private void Apply(GStylizedTerrain t) { if (t.TerrainData == null) { return; } if (PrototypeIndices.Count == 0) { return; } if (Prototypes.Count == 0) { return; } RenderTexture rt = new RenderTexture(MaskResolution, MaskResolution, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); List <Vector4> vertices = SplineCreator.GenerateVerticesWithFalloff(); Internal_Apply(t, rt, vertices); Texture2D mask = GCommon.CreateTexture(MaskResolution, Color.clear); GCommon.CopyFromRT(mask, rt); mask.wrapMode = TextureWrapMode.Clamp; Color[] maskColors = mask.GetPixels(); RemoveObjectFromTerrain(t, maskColors); rt.Release(); GUtilities.DestroyObject(rt); GUtilities.DestroyObject(mask); }
private void Apply(GStylizedTerrain t) { if (t.TerrainData == null) { return; } RenderTexture rt = new RenderTexture(MaskResolution, MaskResolution, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); List <Vector4> vertices = SplineCreator.GenerateVerticesWithFalloff(); Internal_Apply(t, rt, vertices); Texture2D mask = GCommon.CreateTexture(MaskResolution, Color.clear); GCommon.CopyFromRT(mask, rt); mask.wrapMode = TextureWrapMode.Clamp; Color[] maskColors = mask.GetPixels(); if (RemoveTrees) { RemoveTreeOnTerrain(t, maskColors); } if (RemoveGrasses) { RemoveGrassOnTerrain(t, maskColors); t.UpdateGrassPatches(); } t.TerrainData.Foliage.ClearGrassDirtyRegions(); t.TerrainData.SetDirty(GTerrainData.DirtyFlags.Foliage); rt.Release(); GUtilities.DestroyObject(rt); GUtilities.DestroyObject(mask); }