Ejemplo n.º 1
0
    private void WriteTexture(float u, int x)
    {
        var fade  = 1.0f - SgtEase.Evaluate(Ease, 1.0f - Mathf.Pow(u, Power));
        var color = new Color(fade, fade, fade, fade);

        generatedTexture.SetPixel(x, 0, color);
    }
Ejemplo n.º 2
0
    private void WriteTexture(float u, float v, int x, int y)
    {
        var noise      = u * NoisePoints;
        var noiseIndex = (int)noise;
        var noiseFrac  = noise % 1.0f;
        var noiseA     = noisePoints[(noiseIndex + 0) % NoisePoints];
        var noiseB     = noisePoints[(noiseIndex + 1) % NoisePoints];
        var noiseC     = noisePoints[(noiseIndex + 2) % NoisePoints];
        var noiseD     = noisePoints[(noiseIndex + 3) % NoisePoints];
        var color      = MiddleColor;

        if (v < MiddlePoint)
        {
            color.a = SgtEase.Evaluate(BottomEase, SgtHelper.Pow(Mathf.InverseLerp(0.0f, MiddlePoint, v), BottomPower));
        }
        else
        {
            color.a = SgtEase.Evaluate(TopEase, SgtHelper.Pow(Mathf.InverseLerp(1.0f, MiddlePoint, v), TopPower));
        }

        var middle = SgtEase.Evaluate(MiddleEase, SgtHelper.Pow(1.0f - v, MiddlePower));

        color.a *= SgtHelper.HermiteInterpolate(noiseA, noiseB, noiseC, noiseD, noiseFrac);

        color.r *= middle * color.a;
        color.g *= middle * color.a;
        color.b *= middle * color.a;
        color.a *= 1.0f - middle;

        generatedTexture.SetPixel(x, y, color);
    }
Ejemplo n.º 3
0
    public override float GetDensity(Vector3 worldPoint)
    {
        var localPoint = transform.InverseTransformPoint(worldPoint);
        var distance   = Mathf.InverseLerp(Radius, 0.0f, localPoint.magnitude);

        return(SgtHelper.Pow(SgtEase.Evaluate(Ease, distance), Power));
    }
Ejemplo n.º 4
0
    private void WriteTexture(float u, int x)
    {
        var e = SgtEase.Evaluate(Ease, Mathf.Pow(u, Power));

        var color = new Color(1.0f, 1.0f, 1.0f, e);

        generatedTexture.SetPixel(x, 0, color);
    }
Ejemplo n.º 5
0
    private void WriteTexture(float u, int x)
    {
        var rim   = SgtEase.Evaluate(RimEase, Mathf.Pow(1.0f - u, RimPower));
        var color = Color.Lerp(Color.white, RimColor, rim * RimColor.a);

        color.a = 1.0f - Mathf.Pow(1.0f - Mathf.Pow(u, AlphaFade), AlphaDensity);

        generatedTexture.SetPixel(x, 0, color);
    }
Ejemplo n.º 6
0
    public override float GetDensity(Vector3 worldPoint)
    {
        var localPoint = transform.InverseTransformPoint(worldPoint);
        var distanceX  = Mathf.InverseLerp(Extents.x, 0.0f, Mathf.Abs(localPoint.x));
        var distanceY  = Mathf.InverseLerp(Extents.y, 0.0f, Mathf.Abs(localPoint.y));
        var distanceZ  = Mathf.InverseLerp(Extents.z, 0.0f, Mathf.Abs(localPoint.z));
        var distance   = Mathf.Min(distanceX, Mathf.Min(distanceY, distanceZ));

        return(SgtHelper.Pow(SgtEase.Evaluate(Ease, distance), Power));
    }
Ejemplo n.º 7
0
    private void WriteTexture(float u, int x)
    {
        var color = Color;

        color.r *= 1.0f - SgtEase.Evaluate(Ease, 1.0f - Mathf.Pow(1.0f - u, PowerR));
        color.g *= 1.0f - SgtEase.Evaluate(Ease, 1.0f - Mathf.Pow(1.0f - u, PowerG));
        color.b *= 1.0f - SgtEase.Evaluate(Ease, 1.0f - Mathf.Pow(1.0f - u, PowerB));
        color.a  = color.grayscale;

        generatedTexture.SetPixel(x, 0, color);
    }
Ejemplo n.º 8
0
    private void WriteTexture(Texture2D texture2D, float u, int x, Color baseColor, SgtEase.Type ease, float colorPower, float alphaPower)
    {
        var colorU = SgtHelper.Pow(u, colorPower); colorU = SgtEase.Evaluate(ease, colorU);
        var alphaU = SgtHelper.Pow(u, alphaPower); alphaU = SgtEase.Evaluate(ease, alphaU);

        var color = Color.Lerp(baseColor, HorizonColor, colorU);

        color.a = alphaU;

        texture2D.SetPixel(x, 0, color);
    }
Ejemplo n.º 9
0
    private void WriteTexture(float u, int x)
    {
        var sunsetU = Mathf.InverseLerp(SunsetEnd, SunsetStart, u);
        var color   = default(Color);

        color.r = SgtEase.Evaluate(SunsetEase, 1.0f - Mathf.Pow(sunsetU, SunsetPowerR));
        color.g = SgtEase.Evaluate(SunsetEase, 1.0f - Mathf.Pow(sunsetU, SunsetPowerG));
        color.b = SgtEase.Evaluate(SunsetEase, 1.0f - Mathf.Pow(sunsetU, SunsetPowerB));
        color.a = 0.0f;

        generatedTexture.SetPixel(x, 0, color);
    }
Ejemplo n.º 10
0
    private void WriteTexture(float u, float v, int x, int y)
    {
        var ray        = Mathf.Abs(v * 2.0f - 1.0f); ray = Rayleigh * ray * ray;
        var mie        = Mathf.Pow(v, Mie);
        var scattering = ray + mie * (1.0f - ray);
        var sunsetU    = Mathf.InverseLerp(SunsetEnd, SunsetStart, u);
        var color      = default(Color);

        color.r = 1.0f - SgtEase.Evaluate(SunsetEase, Mathf.Pow(sunsetU, SunsetPowerR));
        color.g = 1.0f - SgtEase.Evaluate(SunsetEase, Mathf.Pow(sunsetU, SunsetPowerG));
        color.b = 1.0f - SgtEase.Evaluate(SunsetEase, Mathf.Pow(sunsetU, SunsetPowerB));
        color.a = (color.r + color.g + color.b) / 3.0f;

        generatedTexture.SetPixel(x, y, color * scattering);
    }
Ejemplo n.º 11
0
    // Calculates the 0..1 depth between the eye and target
    public float Calculate(Vector3 eye, Vector3 target)
    {
        if (busy == true)
        {
            Debug.LogError("Calculate is being called recursively");

            return(0.0f);
        }

        var coverage = default(float);

        busy = true;
        {
            coverage = DoCalculate(eye, target);
        }
        busy = false;

        return(1.0f - SgtEase.Evaluate(Ease, 1.0f - coverage));
    }