예제 #1
0
        private void UpdateTexture()
        {
            if (width > 0)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != width || generatedTexture.height != 1 || generatedTexture.format != format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Near (Generated)", width, 1, format);

                    generatedTexture.wrapMode = TextureWrapMode.Clamp;

                    ApplyTexture();
                }

                var stepU = 1.0f / (width - 1);

                for (var x = 0; x < width; x++)
                {
                    WritePixel(stepU * x, x);
                }

                generatedTexture.Apply();
            }

            ApplyTexture();
        }
예제 #2
0
        public void UpdateTextures()
        {
            if (Width > 0)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != Width || generatedTexture.height != 1 || generatedTexture.format != Format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Depth (Generated)", Width, 1, Format);

                    generatedTexture.wrapMode = TextureWrapMode.Clamp;

                    ApplyTexture();
                }

                var color = Color.clear;
                var stepU = 1.0f / (Width - 1);

                for (var x = 0; x < Width; x++)
                {
                    WritePixel(stepU * x, x);
                }

                generatedTexture.Apply();
            }
        }
예제 #3
0
        private void UpdateTexture()
        {
            if (source != null)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != source.width || generatedTexture.height != 1 || generatedTexture.format != format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("MainTex (Generated)", source.width, 1, format);

                    generatedTexture.wrapMode = TextureWrapMode.Clamp;

                    ApplyTexture();
                }

                for (var x = source.width - 1; x >= 0; x--)
                {
                    WritePixel(x);
                }

                generatedTexture.Apply();
            }

            ApplyTexture();
        }
예제 #4
0
        public void UpdateTexture()
        {
            if (Width > 0 && Height > 0 && NoisePoints > 0)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != Width || generatedTexture.height != Height || generatedTexture.format != Format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Aurora MainTex (Generated)", Width, Height, Format);

                    generatedTexture.wrapMode = TextureWrapMode.Repeat;

                    ApplyTexture();
                }

                SgtHelper.BeginRandomSeed(NoiseSeed);
                {
                    noisePoints.Clear();

                    for (var i = 0; i < NoisePoints; i++)
                    {
                        noisePoints.Add(1.0f - Random.Range(0.0f, NoiseStrength));
                    }
                }
                SgtHelper.EndRandomSeed();

                var stepU = 1.0f / (Width - 1);
                var stepV = 1.0f / (Height - 1);

                for (var y = 0; y < Height; y++)
                {
                    var v = stepV * y;

                    for (var x = 0; x < Width; x++)
                    {
                        WritePixel(stepU * x, v, x, y);
                    }
                }

                generatedTexture.Apply();
            }
        }
예제 #5
0
        private void UpdateTexture()
        {
            if (width > 0 && height > 0 && noisePoints > 0)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != width || generatedTexture.height != height || generatedTexture.format != format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Aurora MainTex (Generated)", width, height, format);

                    generatedTexture.wrapMode = TextureWrapMode.Repeat;
                }

                SgtHelper.BeginRandomSeed(noiseSeed);
                {
                    tempPoints.Clear();

                    for (var i = 0; i < noisePoints; i++)
                    {
                        tempPoints.Add(1.0f - Random.Range(0.0f, noiseStrength));
                    }
                }
                SgtHelper.EndRandomSeed();

                var stepU = 1.0f / (width - 1);
                var stepV = 1.0f / (height - 1);

                for (var y = 0; y < height; y++)
                {
                    var v = stepV * y;

                    for (var x = 0; x < width; x++)
                    {
                        WritePixel(stepU * x, v, x, y);
                    }
                }

                generatedTexture.Apply();
            }

            ApplyTexture();
        }
        private void ValidateTexture(ref Texture2D texture2D, string createName)
        {
            // Destroy if invalid
            if (texture2D != null)
            {
                if (texture2D.width != Width || texture2D.height != 1 || texture2D.format != Format)
                {
                    texture2D = SgtHelper.Destroy(texture2D);
                }
            }

            // Create?
            if (texture2D == null)
            {
                texture2D = SgtHelper.CreateTempTexture2D(createName, Width, 1, Format);

                texture2D.wrapMode = TextureWrapMode.Clamp;

                ApplyTextures();
            }
        }
예제 #7
0
        private void UpdateTexture()
        {
            if (width > 0 && height > 0)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != width || generatedTexture.height != height || generatedTexture.format != format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Scattering (Generated)", width, height, format);

                    generatedTexture.wrapMode = TextureWrapMode.Clamp;
                }

                var stepU = 1.0f / (width - 1);
                var stepV = 1.0f / (height - 1);

                for (var y = 0; y < height; y++)
                {
                    var v = y * stepV;

                    for (var x = 0; x < width; x++)
                    {
                        WritePixel(stepU * x, v, x, y);
                    }
                }

                generatedTexture.Apply();
            }

            ApplyTexture();
        }
        public void UpdateTexture()
        {
            if (Width > 0 && Height > 0)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != Width || generatedTexture.height != Height || generatedTexture.format != Format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Scattering (Generated)", Width, Height, Format);

                    generatedTexture.wrapMode = TextureWrapMode.Clamp;

                    UpdateApply();
                }

                var stepU = 1.0f / (Width - 1);
                var stepV = 1.0f / (Height - 1);

                for (var y = 0; y < Height; y++)
                {
                    var v = y * stepV;

                    for (var x = 0; x < Width; x++)
                    {
                        WritePixel(stepU * x, v, x, y);
                    }
                }

                generatedTexture.Apply();
            }
        }
예제 #9
0
        private bool ValidateTexture(ref Texture2D texture2D, string createName)
        {
            // Destroy if invalid
            if (texture2D != null)
            {
                if (texture2D.width != width || texture2D.height != 1 || texture2D.format != format)
                {
                    texture2D = SgtHelper.Destroy(texture2D);
                }
            }

            // Create?
            if (texture2D == null)
            {
                texture2D = SgtHelper.CreateTempTexture2D(createName, width, 1, format);

                texture2D.wrapMode = TextureWrapMode.Clamp;

                return(true);
            }

            return(false);
        }
        public void UpdateTexture()
        {
            if (Width > 0)
            {
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != Width || generatedTexture.height != 1 || generatedTexture.format != Format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Flare Texture (Generated)", Width, 1, Format);

                    generatedTexture.wrapMode = TextureWrapMode.Clamp;

                    if (generatedMaterial != null)
                    {
                        generatedMaterial.SetTexture(SgtShader._MainTex, generatedTexture);
                    }
                }

                var stepU = 1.0f / (Width - 1);

                for (var x = 0; x < Width; x++)
                {
                    WritePixel(stepU * x, x);
                }

                generatedTexture.Apply();
            }
        }
        public void UpdateTexture()
        {
            if (Source == null)
            {
                Source = CachedShadowRing.Texture as Texture2D;
            }

            if (Source != null)
            {
                var width = Source.width;
#if UNITY_EDITOR
                SgtHelper.MakeTextureReadable(Source);
#endif
                // Destroy if invalid
                if (generatedTexture != null)
                {
                    if (generatedTexture.width != width || generatedTexture.height != 1 || generatedTexture.format != Format)
                    {
                        generatedTexture = SgtHelper.Destroy(generatedTexture);
                    }
                }

                // Create?
                if (generatedTexture == null)
                {
                    generatedTexture = SgtHelper.CreateTempTexture2D("Ring Shadow (Generated)", width, 1, Format);

                    generatedTexture.wrapMode = TextureWrapMode.Clamp;

                    ApplyTexture();
                }

                if (bufferA == null || bufferA.Length != width)
                {
                    bufferA = new Color[width];
                    bufferB = new Color[width];
                }

                for (var x = 0; x < width; x++)
                {
                    bufferA[x] = bufferB[x] = Source.GetPixel(x, 0);
                }

                if (Invert == true)
                {
                    for (var x = 0; x < width; x++)
                    {
                        var a = bufferA[x];

                        bufferA[x] = bufferB[x] = new Color(1.0f - a.r, 1.0f - a.g, 1.0f - a.b, 1.0f - a.a);
                    }
                }

                if (ShareRGB == true)
                {
                    for (var x = 0; x < width; x++)
                    {
                        var a = bufferA[x].a;

                        bufferA[x] = bufferB[x] = new Color(a, a, a, a);
                    }
                }

                for (var i = 0; i < Iterations; i++)
                {
                    SwapBuffers();

                    for (var x = width - 2; x >= 1; x--)
                    {
                        WritePixel(x);
                    }
                }

                for (var x = 0; x < width; x++)
                {
                    generatedTexture.SetPixel(x, 0, bufferB[x]);
                }

                generatedTexture.SetPixel(0, 0, Color.white);
                generatedTexture.SetPixel(width - 1, 0, Color.white);

                generatedTexture.Apply();
            }
        }