Ejemplo n.º 1
0
        public virtual bool PEGI()
        {
            ImageData id = InspectedImageData;

            bool      cpuBlit     = id == null ? InspectedBrush.TargetIsTex2D : id.destination == TexTarget.Texture2D;
            BrushType brushType   = InspectedBrush.Type(cpuBlit);
            bool      usingDecals = (!cpuBlit) && brushType.IsUsingDecals;

            bool changed = false;

            pegi.newLine();

            if ((!cpuBlit) && (!usingDecals))
            {
                changed |= "Hardness:".edit("Makes edges more rough.", 70, ref InspectedBrush.Hardness, 1f, 512f).nl();
            }

            changed |= (usingDecals ? "Tint alpha" : "Speed").edit(usingDecals ? 70 : 40, ref InspectedBrush.speed, 0.01f, 20).nl();

            pegi.write("Scale:", 40);

            if (InspectedBrush.IsA3Dbrush(InspectedPainter))
            {
                Mesh m = PlaytimePainter.inspectedPainter.GetMesh();

                float maxScale = (m != null ? m.bounds.max.magnitude : 1) * (PlaytimePainter.inspectedPainter == null ? 1 : PlaytimePainter.inspectedPainter.transform.lossyScale.magnitude);

                changed |= pegi.edit(ref InspectedBrush.Brush3D_Radius, 0.001f * maxScale, maxScale * 0.5f);
            }
            else
            {
                if (!brushType.IsPixelPerfect)
                {
                    changed |= pegi.edit(ref InspectedBrush.Brush2D_Radius, cpuBlit ? 1 : 0.1f, usingDecals ? 128 : (id != null ? id.width * 0.5f : 256));
                }
                else
                {
                    int val = (int)InspectedBrush.Brush2D_Radius;
                    changed |= pegi.edit(ref val, (int)(cpuBlit ? 1 : 0.1f), (int)(usingDecals ? 128 : (id != null ? id.width * 0.5f : 256)));
                    InspectedBrush.Brush2D_Radius = val;
                }
            }

            pegi.newLine();

            if ((InspectedBrush.BlitMode.UsingSourceTexture) && (id == null || id.TargetIsRenderTexture()))
            {
                if (TexMGMTdata.sourceTextures.Count > 0)
                {
                    pegi.write("Copy From:", 70);
                    changed |= pegi.selectOrAdd(ref InspectedBrush.selectedSourceTexture, ref TexMGMTdata.sourceTextures);
                }
                else
                {
                    "Add Textures to Render Camera to copy from".nl();
                }
            }

            pegi.newLine();

            return(changed);
        }
 public override void AfterGPUStroke(PlaytimePainter p, BrushConfig br, StrokeVector st, BrushType type)
 {
     if (br.IsA3Dbrush(p) && p.IsAtlased())
     {
         Shader.SetGlobalVector(PainterDataAndConfig.BRUSH_ATLAS_SECTION_AND_ROWS, new Vector4(0, 0, 1, 0));
     }
 }
Ejemplo n.º 3
0
        public StdEncoder EncodeStrokeFor(PlaytimePainter painter)
        {
            var id = painter.ImgData;

            bool rt = id.TargetIsRenderTexture();

            BlitMode  mode = BlitMode;
            BrushType type = Type(!rt);

            bool worldSpace = rt && IsA3Dbrush(painter);

            StdEncoder cody = new StdEncoder()

                              .Add(rt ? "typeGPU" : "typeCPU", _type(!rt));

            if (worldSpace)
            {
                cody.Add("size3D", Brush3D_Radius);
            }
            else
            {
                cody.Add("size2D", Brush2D_Radius / ((float)id.width));
            }


            cody.Add_Bool("useMask", useMask)
            .Add("mode", _bliTMode);

            if (useMask)
            {
                cody.Add("mask", (int)mask);
            }

            cody.Add("bc", colorLinear);

            if (mode.UsingSourceTexture)
            {
                cody.Add("source", selectedSourceTexture);
            }

            if (rt)
            {
                if ((mode.GetType() == typeof(BlitModeBlur)))
                {
                    cody.Add("blur", blurAmount);
                }

                if (type.IsUsingDecals)
                {
                    cody.Add("decA", decalAngle)
                    .Add("decNo", selectedDecal);
                }

                if (useMask)
                {
                    cody.Add("Smask", selectedSourceMask)
                    .Add("maskTil", maskTiling)
                    .Add_Bool("maskFlip", flipMaskAlpha)
                    .Add("maskOff", maskOffset);
                }
            }

            cody.Add("hard", Hardness)
            .Add("speed", speed);

            return(cody);
        }
 public override void BeforeGPUStroke(PlaytimePainter pntr, BrushConfig br, StrokeVector st, BrushType type)
 {
     if (br.IsA3Dbrush(pntr) && pntr.IsAtlased())
     {
         var ats = GetAtlasedSection();
         Shader.SetGlobalVector(PainterDataAndConfig.BRUSH_ATLAS_SECTION_AND_ROWS, new Vector4(ats.x, ats.y, atlasRows, 1));
     }
 }