Esempio n. 1
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            UnityEngine.Color col1             = SourceModule.GetColour(x, y);
            float             brightnessChange = (float)BrightnessModule.GetValue(x, y);

            // Read hsl:
            float h = col1.r;
            float s = col1.g;
            float l = col1.b;

            HslRgb.ToHsl(ref h, ref s, ref l);

            // Boost brightness:
            l *= 1f + brightnessChange;

            // Back to colour:
            HslRgb.ToRgb(ref h, ref s, ref l);

            // Now RGB:
            col1.r = h;
            col1.g = s;
            col1.b = l;

            return(col1);
        }
Esempio n. 2
0
        public override double GetValue(double t)
        {
            // Get control (0-1):
            double control = ControlModule.GetValue(t);

            int count = Sources.Length - 1;

            if (count == 0)
            {
                return(control);
            }
            else if (count == 1)
            {
                return(Sources[1].GetValue(t));
            }

            // Reduce count (such that it ranges from 0->count-1):
            count--;

            // Map to being relative to the points:
            control *= (double)count;

            int index = (int)control;

            if (index < 0)
            {
                // Sample it:
                return(Sources[1].GetValue(t));
            }
            else if (index >= count)
            {
                // Sample there:
                return(Sources[count + 1].GetValue(t));
            }
            else
            {
                // Make relative:
                control -= (double)index;
            }

            // Control is now 0-1 relative to Points[index].

            // Get current:
            TextureNode current = Sources[index + 1];

            if (control == 0)
            {
                // Just read it:
                return(current.GetValue(t));
            }

            // Note that index is never equal to (actual count-1), therefore next is just:
            TextureNode next = Sources[index + 2];

            // Blend:
            double a = current.GetValue(t);
            double b = next.GetValue(t);

            return(a + ((b - a) * control));
        }
Esempio n. 3
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            UnityEngine.Color col1      = SourceModule.GetColour(x, y);
            float             hueChange = (float)HueModule.GetValue(x, y);
            float             satChange = (float)SatModule.GetValue(x, y);
            float             lumChange = (float)LumModule.GetValue(x, y);

            // Read hsl:
            float h = col1.r;
            float s = col1.g;
            float l = col1.b;

            HslRgb.ToHsl(ref h, ref s, ref l);

            // Boost all 3:
            h  = (h + hueChange) % 1f;
            s *= 1f + satChange;
            l *= 1f + lumChange;

            // Back to colour:
            HslRgb.ToRgb(ref h, ref s, ref l);

            // Now RGB:
            col1.r = h;
            col1.g = s;
            col1.b = l;

            return(col1);
        }
Esempio n. 4
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            UnityEngine.Color col1      = SourceModule.GetColour(x, y);
            float             hueChange = (float)HueModule.GetValue(x, y);

            // Read hsl:
            float h = col1.r;
            float s = col1.g;
            float l = col1.b;

            HslRgb.ToHsl(ref h, ref s, ref l);

            // Cycle the hue:
            h = (h + hueChange) % 1f;

            // Back to colour:
            HslRgb.ToRgb(ref h, ref s, ref l);

            // Now RGB:
            col1.r = h;
            col1.g = s;
            col1.b = l;

            return(col1);
        }
Esempio n. 5
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            UnityEngine.Color col1      = SourceModule.GetColour(x, y);
            float             satChange = (float)SaturationModule.GetValue(x, y);

            // Read hsl:
            float h = col1.r;
            float s = col1.g;
            float l = col1.b;

            HslRgb.ToHsl(ref h, ref s, ref l);

            // Boost sat:
            s *= (1f + satChange);

            // Back to colour:
            HslRgb.ToRgb(ref h, ref s, ref l);

            // Now RGB:
            col1.r = h;
            col1.g = s;
            col1.b = l;

            return(col1);
        }
Esempio n. 6
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read coords:
            double lookX = (XModule == null)?0:XModule.GetValue(x, y);
            double lookY = (YModule == null)?0:YModule.GetValue(x, y);

            // Read colour:
            return(SourceModule.GetColour(lookX, lookY));
        }
Esempio n. 7
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read colour:
            UnityEngine.Color col1 = SourceModule.GetColour(x, y);

            // Read and apply alpha:
            col1.a = (float)AlphaModule.GetValue(x, y);

            return(col1);
        }
Esempio n. 8
0
        public override double GetValue(double x, double y, double z)
        {
            double toNearest = ToNearestModule.GetValue(x, y, z);

            if (toNearest == 0)
            {
                return(0);
            }

            return(toNearest * System.Math.Floor(SourceModule.GetValue(x, y, z) / toNearest));
        }
Esempio n. 9
0
        public override double GetValue(double x, double y, double z)
        {
            double deg = DegreeModule.GetValue(x, y, z);

            if (deg == 0)
            {
                return(0);
            }

            return(System.Math.Pow(SourceModule.GetValue(x, y, z), 1.0 / deg));
        }
Esempio n. 10
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            UnityEngine.Color col1   = SourceModule.GetColour(x, y);
            float             ctrast = 1f + (float)LuminanceModule.GetValue(x, y);

            // Boost:
            col1.r *= ctrast;
            col1.g *= ctrast;
            col1.b *= ctrast;

            return(col1);
        }
Esempio n. 11
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            UnityEngine.Color col1     = SourceModule.GetColour(x, y);
            float             contrast = 1f + (float)ContrastModule.GetValue(x, y);

            // Boost:
            col1.r = ((col1.r - 0.5f) * contrast) + 0.5f;
            col1.g = ((col1.g - 0.5f) * contrast) + 0.5f;
            col1.b = ((col1.b - 0.5f) * contrast) + 0.5f;

            return(col1);
        }
        public override UnityEngine.Color GetColour(double x, double y)
        {
            UnityEngine.Color col1     = SourceModule.GetColour(x, y);
            float             contrast = 1f + (float)Contrast.GetValue(x, y);
            float             origin   = (float)Origin.GetValue(x, y);

            // Boost:
            col1.r = ((col1.r - origin) * contrast) + origin;
            col1.g = ((col1.g - origin) * contrast) + origin;
            col1.b = ((col1.b - origin) * contrast) + origin;

            return(col1);
        }
Esempio n. 13
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read R:
            float r = (float)RedModule.GetValue(x, y);

            // Read G:
            float g = (float)GreenModule.GetValue(x, y);

            // Read B:
            float b = (float)BlueModule.GetValue(x, y);

            return(new Color(r, g, b, 1f));
        }
Esempio n. 14
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Get the bounds:
            double minX   = MinXModule.GetValue(x, y);
            double rangeX = RangeXModule.GetValue(x, y);          // maxX = rangeX-minX
            double minY   = MinYModule.GetValue(x, y);
            double rangeY = RangeYModule.GetValue(x, y);          // maxY = rangeY-minY

            //Wrap and clip both:
            x = ((x - minX) % rangeX) + minX;
            y = ((y - minY) % rangeY) + minY;

            return(SourceModule.GetColour(x, y));
        }
Esempio n. 15
0
        public override double GetValue(double x, double y, double z)
        {
            // Read value:
            double value = SourceModule.GetValue(x, y, z);

            // Read min of range:
            double min = BlackModule.GetValue(x, y, z);

            // Divide by range:
            value /= (WhiteModule.GetValue(x, y, z) - min);

            // Offset:
            return(value + min);
        }
Esempio n. 16
0
        public override void Prepare(DrawInfo info)
        {
            double xAngle = XAngle.GetValue(0, 0);
            double yAngle = YAngle.GetValue(0, 0);
            double zAngle = ZAngle.GetValue(0, 0);

            double xCos, yCos, zCos, xSin, ySin, zSin;

            xCos = System.Math.Cos(xAngle);
            yCos = System.Math.Cos(yAngle);
            zCos = System.Math.Cos(zAngle);
            xSin = System.Math.Sin(xAngle);
            ySin = System.Math.Sin(yAngle);
            zSin = System.Math.Sin(zAngle);

            Matrix = new double[4];

            Matrix[0] = ySin * xSin * zSin + yCos * zCos;
            Matrix[1] = xCos * zSin;
            Matrix[2] = ySin * xSin * zCos - yCos * zSin;
            Matrix[3] = xCos * zCos;

            // Prepare sources:
            base.Prepare(info);
        }
Esempio n. 17
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // 2 points (horizontal line), rotated clockwise by Angle.
            // Length of the line is a constant.
            // Sample those two points, then simply compute the difference.

            // Read angle:
            double angle = AngleModule.GetValue(x, y);
            float  sA    = (float)System.Math.Sin(angle);
            float  cA    = (float)System.Math.Cos(angle);

            // Base points (rotate first)
            float rightX = cA * HalfLine;
            float rightY = sA * HalfLine;

            // Read colour:
            UnityEngine.Color col1 = SourceModule.GetColour(x - rightX, y - rightY);

            // Read colour:
            UnityEngine.Color col2 = SourceModule.GetColour(x + rightX, y + rightY);

            // Difference divided by distance:
            col1.r = (col2.r - col1.r) / LineLength;
            col1.g = (col2.g - col1.g) / LineLength;
            col1.b = (col2.b - col1.b) / LineLength;

            return(col1);
        }
Esempio n. 18
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read H:
            float h = (float)HueModule.GetValue(x, y);

            // Read S:
            float s = (float)SaturationModule.GetValue(x, y);

            // Read L:
            float l = (float)LumModule.GetValue(x, y);

            // Convert to RGB:
            HslRgb.ToRgb(ref h, ref s, ref l);

            // Now RGB.
            return(new Color(h, s, l, 1f));
        }
Esempio n. 19
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read colour:
            UnityEngine.Color col1 = SourceModule.GetColour(x, y);

            // Read gamma:
            double gamma = GammaModule.GetValue(x, y);

            // Map gamma into the 0.1 to 10 range, and invert it:
            gamma = 1.0 / System.Math.Pow(10.0, gamma);

            col1.r = (float)(col1.r * gamma);
            col1.g = (float)(col1.g * gamma);
            col1.b = (float)(col1.b * gamma);

            return(col1);
        }
Esempio n. 20
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read L:
            float l = (float)LightModule.GetValue(x, y);

            // Read A:
            float a = (float)AModule.GetValue(x, y);

            // Read B:
            float b = (float)BModule.GetValue(x, y);

            // Convert to RGB:
            LabRgb.ToRgb(ref l, ref a, ref b);

            // Now RGB.
            return(new Color(l, a, b, 1f));
        }
Esempio n. 21
0
        public override double GetValue(double x, double y, double z)
        {
            double tX = X.GetValue(x, y, z);
            double tY = Y.GetValue(x, y, z);
            double tZ = Z.GetValue(x, y, z);

            return(SourceModule.GetValue(x + tX, y + tY, z + tZ));
        }
Esempio n. 22
0
        public override double GetValue(double x, double y, double z)
        {
            double scaleX = X.GetValue(x, y, z);
            double scaleY = Y.GetValue(x, y, z);
            double scaleZ = Z.GetValue(x, y, z);

            return(SourceModule.GetValue(x * scaleX, y * scaleY, z * scaleZ));
        }
Esempio n. 23
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read H:
            float h = (float)HueModule.GetValue(x, y);

            // Read S:
            float s = (float)SaturationModule.GetValue(x, y);

            // Read V:
            float v = (float)BrightModule.GetValue(x, y);

            // Convert to RGB:
            HsvRgb.ToRgb(ref h, ref s, ref v);

            // Now RGB.
            return(new Color(h, s, v, 1f));
        }
Esempio n. 24
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read colour:
            UnityEngine.Color col1 = SourceModule.GetColour(x, y);

            // Threshold:
            double threshold = ThresholdModule.GetValue(x, y);

            // Smoothing range (+- half this):
            double smooth  = SmoothingRange.GetValue(x, y);
            double hSmooth = smooth * 0.5;

            // Get input colours intensity:
            double intensity = (col1.r + col1.g + col1.b) / 3.0;

            // High:
            UnityEngine.Color high;

            // Low:
            UnityEngine.Color low;

            // How does it compare to the minimum?
            double min = threshold - hSmooth;

            // Note: Equals here avoids a division by 0 when computing blending factor.
            if (intensity <= min)
            {
                low   = LowModule.GetColour(x, y);
                low.a = col1.a;
                return(low);
            }

            // And the max?
            if (intensity >= threshold + hSmooth)
            {
                high   = HighModule.GetColour(x, y);
                high.a = col1.a;
                return(high);
            }

            // Smooth. Blend between high and low.
            high = HighModule.GetColour(x, y);
            low  = LowModule.GetColour(x, y);

            // Blending factor is.. (NB: won't div by 0)
            float blend = (float)((intensity - min) / smooth);

            col1.r = low.r + (high.r - low.r) * blend;
            col1.g = low.g + (high.g - low.g) * blend;
            col1.b = low.b + (high.b - low.b) * blend;

            return(col1);
        }
Esempio n. 25
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Read colour:
            UnityEngine.Color col1 = SourceModule.GetColour(x, y);

            float lower = (float)LowerBound.GetValue(x, y);
            float upper = (float)UpperBound.GetValue(x, y);

            // Clamp! Ignore alpha though - it comes from col1:
            if (col1.r < lower)
            {
                col1.r = lower;
            }
            else if (col1.r > upper)
            {
                col1.r = upper;
            }

            if (col1.g < lower)
            {
                col1.g = lower;
            }
            else if (col1.g > upper)
            {
                col1.g = upper;
            }

            if (col1.b < lower)
            {
                col1.b = lower;
            }
            else if (col1.b > upper)
            {
                col1.b = upper;
            }

            return(col1);
        }
Esempio n. 26
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Get the angle to rotate by (rad):
            double deltaAngle = RotationModule.GetValue(x, y);

            // rotate the point x/y deltaAngle about 0.5/0.5
            x -= 0.5;
            y -= 0.5;

            // Get sin/cos:
            double cAngle = System.Math.Cos(deltaAngle);
            double sAngle = System.Math.Sin(deltaAngle);

            double tx = x * cAngle - y * sAngle;

            y = y * cAngle + x * sAngle;
            x = tx;

            x += 0.5;
            y += 0.5;

            return(SourceModule.GetColour(x, y));
        }
Esempio n. 27
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            float weight = (float)IntensityModule.GetValue(x, y);

            UnityEngine.Color col1 = SourceModule.GetColour(x, y);

            // Compute full sepia version:
            float sepiaR = (col1.r * .393f) + (col1.g * .769f) + (col1.b * .189f);
            float sepiaG = (col1.r * .349f) + (col1.g * .686f) + (col1.b * .168f);
            float sepiaB = (col1.r * .272f) + (col1.g * .534f) + (col1.b * .131f);

            // Blended:
            return(new Color(
                       col1.r + (sepiaR - col1.r) * weight,
                       col1.g + (sepiaG - col1.g) * weight,
                       col1.b + (sepiaB - col1.b) * weight,
                       col1.a
                       ));
        }
        public override UnityEngine.Color GetColour(double x, double y)
        {
            float threshold  = (float)Threshold.GetValue(x, y);
            float nThreshold = -threshold;
            float a          = 4f * (float)Gain.GetValue(x, y);

            a += 1f;

            // Read the two colours:
            UnityEngine.Color pix2 = SourceModule1.GetColour(x, y);
            UnityEngine.Color pix1 = SourceModule2.GetColour(x, y);


            // Get deltas:
            float rDelta = pix1.r - pix2.r;
            float gDelta = pix1.g - pix2.g;
            float bDelta = pix1.b - pix2.b;

            // Threshold test:
            if (rDelta <= nThreshold || rDelta >= threshold)
            {
                pix1.r = (a * rDelta + pix2.r);
            }

            if (gDelta <= nThreshold || gDelta >= threshold)
            {
                pix1.g = (a * gDelta + pix2.g);
            }

            if (bDelta <= nThreshold || bDelta >= threshold)
            {
                pix1.b = (a * bDelta + pix2.b);
            }

            return(pix1);
        }
Esempio n. 29
0
        public override double GetValue(double x, double y)
        {
            // Radius:
            double radius = RadiusModule.GetValue(x, y);

            // Get width (and height):
            double size = WidthModule.GetValue(x, y);

            // Blur factor:
            double blur = BlurModule.GetValue(x, y);

            // Get delta from origin:
            double dx = x - 0.5;
            double dy = y - 0.5;

            double angle = 0.0;

            if (EdgeFunction != null)
            {
                // Compute the angle in 0-1 range:
                angle  = System.Math.Atan2(dy, dx) / (System.Math.PI * 2.0);
                angle += 0.5;
            }

            // Offset dx and dy:
            if (size > 0)
            {
                if (dx < 0)
                {
                    dx = -dx;
                }

                dx -= size;

                if (dx < 0)
                {
                    dx = 0;
                }

                if (dy < 0)
                {
                    dy = -dy;
                }

                dy -= size;

                if (dy < 0)
                {
                    dy = 0;
                }
            }

            // Compute distance:
            double distance = System.Math.Sqrt(dx * dx + dy * dy);

            if (EdgeFunction != null)
            {
                // Chord adjustment:
                // - Imagine a right angle triangle segment fitted perfectly into the circle.
                //   The right angle is sitting at the center of the circle, and one of its edges
                //   forms a chord of the circle.
                //   The chord adjustment is where we compute the distance to the chord
                //   and update the radius value. This results in n-polygon edges in the output.

                // Read the graph at the angle in the 0-1 range and apply to radius:
                radius *= 1.0 - EdgeFunction.GetValue(angle);
            }

            if (distance > radius)
            {
                // Beyond the outside of the shape.
                return(0.0);
            }

            // Inside the shape. Inside the blur?
            distance -= (radius - blur);

            if (distance < 0.0)
            {
                return(1.0);
            }

            // Interpolate:
            return(1.0 - distance / blur);
        }
Esempio n. 30
0
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // Get control (0-1):
            double control = ControlModule.GetValue(x, y);

            int count = Sources.Length - 1;

            if (count == 0)
            {
                return(new UnityEngine.Color(0, 0, 0, 1));
            }
            else if (count == 1)
            {
                return(Sources[1].GetColour(x, y));
            }

            // Reduce count (such that it ranges from 0->count-1):
            count--;

            // Map to being relative to the points:
            control *= (double)count;

            int index = (int)control;

            if (index < 0)
            {
                // Sample it:
                return(Sources[1].GetColour(x, y));
            }
            else if (index >= count)
            {
                // Sample there:
                return(Sources[count + 1].GetColour(x, y));
            }
            else
            {
                // Make relative:
                control -= (double)index;
            }

            // Get current:
            TextureNode current = Sources[index + 1];

            if (control == 0)
            {
                // Just read it:
                return(current.GetColour(x, y));
            }

            // Control is now 0-1 relative to Sources[index+1]. Get as float:
            float blend = (float)control;

            // Note that index is never equal to (actual count-1), therefore next is just:
            TextureNode next = Sources[index + 2];

            // Blend:
            UnityEngine.Color col1 = current.GetColour(x, y);
            UnityEngine.Color col2 = next.GetColour(x, y);

            col1.r += (col1.r - col2.r) * blend;
            col1.g += (col1.g - col2.g) * blend;
            col1.b += (col1.b - col2.b) * blend;
            col1.a += (col1.a - col2.a) * blend;

            return(col1);
        }