class in UnityEngine.Experimental.TerrainAPI
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
The context for a paint operation that may span multiple connected Terrains.
This class is used to apply an edit operation to an area of Terrain that may span multiple Terrains.
A PaintContext may be used to edit heightmap or splatmap data, and may also be used to gather normal data in read-only mode (you cannot write to normals, because they are derived from the heightmap).
A PaintContext will calculate the relevant regions on each Terrain, and collect the original data into a single sourceRenderTarget. Your edit operation can then read from sourcerenderTarget, and write the modified data to destinationRenderTarget. Once you have applied your edit operation, the PaintContext can also write the modified data in destinationRenderTarget back to each Terrain, ensuring no seams between them.
The simplest way to use a PaintContext is through the helper functions in TerrainPaintUtility:
TerrainPaintUtility.BeginPaintHeightmap, TerrainPaintUtility.EndPaintHeightmap, TerrainPaintUtility.BeginPaintTexture, TerrainPaintUtility.EndPaintTexture, TerrainPaintUtility.CollectNormals and TerrainPaintUtility.ReleaseContextResources.
You can also use PaintContext more directly through its member functions. In general, they are used in the following order:
1) Constructor, PaintContext.CreateFromBounds - Construct a PaintContext with a target Terrain and a region to edit
2) PaintContext.CreateRenderTargets - Create the source and destination RenderTargets
3) PaintContext.GatherHeightmap, PaintContext.GatherAlphamap, PaintContext.GatherNormals - Read from Terrains into sourceRenderTarget
4) PaintContext.ScatterHeightmap, PaintContext.ScatterAlphamap - Write from destinationRenderTarget into Terrains (optional)
5) PaintContext.Cleanup - Destroy RenderTarget resources (required if you call CreateRenderTargets)
See Also: TerrainPaintTool<T0>
|destinationRenderTexture||(Read Only) RenderTexture that an edit operation writes to modify the data.|
|oldRenderTexture||(Read Only) The value of RenderTexture.active at the time CreateRenderTargets is called.|
|originTerrain||(Read Only) The Terrain used to build the PaintContext.|
|pixelRect||(Read Only) The pixel rectangle that this PaintContext represents.|
|pixelSize||(Read Only) The size of a PaintContext pixel in terrain units (as defined by originTerrain.)|
|sourceRenderTexture||(Read Only) Render target that stores the original data from the Terrains.|
|targetTextureHeight||(Read Only) The height of the target terrain texture. This is the resolution for a single Terrain.|
|targetTextureWidth||(Read Only) The width of the target terrain texture. This is the resolution for a single Terrain.|
|terrainCount||(Read Only) The number of Terrains in this PaintContext.|
|PaintContext||Creates a new PaintContext, to edit a target texture on a Terrain, in a region defined by pixelRect.|
|Cleanup||Releases the allocated resources of this PaintContext.|
|CreateRenderTargets||Creates the sourceRenderTexture and destinationRenderTexture.|
|GatherAlphamap||Gathers the alphamap information into sourceRenderTexture.|
|GatherHeightmap||Gathers the heightmap information into sourceRenderTexture.|
|GatherNormals||Gathers the normal information into sourceRenderTexture.|
|GetClippedPixelRectInRenderTexturePixels||Retrieves the clipped pixel rectangle for a Terrain, relative to the PaintContext render textures.|
|GetClippedPixelRectInTerrainPixels||Retrieves the clipped pixel rectangle for a Terrain.|
|GetTerrain||Retrieves a Terrain from the PaintContext.|
|ScatterAlphamap||Applies an edited alphamap PaintContext by copying modifications back to the source Terrains.|
|ScatterHeightmap||Applies an edited heightmap PaintContext by copying modifications back to the source Terrains.|