public static void Paint(Vector2 uv, Brush br, RenderTexture rt) { var command = new PaintCommand.UV(new Stroke(uv) { firstStroke = false }, rt.GetTextureMeta(), br) { strokeAlphaPortion = Mathf.Clamp01(br.Flow * 0.05f) }; TexMGMT.SHADER_STROKE_SEGMENT_UPDATE(command); // br, br.Speed * 0.05f, id, stroke, out alphaBuffer); float width = br.StrokeWidth(command.TextureData.width, false); RtBrush.localScale = Vector3.one; BrushMesh = PainterCamera.BrushMeshGenerator.GetLongMesh(0, width); RtBrush.localRotation = Quaternion.Euler(new Vector3(0, 0, Vector2.Angle(Vector2.up, Vector2.zero))); RtBrush.localPosition = Stroke.BrushWorldPositionFrom(command.Stroke.uvTo); TexMGMT.Render(); br.GetBrushType(false).AfterStroke(command); }
public virtual void PaintRenderTextureUvSpace(PaintCommand.UV command) { TextureMeta textureMeta = command.TextureData; Brush br = command.Brush; Stroke st = command.Stroke; BeforeStroke(command); if (st.CrossedASeam()) { st.uvFrom = st.uvTo; } command.strokeAlphaPortion = Mathf.Clamp01(br.Flow * 0.05f); TexMGMT.SHADER_STROKE_SEGMENT_UPDATE(command); var rb = RtBrush; rb.localScale = Vector3.one; var direction = st.DeltaUv; var length = direction.magnitude; BrushMesh = PainterCamera.BrushMeshGenerator.GetLongMesh(length * 256, br.StrokeWidth(textureMeta.width, false)); rb.localRotation = Quaternion.Euler(new Vector3(0, 0, (direction.x > 0 ? -1 : 1) * Vector2.Angle(Vector2.up, direction))); rb.localPosition = Stroke.BrushWorldPositionFrom((st.uvFrom + st.uvTo) * 0.5f); TexMGMT.Render(); AfterStroke(command); }
public override void PaintRenderTextureUvSpace(PaintCommand.UV command) //PlaytimePainter painter, Brush br, Stroke st) { Brush br = command.Brush; Stroke st = command.Stroke; BeforeStroke(command); var id = command.TextureData; if (st.firstStroke || br.decalContentious) { if (br.rotationMethod == RotationMethod.FaceStrokeDirection) { var delta = st.uvTo - _previousUv; var portion = Mathf.Clamp01(delta.magnitude * id.width * 4 / br.Size(false)); var newAngle = Vector2.SignedAngle(Vector2.up, delta) + br.decalAngleModifier; br.decalAngle = Mathf.LerpAngle(br.decalAngle, newAngle, portion); _previousUv = st.uvTo; } command.strokeAlphaPortion = 1; TexMGMT.SHADER_STROKE_SEGMENT_UPDATE(command); // br, 1, id, st, out alphaBuffer, command.painter); var tf = RtBrush; tf.localScale = Vector3.one * br.Size(false); tf.localRotation = Quaternion.Euler(new Vector3(0, 0, br.decalAngle)); BrushMesh = PainterCamera.BrushMeshGenerator.GetQuad(); st.uvTo = st.uvTo.To01Space(); var deltaUv = st.DeltaUv; var uv = st.uvTo; if (br.rotationMethod == RotationMethod.FaceStrokeDirection && !st.firstStroke) { var length = Mathf.Max(deltaUv.magnitude * 2 * id.width / br.Size(false), 1); var scale = tf.localScale; if ((Mathf.Abs(Mathf.Abs(br.decalAngleModifier) - 90)) < 40) { scale.x *= length; } else { scale.y *= length; } tf.localScale = scale; uv -= deltaUv * ((length - 1) * 0.5f / length); } tf.localPosition = Stroke.BrushWorldPositionFrom(uv); TexMGMT.Render(); AfterStroke(command); } else { command.OnStrokeComplete(); //painter.AfterStroke(st); } }