Esempio n. 1
0
        public void FlipChanel(ColorChanel chan)
        {
            float val = _color.GetChanel(chan);

            val = (val > 0.9f) ? 0 : 1;
            chan.SetChanel(ref _color, val);
        }
Esempio n. 2
0
 void SetSourceMaskToCopyAChannel(ColorChanel sourceChannel)
 => PainterShaderVariables.ChannelCopySourceMask.GlobalValue = new Vector4(
     sourceChannel == ColorChanel.R ? 1 : 0,
     sourceChannel == ColorChanel.G ? 1 : 0,
     sourceChannel == ColorChanel.B ? 1 : 0,
     sourceChannel == ColorChanel.A ? 1 : 0
     );
Esempio n. 3
0
 void SetSourceMaskToCopyAChannel(ColorChanel sourceChannel)
 => ChannelCopySourceMask.GlobalValue = new Vector4(
     sourceChannel == ColorChanel.R ? 1 : 0,
     sourceChannel == ColorChanel.G ? 1 : 0,
     sourceChannel == ColorChanel.B ? 1 : 0,
     sourceChannel == ColorChanel.A ? 1 : 0
     );
Esempio n. 4
0
        public ColorChanel GetZeroChanel_AifNotOne()
        {
            int count = 0;

            ColorChanel ch = GetZeroChanelIfOne(ref count);

            if (count == 2)
            {
                return(ch);
            }
            else
            {
                foreach (Vertex u in meshPoint.uvpoints)
                {
                    if (u != this)
                    {
                        ch = GetZeroChanelIfOne(ref count);
                        if (count == 2)
                        {
                            return(ch);
                        }
                    }
                }
            }


            return(ColorChanel.A);
        }
Esempio n. 5
0
        public bool FlipChanelOnLine(ColorChanel chan, MeshPoint other)
        {
            float val = 1;

            if (Cfg.MakeVericesUniqueOnEdgeColoring)
            {
                EditedMesh.GiveLineUniqueVerticles_RefreshTrisListing(new LineData(this, other));
            }

            foreach (Vertex u in uvpoints)
            {
                if (u.ConnectedTo(other))
                {
                    val *= u._color.GetChanel(chan) * u.GetConnectedUVinVert(other)._color.GetChanel(chan);
                }
            }

            val = (val > 0.9f) ? 0 : 1;

            SetChanel(chan, other, val);
            other.SetChanel(chan, this, val);



            EditedMesh.Dirty = true;


            return(val == 1);
        }
Esempio n. 6
0
        public bool FlipChanelOnLine(ColorChanel chan, MeshPoint other)
        {
            float val = 1;

            if (Cfg.makeVerticesUniqueOnEdgeColoring)
            {
                EditedMesh.GiveLineUniqueVerticesRefreshTriangleListing(new LineData(this, other));
            }

            foreach (var u in vertices)
            {
                if (u.ConnectedTo(other))
                {
                    val *= chan.GetValueFrom(u.color) * chan.GetValueFrom(u.GetConnectedUVinVertex(other).color);
                }
            }

            val = (val > 0.9f) ? 0 : 1;

            SetChanel(chan, other, val);
            other.SetChanel(chan, this, val);

            EditedMesh.Dirty = true;

            return(val == 1);
        }
Esempio n. 7
0
        public void FlipChanel(ColorChanel chan)
        {
            var val = chan.GetValueFrom(color);

            val = (val > 0.9f) ? 0 : 1;
            chan.SetValueOn(ref color, val);
        }
Esempio n. 8
0
 public void SetColor_OppositeTo(ColorChanel chan)
 {
     for (var i = 0; i < 3; i++)
     {
         var c = (ColorChanel)i;
         c.SetValueOn(ref color, c == chan ? 0 : 1);
     }
 }
Esempio n. 9
0
 public void SetColor_OppositeTo(ColorChanel chan)
 {
     for (int i = 0; i < 3; i++)
     {
         ColorChanel c = (ColorChanel)i;
         c.SetChanel(ref _color, c == chan ? 0 : 1);
     }
 }
Esempio n. 10
0
 private void SetChanel(ColorChanel chan, MeshPoint other, float val)
 {
     foreach (var u in vertices)
     {
         if (u.ConnectedTo(other))
         {
             chan.SetValueOn(ref u.color, val);
         }
     }
 }
Esempio n. 11
0
 void SetChanel(ColorChanel chan, MeshPoint other, float val)
 {
     foreach (Vertex u in uvpoints)
     {
         if (u.ConnectedTo(other))
         {
             chan.SetChanel(ref u._color, val);
         }
     }
 }
Esempio n. 12
0
        public bool ChannelSlider(ColorChanel chan, ref Color col)
        {
            chan.GetIcon().write();
            float val = chan.GetValueFrom(col);

            if (pegi.edit(ref val, 0, 1).nl())
            {
                chan.SetValueOn(ref col, val);
                return(true);
            }

            return(false);
        }
Esempio n. 13
0
        public Shader GetShaderToWriteInto(ColorChanel chan)
        {
            switch (chan)
            {
            case ColorChanel.R: return(bufferCopyR);

            case ColorChanel.G: return(bufferCopyG);

            case ColorChanel.B: return(bufferCopyB);

            case ColorChanel.A: return(bufferCopyA);
            }

            return(null);
        }
Esempio n. 14
0
        public static string ToText(this ColorChanel icon)
        {
            switch (icon)
            {
            case ColorChanel.R: return("Red");

            case ColorChanel.G: return("Green");

            case ColorChanel.B: return("Blue");

            case ColorChanel.A: return("Alpha");

            default: return("Unknown channel");
            }
        }
Esempio n. 15
0
        public static float GetValueFrom(this ColorChanel chan, Color col)
        {
            switch (chan)
            {
            case ColorChanel.R:
                return(col.r);

            case ColorChanel.G:
                return(col.g);

            case ColorChanel.B:
                return(col.b);

            default:
                return(col.a);
            }
        }
Esempio n. 16
0
        public void AutoSetVertColors()
        {
            //  foreach (vertexpointDta v in vertices)
            //    v.setColor(Color.black);

            bool[] asCol = new bool[3];
            bool[] asUV  = new bool[3];

            foreach (Triangle td in triangles)
            {
                asCol[0] = asCol[1] = asCol[2] = false;
                asUV[0]  = asUV[1] = asUV[2] = false;

                for (int i = 0; i < 3; i++)
                {
                    ColorChanel c = td.vertexes[i].GetZeroChanel_AifNotOne();
                    if ((c != ColorChanel.A) && (!asCol[(int)c]))
                    {
                        asCol[(int)c] = true;
                        asUV[i]       = true;
                        td.vertexes[i].SetColor_OppositeTo(c);
                        //  Debug.Log("Setting requested " + c);
                    }
                }

                for (int i = 0; i < 3; i++)
                {
                    if (!asUV[i])
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            if (!asCol[j])
                            {
                                asCol[(int)j] = true;
                                asUV[i]       = true;
                                td.vertexes[i].SetColor_OppositeTo((ColorChanel)j);
                                // Debug.Log("Setting leftover " + (ColorChanel)j);
                                break;
                            }
                        }
                    }
                }
            }
            // Debug.Log("Dirty");
            Dirty = true;
        }
Esempio n. 17
0
        public float GetChanel(ColorChanel chan)
        {
            switch (chan)
            {
            case ColorChanel.R:
                return(r);

            case ColorChanel.G:
                return(g);

            case ColorChanel.B:
                return(b);

            default:
                return(a);
            }
        }
Esempio n. 18
0
        ColorChanel GetZeroChanelIfOne(ref int count)
        {
            count = 0;
            ColorChanel ch = ColorChanel.A;

            for (int i = 0; i < 3; i++)
            {
                if (_color.GetChanel((ColorChanel)i) > 0.9f)
                {
                    count++;
                }
                else
                {
                    ch = (ColorChanel)i;
                }
            }

            return(ch);
        }
Esempio n. 19
0
        public static void SetValueOn(this ColorChanel chan, ref Color col, float value)
        {
            switch (chan)
            {
            case ColorChanel.R:
                col.r = value;
                break;

            case ColorChanel.G:
                col.g = value;
                break;

            case ColorChanel.B:
                col.b = value;
                break;

            case ColorChanel.A:
                col.a = value;
                break;
            }
        }
Esempio n. 20
0
        public void RemoveBorderFromLine(MeshPoint other)
        {
            foreach (Vertex u in uvpoints)
            {
                if (u.ConnectedTo(other))
                {
                    for (int i = 0; i < 4; i++)
                    {
                        Vertex      ouv = u.GetConnectedUVinVert(other);
                        ColorChanel ch  = (ColorChanel)i;

                        float val = u._color.GetChanel(ch) * ouv._color.GetChanel(ch);

                        if (val > 0.9f)
                        {
                            ch.SetChanel(ref u._color, 0);
                            ch.SetChanel(ref ouv._color, 0);
                        }
                    }
                }
            }
        }
Esempio n. 21
0
        public void SetChanelFrom01(ColorChanel chan, float value)
        {
            value *= value;
            switch (chan)
            {
            case ColorChanel.R:
                r = value;
                break;

            case ColorChanel.G:
                g = value;
                break;

            case ColorChanel.B:
                b = value;
                break;

            case ColorChanel.A:
                a = value;
                break;
            }
        }
Esempio n. 22
0
 public float GetChanel01(ColorChanel chan)
 {
     return(Mathf.Abs(Mathf.Sqrt(GetChanel(chan))));
 }
Esempio n. 23
0
 public static Texture getIcon(this ColorChanel icon)
 {
     return(colorIcon((int)icon));
 }
Esempio n. 24
0
 public RenderTexture RenderDepth(Texture from, RenderTexture to, ColorChanel intoChannel)
 => Render(from, to, ColorChanel.R, intoChannel);
Esempio n. 25
0
 public static Texture GetIcon(this ColorChanel icon) => ColorIcon((int)icon);
Esempio n. 26
0
 public RenderTexture Render(Texture from, RenderTexture to, ColorChanel sourceChannel, ColorChanel intoChannel)
 {
     SetSourceMaskToCopyAChannel(sourceChannel);
     Render(from, to, Data.GetShaderToWriteInto(intoChannel));
     return(to);
 }