Nature Renderer 1.1.8 또는 더 높은 버전이 필요합니다.
터레인을 영구적으로 변경해야 하는 경우 런타임 중 터레인 디테일을 편집할 수 있습니다.
터레인 편집 방법
- TerrainData.SetDetailLayer.Unity의 터레인 데이터를 편집합니다.
- TerrainChangedFlags.RemoveDirtyDetailsImmediately 파라미터를 사용해 Nature Renderer 컴포넌트에 RebuildBuffers를 호출합니다.
- Nature Renderer에서 터레인의 수정된 부분을 자동으로 찾아 해당 영역의 내부 버퍼를 재빌드합니다. 재빌드는 별도의 워커 스레드에서 처리되며 마무리까지 프레임 정도 소요됩니다. 그동안에는 이전 터레인 데이터가 계속 표시됩니다.
참고: 터레인의 하이트맵을 변경하거나 전에는 없던 디테일을 새로 추가하는 경우, Nature Renderer는 수정된 해당 영역만이 아니라 전 터레인을 재빌드해야 합니다. 터레인이 클수록 1, 2초가 더 소요됩니다.
Unity 문서에서 가져온 수정 예
using UnityEngine;
using VisualDesignCafe.Rendering.Nature;
public class ExampleClass : MonoBehaviour { // Set all pixels in a detail map below a certain
// threshold to zero. void DetailMapCutoff(Terrain t, float threshold) { // Get all of layer zero. var map =
t.terrainData.GetDetailLayer(
0,
0,
t.terrainData.detailWidth,
t.terrainData.detailHeight,
0);
// For each pixel in the detail map... for (int y = 0; y < t.terrainData.detailHeight; y++) { for (int x = 0; x < t.terrainData.detailWidth; x++) { // If the pixel value is below the threshold then // set it to zero. if (map[x, y] < threshold) { map[x, y] = 0; } } }
// Assign the modified map back. t.terrainData.SetDetailLayer(0, 0, 0, map);
// Update Nature Renderer's buffers.
t.GetComponent<NatureRenderer>().RebuildBuffers(
TerrainChangedFlags.RemoveDirtyDetailsImmediately ); } }