Version: 2022.2
言語: 日本語

PaintContext

class in UnityEngine.TerrainTools

マニュアルに切り替える

説明

The context for a paint operation that may span multiple connected Terrain tiles.

This class is used to apply an edit operation to an area of Terrain that may span multiple Terrain tiles. 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 Terrain tiles into sourceRenderTarget
4) Apply editing operations, reading from sourceRenderTarget, and writing to destinationRenderTarget
5) PaintContext.ScatterHeightmap, PaintContext.ScatterAlphamap - Write from destinationRenderTarget into Terrain tiles (optional)
6) PaintContext.Cleanup - Destroy RenderTarget resources (required if you call CreateRenderTargets)
7) PaintContext.ApplyDelayedActions - Apply any delayed actions that perform expensive updates


See Also: TerrainPaintTool<T0>

Static 変数

kNormalizedHeightScaleUnity uses this value internally to transform a [0, 1] height value to a texel value, which is stored in TerrainData.heightmapTexture.

変数

destinationRenderTexture(Read Only) RenderTexture that an edit operation writes to modify the data.
heightWorldSpaceMinThe minimum height of all Terrain tiles that this PaintContext touches in world space.
heightWorldSpaceSizeThe height range (from Min to Max) of all Terrain tiles that this PaintContext touches in world space.
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 Terrain tiles.
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 Terrain tiles in this PaintContext.

コンストラクタ

PaintContextCreates a new PaintContext, to edit a target texture on a Terrain, in a region defined by pixelRect.

Public 関数

CleanupReleases the allocated resources of this PaintContext.
CreateRenderTargetsCreates the sourceRenderTexture and destinationRenderTexture.
GatherGathers user-specified Texture data into sourceRenderTexture.
GatherAlphamapGathers the alphamap information into sourceRenderTexture.
GatherHeightmapGathers the heightmap information into sourceRenderTexture.
GatherHolesGathers the Terrain holes information into sourceRenderTexture.
GatherNormalsGathers the normal information into sourceRenderTexture.
GetClippedPixelRectInRenderTexturePixelsRetrieves the clipped pixel rectangle for a Terrain, relative to the PaintContext render textures.
GetClippedPixelRectInTerrainPixelsRetrieves the clipped pixel rectangle for a Terrain.
GetTerrainRetrieves a Terrain from the PaintContext.
ScatterApplies an edited PaintContext by copying modifications back to user-specified RenderTextures for the source Terrain tiles.
ScatterAlphamapApplies an edited alphamap PaintContext by copying modifications back to the source Terrain tiles.
ScatterHeightmapApplies an edited heightmap PaintContext by copying modifications back to the source Terrain tiles.
ScatterHolesApplies an edited Terrain holes PaintContext by copying modifications back to the source Terrain tiles.

Static 関数

ApplyDelayedActionsFlushes the delayed actions created by PaintContext heightmap and alphamap modifications.
CreateFromBoundsConstructs a PaintContext that you can use to edit a texture on a Terrain, in the region defined by boundsInTerrainSpace and extraBorderPixels.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961