public PaintContext AcquireHolesTexture(bool writable, Terrain terrain, Rect boundsInTerrainSpace, int extraBorderPixels = 0) { m_WriteToHoles = writable; #if UNITY_2019_3_OR_NEWER m_HolesContext = TerrainPaintUtility.BeginPaintHoles(terrain, boundsInTerrainSpace, extraBorderPixels); #endif return(m_HolesContext); }
public PaintContext AcquireHolesTexture(bool writable, Terrain terrain, Rect boundsInTerrainSpace, int extraBorderPixels = 0) { m_WriteToHoles = writable; #if UNITY_2019_3_OR_NEWER m_HolesContext = TerrainPaintUtility.BeginPaintHoles(terrain, boundsInTerrainSpace, extraBorderPixels); if (m_HolesContext == null) { return(null); } m_HolesContext.sourceRenderTexture.name = $"{m_Name}::HolesContext::SourceRT"; m_HolesContext.destinationRenderTexture.name = $"{m_Name}::HolesContext::DestRT"; #endif return(m_HolesContext); }
public override bool OnPaint(Terrain terrain, IOnPaint editContext) { BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, editContext.uv, editContext.brushSize, 0.0f); PaintContext paintContext = TerrainPaintUtility.BeginPaintHoles(terrain, brushXform.GetBrushXYBounds()); Material mat = TerrainPaintUtility.GetBuiltinPaintMaterial(); float brushStrength = Event.current.shift ? editContext.brushStrength : -editContext.brushStrength; Vector4 brushParams = new Vector4(brushStrength, 0.0f, 0.0f, 0.0f); mat.SetTexture("_BrushTex", editContext.brushTexture); mat.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, mat, (int)TerrainPaintUtility.BuiltinPaintMaterialPasses.PaintHoles); TerrainPaintUtility.EndPaintHoles(paintContext, "Terrain Paint - Paint Holes"); return(true); }