public override bool PaintRenderTexture(StrokeVector stroke, ImageData image, BrushConfig bc, PlaytimePainter pntr) { var vt = pntr.GetVolumeTexture(); if (vt != null) { BrushTypeSphere.Inst.BeforeStroke(pntr, bc, stroke); Shader.SetGlobalVector(VOLUME_POSITION_N_SIZE + "_BRUSH", vt.PosNsize4Shader); Shader.SetGlobalVector(VOLUME_H_SLICES + "_BRUSH", vt.Slices4Shader); if (stroke.mouseDwn) { stroke.posFrom = stroke.posTo; } stroke.useTexcoord2 = false; TexMGMT.ShaderPrepareStroke(bc, bc.speed * 0.05f, image, stroke, pntr); stroke.SetWorldPosInShader(); TexMGMT.brushRendy.FullScreenQuad(); TexMGMT.Render(); BrushTypeSphere.Inst.AfterStroke(pntr, bc, stroke); return(true); } return(false); }
public static void Paint(Vector2 uv, BrushConfig br, RenderTexture rt) { if (TexMGMT.BigRT_pair == null) { TexMGMT.UpdateBuffersState(); } var id = rt.GetImgData(); var stroke = new StrokeVector(uv) { useTexcoord2 = false, firstStroke = false }; TexMGMT.ShaderPrepareStroke(br, br.speed * 0.05f, id, stroke, null); float width = br.StrokeWidth(id.width, false); Rtbrush.localScale = Vector3.one; BrushMesh = brushMeshGenerator.inst().GetLongMesh(0, width); Rtbrush.localRotation = Quaternion.Euler(new Vector3(0, 0, Vector2.Angle(Vector2.up, Vector2.zero))); Rtbrush.localPosition = StrokeVector.BrushWorldPositionFrom(uv); TexMGMT.Render(); AfterStroke(br); }
public override void PaintRenderTexture(PlaytimePainter pntr, BrushConfig br, StrokeVector st) { BeforeStroke(pntr, br, st); if (st.CrossedASeam()) { st.uvFrom = st.uvTo; } if (TexMGMT.BigRT_pair == null) { TexMGMT.UpdateBuffersState(); } ImageData id = pntr.ImgData; TexMGMT.ShaderPrepareStroke(br, br.speed * 0.05f, id, st, pntr); Rtbrush.localScale = Vector3.one * br.StrokeWidth(id.width, false); BrushMesh = brushMeshGenerator.inst().GetQuad(); Rtbrush.localRotation = Quaternion.identity; Rtbrush.localPosition = st.BrushWorldPosition; TexMGMT.Render(); AfterStroke(pntr, br, st); }
public virtual void PaintRenderTexture(PlaytimePainter pntr, BrushConfig br, StrokeVector st) { BeforeStroke(pntr, br, st); if (st.CrossedASeam()) { st.uvFrom = st.uvTo; } ImageData id = pntr.ImgData; TexMGMT.ShaderPrepareStroke(br, br.speed * 0.05f, id, st, pntr); var rb = Rtbrush; rb.localScale = Vector3.one; Vector2 direction = st.Delta_uv; float length = direction.magnitude; BrushMesh = brushMeshGenerator.inst().GetLongMesh(length * 256, br.StrokeWidth(id.width, false)); rb.localRotation = Quaternion.Euler(new Vector3(0, 0, (direction.x > 0 ? -1 : 1) * Vector2.Angle(Vector2.up, direction))); rb.localPosition = StrokeVector.BrushWorldPositionFrom((st.uvFrom + st.uvTo) / 2); TexMGMT.Render(); AfterStroke(pntr, br, st); }
static void PrepareSphereBrush(ImageData id, BrushConfig br, StrokeVector stroke, PlaytimePainter pntr) { if (TexMGMT.BigRT_pair == null) { TexMGMT.UpdateBuffersState(); } if (stroke.mouseDwn) { stroke.posFrom = stroke.posTo; } TexMGMT.ShaderPrepareStroke(br, br.speed * 0.05f, id, stroke, null); Vector2 offset = id.offset - stroke.unRepeatedUV.Floor(); stroke.SetWorldPosInShader(); Shader.SetGlobalVector(PainterDataAndConfig.BRUSH_EDITED_UV_OFFSET, new Vector4(id.tiling.x, id.tiling.y, offset.x, offset.y)); Shader.SetGlobalVector(PainterDataAndConfig.BRUSH_ATLAS_SECTION_AND_ROWS, new Vector4(0, 0, 1, 0)); }
public override void PaintRenderTexture(PlaytimePainter pntr, BrushConfig br, StrokeVector st) { BeforeStroke(pntr, br, st); ImageData id = pntr.ImgData; if ((st.firstStroke) || (br.decalContinious)) { if (br.decalRotationMethod == DecalRotationMethod.StrokeDirection) { Vector2 delta = st.uvTo - previousUV; // if ((st.firstStroke) || (delta.magnitude*id.width > br.Size(false)*0.25f)) { float portion = Mathf.Clamp01(delta.magnitude * id.width * 4 / br.Size(false)); float newAngle = Vector2.SignedAngle(Vector2.up, delta) + br.decalAngleModifier; br.decalAngle = Mathf.LerpAngle(br.decalAngle, newAngle, portion); previousUV = st.uvTo; //} } if (TexMGMT.BigRT_pair == null) { TexMGMT.UpdateBuffersState(); } TexMGMT.ShaderPrepareStroke(br, 1, id, st, pntr); Transform tf = Rtbrush; tf.localScale = Vector3.one * br.Size(false); tf.localRotation = Quaternion.Euler(new Vector3(0, 0, br.decalAngle)); BrushMesh = brushMeshGenerator.inst().GetQuad(); st.uvTo = st.uvTo.To01Space(); Vector2 deltauv = st.Delta_uv; /* * * int strokes = Mathf.Max(1, (br.decalContinious && (!st.firstStroke)) ? (int)(deltauv.magnitude*id.width/br.Size(false)) : 1); * * deltauv /= strokes; * * for (int i = 0; i < strokes; i++) { * st.uvFrom += deltauv;*/ Vector2 uv = st.uvTo; if ((br.decalRotationMethod == DecalRotationMethod.StrokeDirection) && (!st.firstStroke)) { float length = Mathf.Max(deltauv.magnitude * 2 * id.width / br.Size(false), 1); Vector3 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 = StrokeVector.BrushWorldPositionFrom(uv); TexMGMT.Render(); AfterStroke(pntr, br, st); } else { pntr.AfterStroke(st); } }