private void ApplyBrushInternal(PaintContext paintContext, float brushStrength, Texture brushTexture, BrushTransform brushXform) { Material mat = TerrainPaintUtility.GetBuiltinPaintMaterial(); Vector4 brushParams = new Vector4(brushStrength * 0.01f, 0.5f * m_Height, 0.0f, 0.0f); mat.SetTexture("_BrushTex", brushTexture); mat.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, mat, (int)TerrainPaintUtility.BuiltinPaintMaterialPasses.SetHeights); }
public static void ShowDefaultPreviewBrush(Terrain terrain, Texture brushTexture, float brushSize) { Ray mouseRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hit; if (terrain.GetComponent <Collider>().Raycast(mouseRay, out hit, Mathf.Infinity)) { BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, hit.textureCoord, brushSize, 0.0f); PaintContext ctx = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds(), 1); DrawBrushPreview(ctx, TerrainPaintUtilityEditor.BrushPreview.SourceRenderTexture, brushTexture, brushXform, GetDefaultBrushPreviewMaterial(), 0); TerrainPaintUtility.ReleaseContextResources(ctx); } }
void WriteReg(PaintContext ctx, string name, ushort value, ushort prevValue) { if (value != prevValue) { ctx.ForegroundColor = ConsoleColor.White; } else { ctx.ForegroundColor = ConsoleColor.Gray; } ctx.Write("{0}: {1:X4}", name, value); }
public override void Paint(PaintContext context) { if (context.view_embedder == null) { return; } EmbeddedViewParams @params = new EmbeddedViewParams(); SKMatrix transform = context.canvas.TotalMatrix; @params.offsetPixels = new SKPoint(transform.TransX, transform.TransY); @params.sizePoints = size_; context.view_embedder.CompositeEmbeddedView(view_id_, @params); }
public override bool OnPaint(Terrain terrain, IOnPaint editContext) { if (m_Mesh == null || Event.current.type != EventType.MouseDown || Event.current.shift == true) { return(false); } Vector3 terrainSize = terrain.terrainData.size; PaintContext context = ApplyBrushInternal(terrain, editContext.uv * new Vector2(terrainSize.x, terrainSize.z), 0); TerrainPaintUtility.EndPaintHeightmap(context, "Terrain Paint - Mesh Stamp"); return(true); }
public override void OnSceneGUI(Terrain terrain, IOnSceneGUI editContext) { commonUI.OnSceneGUI2D(terrain, editContext); // only do the rest if user mouse hits valid terrain or they are using the // brush parameter hotkeys to resize, etc if (!editContext.hitValidTerrain && !commonUI.isInUse) { return; } // update brush UI group commonUI.OnSceneGUI(terrain, editContext); // dont render preview if this isnt a repaint. losing performance if we do if (Event.current.type != EventType.Repaint) { return; } if (commonUI.isRaycastHitUnderCursorValid) { using (IBrushRenderPreviewUnderCursor brushRender = new BrushRenderPreviewUIGroupUnderCursor(commonUI, "PaintHeight", editContext.brushTexture)) { if (brushRender.CalculateBrushTransform(out BrushTransform brushXform)) { PaintContext paintContext = brushRender.AcquireHeightmap(false, brushXform.GetBrushXYBounds(), 1); Material previewMaterial = Utility.GetDefaultPreviewMaterial(); var texelCtx = Utility.CollectTexelValidity(paintContext.originTerrain, brushXform.GetBrushXYBounds()); Utility.SetupMaterialForPaintingWithTexelValidityContext(paintContext, texelCtx, brushXform, previewMaterial); TerrainPaintUtilityEditor.DrawBrushPreview(paintContext, TerrainBrushPreviewMode.SourceRenderTexture, editContext.brushTexture, brushXform, previewMaterial, 0); // draw result preview { float s = Event.current.control ? -commonUI.brushStrength : commonUI.brushStrength; ApplyBrushInternal(terrain, brushRender, paintContext, s, editContext.brushTexture, brushXform); // restore old render target RenderTexture.active = paintContext.oldRenderTexture; previewMaterial.SetTexture("_HeightmapOrig", paintContext.sourceRenderTexture); TerrainPaintUtilityEditor.DrawBrushPreview(paintContext, TerrainBrushPreviewMode.DestinationRenderTexture, editContext.brushTexture, brushXform, previewMaterial, 1); texelCtx.Cleanup(); } } } } }
/// <summary> /// Called when the paint context changed. /// </summary> protected override void OnPaintContextChanged() { var context = new PaintContext <TDrawingContext>(); var w = LegendShapeSize; var sh = 0f; if (Stroke != null) { var strokeClone = Stroke.CloneTask(); var visual = new TVisual { X = 0, Y = 0, Height = (float)LegendShapeSize, Width = (float)LegendShapeSize, CenterX = (float)LegendShapeSize * 0.5f, CenterY = (float)LegendShapeSize * 0.5f, StartAngle = 0, SweepAngle = 359.9999f }; sh = strokeClone.StrokeThickness; strokeClone.ZIndex = 1; w += 2 * strokeClone.StrokeThickness; strokeClone.AddGeometyToPaintTask(visual); _ = context.PaintTasks.Add(strokeClone); } if (Fill != null) { var fillClone = Fill.CloneTask(); var visual = new TVisual { X = sh, Y = sh, Height = (float)LegendShapeSize, Width = (float)LegendShapeSize, CenterX = (float)LegendShapeSize * 0.5f, CenterY = (float)LegendShapeSize * 0.5f, StartAngle = 0, SweepAngle = 359.9999f }; fillClone.AddGeometyToPaintTask(visual); _ = context.PaintTasks.Add(fillClone); } context.Width = w; context.Height = w; paintContext = context; }
protected void PaintChildren(PaintContext context) { FML_DCHECK(needs_painting()); // Intentionally not tracing here as there should be no self-time // and the trace event on this common function has a small overhead. foreach (var layer in layers_) { if (layer.needs_painting()) { layer.Paint(context); } } }
public void ApplyBrushInternal(IPaintContextRender renderer, PaintContext paintContext, float brushStrength, float pinchAmount, Texture brushTexture, BrushTransform brushXform) { Material mat = GetPaintMaterial(); pinchAmount = Event.current.control ? -pinchAmount : pinchAmount; //TODO - use shortcut system once it supports binding modifiers Vector4 brushParams = new Vector4(brushStrength, 0.0f, pinchAmount, Mathf.Deg2Rad * commonUI.brushRotation); mat.SetTexture("_BrushTex", brushTexture); mat.SetVector("_BrushParams", brushParams); renderer.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); renderer.RenderBrush(paintContext, mat, 0); }
private void ApplyBrushInternal(PaintContext paintContext, float brushStrength, Texture brushTexture, BrushTransform brushXform) { Material mat = TerrainPaintUtility.GetBuiltinPaintMaterial(); brushStrength = Event.current.shift ? -brushStrength : brushStrength; Vector4 brushParams = new Vector4(0.01f * brushStrength, 0.0f, 0.0f, 0.0f); mat.SetTexture("_BrushTex", brushTexture); mat.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, mat, (int)TerrainBuiltinPaintMaterialPasses.RaiseLowerHeight); }
public override bool OnPaint(Terrain terrain, IOnPaint editContext) { if (Event.current.type == EventType.MouseDown) { m_PrevBrushPos = editContext.uv; return(false); } if (Event.current.type == EventType.MouseDrag && m_PreviousEvent == EventType.MouseDrag) { BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, editContext.uv, editContext.brushSize, 0.0f); PaintContext paintContext = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds(), 1); Vector2 smudgeDir = editContext.uv - m_PrevBrushPos; paintContext.sourceRenderTexture.filterMode = FilterMode.Bilinear; Material mat = GetPaintMaterial(); PaintContext maskContext = null; if (m_TextureMask || m_TextureStencil) { TerrainLayer maskTerrainLayer = terrain.terrainData.terrainLayers[m_TextureMask ? m_maskIndex : m_stencilIndex]; maskContext = TerrainPaintUtility.BeginPaintTexture(terrain, brushXform.GetBrushXYBounds(), maskTerrainLayer); if (maskContext == null) { return(false); } mat.SetTexture("_MaskTex", maskContext.sourceRenderTexture); } mat.SetInt("_MaskStencil", m_TextureMask ? 1 : (m_TextureStencil ? 2 : 0)); Vector4 brushParams = new Vector4(editContext.brushStrength, smudgeDir.x, smudgeDir.y, 0); mat.SetTexture("_BrushTex", editContext.brushTexture); mat.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, mat, 0); TerrainPaintUtility.EndPaintHeightmap(paintContext, "Terrain Paint - Masked Smudge"); if (maskContext != null) { TerrainPaintUtility.ReleaseContextResources(maskContext); } m_PrevBrushPos = editContext.uv; } m_PreviousEvent = Event.current.type; return(false); }
public override void OnSceneGUI(Terrain terrain, IOnSceneGUI editContext) { commonUI.OnSceneGUI2D(terrain, editContext); // only do the rest if user mouse hits valid terrain or they are using the // brush parameter hotkeys to resize, etc if (!editContext.hitValidTerrain && !commonUI.isInUse) { return; } // update brush UI group commonUI.OnSceneGUI(terrain, editContext); // dont render preview if this isnt a repaint. losing performance if we do if (Event.current.type != EventType.Repaint) { return; } Texture brushTexture = editContext.brushTexture; using (IBrushRenderPreviewUnderCursor brushRender = new BrushRenderPreviewUIGroupUnderCursor(commonUI, "PinchHeight", brushTexture)) { if (brushRender.CalculateBrushTransform(out BrushTransform brushXform)) { Material material = TerrainPaintUtilityEditor.GetDefaultBrushPreviewMaterial(); PaintContext ctx = brushRender.AcquireHeightmap(false, brushXform.GetBrushXYBounds(), 1); brushRender.RenderBrushPreview(ctx, TerrainPaintUtilityEditor.BrushPreview.SourceRenderTexture, brushXform, material, 0); // draw result preview { float finalPinchAmount = m_PinchAmount * 0.005f; //scale to a reasonable value and negate so default mode is clockwise if (Event.current.shift) { finalPinchAmount *= -1.0f; } ApplyBrushInternal(brushRender, ctx, commonUI.brushStrength, finalPinchAmount, brushTexture, brushXform); // restore old render target RenderTexture.active = ctx.oldRenderTexture; material.SetTexture("_HeightmapOrig", ctx.sourceRenderTexture); brushRender.RenderBrushPreview(ctx, TerrainPaintUtilityEditor.BrushPreview.DestinationRenderTexture, brushXform, material, 1); } } } }
public override bool OnPaint(Terrain terrain, IOnPaint editContext) { commonUI.OnPaint(terrain, editContext); if (!commonUI.allowPaint) { return(true); } using (IBrushRenderUnderCursor brushRender = new BrushRenderUIGroupUnderCursor(commonUI, "PinchHeight", editContext.brushTexture)) { if (brushRender.CalculateBrushTransform(out BrushTransform brushXform)) { float finalPinchAmount = m_PinchAmount * 0.005f; //scale to a reasonable value and negate so default mode is clockwise if (Event.current.shift) { finalPinchAmount *= -1.0f; } Material mat = GetPaintMaterial(); //smudge splat map if (m_AffectMaterials) { for (int i = 0; i < terrain.terrainData.terrainLayers.Length; i++) { TerrainLayer layer = terrain.terrainData.terrainLayers[i]; PaintContext paintContext = brushRender.AcquireTexture(true, brushXform.GetBrushXYBounds(), layer); paintContext.sourceRenderTexture.filterMode = FilterMode.Bilinear; brushRender.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); brushRender.RenderBrush(paintContext, mat, 0); brushRender.Release(paintContext); } } if (m_AffectHeight) { PaintContext paintContext = brushRender.AcquireHeightmap(true, brushXform.GetBrushXYBounds(), 1); paintContext.sourceRenderTexture.filterMode = FilterMode.Bilinear; ApplyBrushInternal(brushRender, paintContext, commonUI.brushStrength, finalPinchAmount, editContext.brushTexture, brushXform); brushRender.Release(paintContext); } } } return(false); }
public PaintContext AcquireHeightmap(bool writable, Terrain terrain, Rect boundsInTerrainSpace, int extraBorderPixels = 0) { m_WriteToHeightmap = writable; m_HeightmapContext = TerrainPaintUtility.BeginPaintHeightmap(terrain, boundsInTerrainSpace, extraBorderPixels); if (m_HeightmapContext == null) { return(null); } m_HeightmapContext.sourceRenderTexture.name = $"{m_Name}::HeightmapContext::SourceRT"; m_HeightmapContext.destinationRenderTexture.name = $"{m_Name}::HeightmapContext::DestRT"; return(m_HeightmapContext); }
public PaintContext AcquireTexture(bool writable, Terrain terrain, Rect boundsInTerrainSpace, TerrainLayer layer, int extraBorderPixels = 0) { m_WriteToTexture = writable; m_TextureContext = TerrainPaintUtility.BeginPaintTexture(terrain, boundsInTerrainSpace, layer, extraBorderPixels); if (m_TextureContext == null) { return(null); } m_TextureContext.sourceRenderTexture.name = $"{m_Name}::TextureContext::SourceRT"; m_TextureContext.destinationRenderTexture.name = $"{m_Name}::TextureContext::DestRT"; return(m_TextureContext); }
public override bool OnPaint(Terrain terrain, IOnPaint editContext) { commonUI.OnPaint(terrain, editContext); if (!commonUI.allowPaint) { return(true); } Vector2 uv = editContext.uv; if (commonUI.ScatterBrushStamp(ref terrain, ref uv)) { using (IBrushRenderUnderCursor brushRender = new BrushRenderUIGroupUnderCursor(commonUI, "WindErosion", editContext.brushTexture)) { if (brushRender.CalculateBrushTransform(out BrushTransform brushXform)) { PaintContext paintContext = brushRender.AcquireHeightmap(true, brushXform.GetBrushXYBounds(), 4); paintContext.sourceRenderTexture.filterMode = FilterMode.Bilinear; //paintContext.sourceRenderTexture = input heightmap //Add Velocity (user wind direction and strength, or texture input, noise, forces, drag etc...) float angle = commonUI.brushRotation; //m_WindAngleDegrees + r; float r = 0.5f * (2.0f * UnityEngine.Random.value - 1.0f) * 0.01f * m_Eroder.m_WindSpeedJitter; float speed = m_Eroder.m_WindSpeed.value + r; float rad = angle * Mathf.Deg2Rad; m_Eroder.m_WindVel = speed * (new Vector4(-Mathf.Sin(rad), Mathf.Cos(rad), 0.0f, 0.0f)); m_Eroder.inputTextures["Height"] = paintContext.sourceRenderTexture; Vector2 texelSize = new Vector2(terrain.terrainData.size.x / terrain.terrainData.heightmapResolution, terrain.terrainData.size.z / terrain.terrainData.heightmapResolution); m_Eroder.ErodeHeightmap(terrain.terrainData.size, brushXform.GetBrushXYBounds(), texelSize); //Blit the result onto the new height map Material mat = GetPaintMaterial(); Vector4 brushParams = new Vector4(commonUI.brushStrength, 0.0f, 0.0f, 0.0f); mat.SetTexture("_BrushTex", editContext.brushTexture); mat.SetTexture("_NewHeightTex", m_Eroder.outputTextures["Height"]); mat.SetVector("_BrushParams", brushParams); brushRender.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); brushRender.RenderBrush(paintContext, mat, 0); } } } return(true); }
public void Release(PaintContext paintContext) { if (ReferenceEquals(paintContext, m_HeightmapContext)) { if (m_WriteToHeightmap) { TerrainPaintUtility.EndPaintHeightmap(m_HeightmapContext, $"{m_Name} - Heightmap"); } else { TerrainPaintUtility.ReleaseContextResources(m_HeightmapContext); } m_HeightmapContext = null; } else if (ReferenceEquals(paintContext, m_NormalmapContext)) { TerrainPaintUtility.ReleaseContextResources(m_NormalmapContext); m_NormalmapContext = null; } else if (ReferenceEquals(paintContext, m_TextureContext)) { if (m_WriteToTexture) { TerrainPaintUtility.EndPaintTexture(m_TextureContext, $"{m_Name} - Texture"); } else { TerrainPaintUtility.ReleaseContextResources(m_TextureContext); } m_TextureContext = null; } #if UNITY_2019_3_OR_NEWER else if (ReferenceEquals(paintContext, m_HolesContext)) { if (m_WriteToHoles) { TerrainPaintUtility.EndPaintHoles(m_HolesContext, "Terrain Paint - Paint Holes"); } else { TerrainPaintUtility.ReleaseContextResources(m_HolesContext); } m_HolesContext = null; } #endif }
void RestoreTerrain(Rect selection) { if (baked) { baked = false; return; } PaintContext prevPaintContext = TerrainPaintUtility.BeginPaintHeightmap(terrain, selection); Graphics.CopyTexture(prevRenderTexture, prevPaintContext.destinationRenderTexture); TerrainPaintUtility.EndPaintHeightmap(prevPaintContext, "Terrain"); terrain.terrainData.SyncHeightmap(); }
private void ApplyBrushInternal(PaintContext paintContext, float brushStrength, Texture brushTexture, BrushTransform brushXform, Terrain terrain) { Material material = TerrainPaintUtility.GetBuiltinPaintMaterial(); float height = m_StampHeight / terrain.terrainData.size.y; Vector4 brushParams = new Vector4(brushStrength, 0.0f, height, 1.0f); material.SetTexture("_BrushTex", brushTexture); material.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, material); Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, material, (int)TerrainPaintUtility.BuiltinPaintMaterialPasses.StampHeight); }
public PaintContext createContext( java.awt.image.ColorModel cm, Rectangle r, java.awt.geom.Rectangle2D r2d, java.awt.geom.AffineTransform xform, RenderingHints rhs ) { if (currentPaintContext != null) { return(currentPaintContext); } currentPaintContext = new Color.ColorPaintContext(value); return(currentPaintContext); }
public override bool OnPaint(Terrain terrain, IOnPaint editContext) { // ignore mouse drags if (Event.current.type == EventType.MouseDrag) { return(true); } BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, editContext.uv, editContext.brushSize, 0.0f); PaintContext paintContext = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds()); ApplyBrushInternal(paintContext, editContext.brushStrength, editContext.brushTexture, brushXform, terrain, Event.current.shift); TerrainPaintUtility.EndPaintHeightmap(paintContext, "Terrain Paint - Stamp"); return(true); }
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: void Paint(PaintContext& context) const override public override void Paint(PaintContext context) { TRACE_EVENT0("flutter", "ShaderMaskLayer::Paint"); FML_DCHECK(needs_painting()); Layer.AutoSaveLayer save = Layer.AutoSaveLayer.Create(context, paint_bounds(), null); PaintChildren(context); SKPaint paint = new SKPaint(); paint.BlendMode = blend_mode_; paint.Shader = shader_; context.canvas.Translate(mask_rect_.Left, mask_rect_.Top); context.canvas.DrawRect(new SKRect(0, 0, mask_rect_.Width, mask_rect_.Height), paint); }
public void OnSceneGUI(Terrain currentTerrain, IOnSceneGUI editContext, BrushSettings brushSettings) { if (m_StartTerrain != null && m_StartPoint != null) { // anchor is placed on the start terrain, independent of the active one; needed for multi-tiles Terrain terrain = m_StartTerrain; BrushTransform anchorBrushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, m_StartPoint, brushSettings.brushSize, brushSettings.brushRotationDegrees); PaintContext anchorCtx = TerrainPaintUtility.BeginPaintHeightmap(terrain, anchorBrushXform.GetBrushXYBounds(), 1); Material brushPreviewMat = BrushUtilities.GetDefaultBrushPreviewMaterial(); brushPreviewMat.color = anchorBrushColor; BrushUtilities.DrawBrushPreview(anchorCtx, BrushUtilities.BrushPreview.SourceRenderTexture, editContext.brushTexture, anchorBrushXform, brushPreviewMat, 0); TerrainPaintUtility.ReleaseContextResources(anchorCtx); } }
private void ApplyBrushInternal(PaintContext paintContext, float brushStrength, Texture brushTexture, BrushTransform brushXform, Terrain terrain) { Material mat = TerrainPaintUtility.GetBuiltinPaintMaterial(); float brushTargetHeight = Mathf.Clamp01((m_TargetHeight - paintContext.heightWorldSpaceMin) / paintContext.heightWorldSpaceSize); Vector4 brushParams = new Vector4(brushStrength * 0.01f, PaintContext.kNormalizedHeightScale * brushTargetHeight, 0.0f, 0.0f); mat.SetTexture("_BrushTex", brushTexture); mat.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, mat, (int)TerrainPaintUtility.BuiltinPaintMaterialPasses.SetHeights); }
private void ApplyBrushInternal(PaintContext paintContext, float brushStrength, Texture brushTexture, BrushTransform brushXform, Terrain terrain) { Material mat = TerrainPaintUtility.GetBuiltinPaintMaterial(); float terrainHeight = Mathf.Clamp01((m_HeightWorldSpace - terrain.transform.position.y) / terrain.terrainData.size.y); Vector4 brushParams = new Vector4(brushStrength * 0.01f, 0.5f * terrainHeight, 0.0f, 0.0f); mat.SetTexture("_BrushTex", brushTexture); mat.SetVector("_BrushParams", brushParams); TerrainPaintUtility.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); Graphics.Blit(paintContext.sourceRenderTexture, paintContext.destinationRenderTexture, mat, (int)TerrainPaintUtility.BuiltinPaintMaterialPasses.SetHeights); }
public override void Paint(PaintContext context) { TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint"); FML_DCHECK(needs_painting()); var save = Layer.AutoSaveLayer.Create( context, paint_bounds(), new SKPaint() { ImageFilter = filter_ }); //, null, filter_, 0); PaintChildren(context); }
private void DrawBrushPreviews(Terrain terrain, IOnSceneGUI editContext) { Vector2 sampleUV; BrushTransform sampleXform; PaintContext sampleContext = null; Material previewMat = Utility.GetDefaultPreviewMaterial(); // draw sample location brush and create context data to be used when drawing target brush previews if (m_SampleLocation.terrain != null) { sampleUV = TerrainUVFromBrushLocation(m_SampleLocation.terrain, m_SampleLocation.pos); sampleXform = TerrainPaintUtility.CalculateBrushTransform(m_SampleLocation.terrain, sampleUV, commonUI.brushSize, commonUI.brushRotation); sampleContext = TerrainPaintUtility.BeginPaintHeightmap(m_SampleLocation.terrain, sampleXform.GetBrushXYBounds()); var texelCtx = Utility.CollectTexelValidity(sampleContext.originTerrain, sampleXform.GetBrushXYBounds()); Utility.SetupMaterialForPaintingWithTexelValidityContext(sampleContext, texelCtx, sampleXform, previewMat); TerrainPaintUtilityEditor.DrawBrushPreview(sampleContext, TerrainBrushPreviewMode.SourceRenderTexture, editContext.brushTexture, sampleXform, previewMat, 0); texelCtx.Cleanup(); } // draw brush preview and mesh preview for current mouse position if (commonUI.isRaycastHitUnderCursorValid) { BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, commonUI.raycastHitUnderCursor.textureCoord, commonUI.brushSize, commonUI.brushRotation); PaintContext ctx = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds(), 1); var texelCtx = Utility.CollectTexelValidity(ctx.originTerrain, brushXform.GetBrushXYBounds()); Utility.SetupMaterialForPaintingWithTexelValidityContext(ctx, texelCtx, brushXform, previewMat); TerrainPaintUtilityEditor.DrawBrushPreview(ctx, TerrainBrushPreviewMode.SourceRenderTexture, editContext.brushTexture, brushXform, previewMat, 0); if (sampleContext != null && cloneToolProperties.m_PaintHeightmap) { ApplyHeightmap(sampleContext, ctx, brushXform, terrain, editContext.brushTexture, commonUI.brushStrength); RenderTexture.active = ctx.oldRenderTexture; previewMat.SetTexture("_HeightmapOrig", ctx.sourceRenderTexture); TerrainPaintUtilityEditor.DrawBrushPreview(ctx, TerrainBrushPreviewMode.DestinationRenderTexture, editContext.brushTexture, brushXform, previewMat, 1); } // Restores RenderTexture.active ctx.Cleanup(); texelCtx.Cleanup(); } // Restores RenderTexture.active sampleContext?.Cleanup(); }
public override void Paint(PaintContext context) { TRACE_EVENT0("flutter", "ClipPathLayer::Paint"); FML_DCHECK(needs_painting()); context.canvas.ClipPath(clip_path_, antialias: clip_behavior_ != Clip.hardEdge); if (clip_behavior_ == Clip.antiAliasWithSaveLayer) { context.canvas.SaveLayer(paint_bounds(), null); } PaintChildren(context); if (clip_behavior_ == Clip.antiAliasWithSaveLayer) { context.canvas.Restore(); } }
void ApplyBrushInternal(IPaintContextRender renderer, PaintContext paintContext, float brushStrength, float finalTwistAmount, Texture brushTexture, BrushTransform brushXform) { Material mat = GetPaintMaterial(); if (Event.current.control) { finalTwistAmount *= -1.0f; } Vector4 brushParams = new Vector4(brushStrength, 0.0f, finalTwistAmount, 0.0f); mat.SetTexture("_BrushTex", brushTexture); mat.SetVector("_BrushParams", brushParams); renderer.SetupTerrainToolMaterialProperties(paintContext, brushXform, mat); renderer.RenderBrush(paintContext, mat, 0); }
public override void OnSceneGUI(Terrain terrain, IOnSceneGUI editContext) { // We're only doing painting operations, early out if it's not a repaint if (Event.current.type != EventType.Repaint) { return; } if (editContext.hitValidTerrain) { BrushTransform brushXform = TerrainPaintUtility.CalculateBrushTransform(terrain, editContext.raycastHit.textureCoord, editContext.brushSize, 0.0f); PaintContext ctx = TerrainPaintUtility.BeginPaintHeightmap(terrain, brushXform.GetBrushXYBounds(), 1); TerrainPaintUtilityEditor.DrawBrushPreview(ctx, TerrainPaintUtilityEditor.BrushPreview.SourceRenderTexture, editContext.brushTexture, brushXform, TerrainPaintUtilityEditor.GetDefaultBrushPreviewMaterial(), 0); TerrainPaintUtility.ReleaseContextResources(ctx); } }
public PaintContext createContext( java.awt.image.ColorModel cm, Rectangle r, java.awt.geom.Rectangle2D r2d, java.awt.geom.AffineTransform xform, RenderingHints rhs ) { if (currentPaintContext != null) { return currentPaintContext; } currentPaintContext = new Color.ColorPaintContext(value); return currentPaintContext; }