public override bool OnPaint(Terrain terrain, IOnPaint editContext) { BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, editContext.uv, editContext.brushSize, 0.0f); PaintContext paintContext = TerrainPaintUtility.BeginPaintSurfaceMask(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.PaintSurfaceMask); TerrainPaintUtility.EndPaintSurfaceMask(paintContext, "Terrain Paint - Paint Surface Mask"); return(true); }