Пример #1
0
                protected override ProTeGe_Texture GetBandNoise(int i, int resolution)
                {
                    int noiseSize = (int)(resolution / Mathf.Pow(2, i));

                    ProTeGe_Texture noise = white.Generate(noiseSize);

                    noise.size = noiseSize;

                    if (noise.size >= 4)
                    {
                        ProTeGe_Texture scaledNoise = new ProTeGe_Texture(noise.size / 2);
                        scaledNoise.CopyFrom(noise, true);
                        scaledNoise.upscaleMode = ProTeGe_Texture.UpscaleModes.Bicubic;
                        scaledNoise.size       *= 2;

                        matDiff.SetTexture("_Tex2", scaledNoise.renderTexture);
                        noise.ApplyMaterial(matDiff);

                        scaledNoise.Release();
                    }

                    noise.upscaleMode = ProTeGe_Texture.UpscaleModes.Bicubic;
                    noise.size        = Globals.instance.textureSize_preview;

                    return(noise);
                }
Пример #2
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    perlin ["Fractal"] = this ["Fractal"];
                    perlin ["Big"]     = this ["Big"];
                    perlin ["Small"]   = this ["Small"];

                    ProTeGe_Texture noiseTex = perlin.Generate(resolution);

                    float qualityCoef = Mathf.Lerp(0.001f, 0.07f, this ["Quality"]);
                    float strength    = this ["Strength"];

                    strength = strength * 1024 * 16;
                    float step = 1.0f / Globals.instance.textureSize_preview;

                    m.SetFloat("_step", step / qualityCoef);
                    m.SetFloat("_iterations", strength * qualityCoef + 1);
                    m.SetInt("_Mode", 0);

                    curl.SetFloat("_step", step);
                    noiseTex.ApplyMaterial(curl);

                    m.SetTexture("_curlNoiseTex", noiseTex.renderTexture);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);

                    noiseTex.Release();

                    return(t.renderTexture);
                }
Пример #3
0
            protected override RenderTexture GenerateRenderTexture(int resolution)
            {
                ProTeGe_Texture t = inputs [0].Generate(resolution);

                t.ApplyMaterial(m);
                return(t.renderTexture);
            }
Пример #4
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture NormalTexture = inputs [0].Generate(resolution);

                    normal.SetInt("_Size", Globals.instance.textureSize_preview);
                    normal.SetFloat("_Noise", 0);
                    normal.SetFloat("_Intensity", Mathf.Lerp(0.01f, 1f, this ["Intensity"]) * 0.01f);

                    NormalTexture.ApplyMaterial(normal);

                    float sampleSize = this ["Range"] * this ["Quality"] / 16.0f + 8.0f;
                    float step       = 1.0f / resolution;
                    float angleStep  = Mathf.PI * 2 / sampleSize;

                    m.SetTexture("_NormalTexture", NormalTexture.renderTexture);
                    m.SetFloat("_Range", this ["Range"]);
                    m.SetFloat("_Intensity", Mathf.Lerp(0.01f, 1f, this ["Intensity"]) * 0.01f);
                    m.SetInt("_Quality", (int)sampleSize);
                    m.SetFloat("_angleStep", angleStep);
                    m.SetFloat("_step", step);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);


                    NormalTexture.Release();

                    return(t.renderTexture);
                }
Пример #5
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetInt("_selectiveSampling", this ["Selective Sampling"] == 1 ? 1 : 0);

                    float qualityCoef = Mathf.Lerp(1.0f / 16, 1, this ["Quality"]);

                    float range = this ["Range"] * qualityCoef * resolution / 1024;

                    range = range * 12.5f;                     //for visual consistency with same range bokeh with 4 + 0 sides
                    float radius = range * 3 * Mathf.Lerp(1, 0.625f, this["Undersampling"]);
                    float step   = 1.0f / Globals.instance.textureSize_preview / qualityCoef;

                    ProTeGe_Texture rangeCoefTex = inputs [1].Generate(resolution);

                    m.SetFloat("_Iterations", radius);
                    m.SetFloat("_Range", range);
                    m.SetFloat("_Ox", step);
                    m.SetFloat("_Oy", 0);
                    m.SetTexture("_RangeCoefTex", rangeCoefTex.renderTexture);
                    m.SetFloat("_RangeVariance", this["Range variance"]);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);

                    m.SetFloat("_Ox", 0);
                    m.SetFloat("_Oy", step);

                    t.ApplyMaterial(m);

                    rangeCoefTex.Release();
                    return(t.renderTexture);
                }
Пример #6
0
            public System.Tuple <ProTeGe_Texture, long> Generate_with_cacheID(int resolution)
            {
                ProTeGe_Texture t      = Generate(resolution);;
                var             result = new System.Tuple <ProTeGe_Texture, long> (t, currentCacheID);

                return(result);
            }
Пример #7
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture tex2;

                    tex2 = inputs [1].Generate(resolution);
                    m.SetTexture("_RangeCoefTex", tex2.renderTexture);

                    m.SetInt("_selectiveSampling", this ["Selective Sampling"] == 1 ? 1 : 0);

                    m.SetFloat("_RangeVariance", this ["Range variance"]);
                    float qualityCoef = Mathf.Lerp(0.3f, 1, this ["Quality"]);
                    float step        = 1.0f / Globals.instance.textureSize_preview;

                    float radius = 16 * this["Range"] + 1;

                    radius = radius * resolution / 1024;

                    m.SetFloat("_Iterations", radius * qualityCoef);
                    qualityCoef = Mathf.Ceil(radius * qualityCoef) / radius;
                    m.SetFloat("_Ox", (Mathf.Cos(this["Angle"]) * step) / qualityCoef);
                    m.SetFloat("_Oy", (Mathf.Sin(this["Angle"]) * step) / qualityCoef);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);
                    tex2.Release();
                    return(t.renderTexture);
                }
Пример #8
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetFloat("_RandomSeed", this ["Seed"]);
                    ProTeGe_Texture t = new ProTeGe_Texture(resolution);

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #9
0
            protected override RenderTexture GenerateRenderTexture(int resolution)
            {
                m.SetFloat("_" + name, this[name]);

                ProTeGe_Texture t = inputs [0].Generate(resolution);

                t.ApplyMaterial(m);

                return(t.renderTexture);
            }
Пример #10
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetFloat("_Low", this ["Low"]);
                    m.SetFloat("_Mid", this ["Mid"]);
                    m.SetFloat("_High", this ["High"]);
                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #11
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    matCellular.SetInt("_Invert", this ["Invert"] == 0 ? 0 : 1);
                    matCellular.SetInt("_Mode", Mathf.RoundToInt(this ["Mode"]));

                    ProTeGe_Texture seedTexture = inputs [0].Generate(resolution);

                    seedTexture.ApplyMaterial(matCellular);
                    return(seedTexture.renderTexture);
                }
Пример #12
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture t    = inputs [0].Generate(resolution);
                    float           step = 1.0f / Globals.instance.textureSize_preview;

                    diffuse.SetFloat("_step", step);
                    diffuse.SetFloat("_Range", this["Range"] + 1);
                    t.ApplyMaterial(diffuse);

                    return(t.renderTexture);
                }
Пример #13
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    float step = 1.0f / Globals.instance.textureSize_preview;

                    m.SetFloat("_step", step);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #14
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetInt("_Size", Globals.instance.textureSize_preview);
                    m.SetFloat("_Intensity", 0.01f * this["Intensity"]);
                    m.SetFloat("_Noise", this ["Noise"]);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);

                    return(t.renderTexture);
                }
Пример #15
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetFloat("_Noise", this ["Noise"]);
                    m.SetFloat("_Frequency", this ["Frequency"]);
                    m.SetFloat("_Thickness", this ["Thickness"]);
                    m.SetFloat("_Flatness", this ["Flatness"]);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #16
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetFloat("_Thickness", 1.0f - this ["Thickness"]);
                    m.SetFloat("_Flatness", this ["Flatness"]);
                    //m.SetFloat ("_Length", this ["Length"]);
                    m.SetFloat("_Length", (int)this ["Length"] * 2 + 4.0f);
                    m.SetFloat("_Size", (int)this ["Size"] + 1.0f);
                    ProTeGe_Texture t = new ProTeGe_Texture(resolution);

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #17
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetFloat("_Frequency_H", 1.0f - this ["Width"]);
                    m.SetFloat("_Frequency_V", 1.0f - this ["Height"]);
                    m.SetFloat("_Size", this ["Size"]);
                    m.SetFloat("_Flatness", this ["Flatness"]);

                    ProTeGe_Texture t = new ProTeGe_Texture();

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #18
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    m.SetInt("_Resolution", (int)this["Resolution"]);
                    m.SetInt("_Modulus", this["Cracks"] == 0 ? 0 : 1);
                    m.SetFloat("_RandomSeed", this ["Seed"]);

                    this["Generate"] = this["Generate"] * 0;
                    ProTeGe_Texture t = new ProTeGe_Texture();

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #19
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture tex2;

                    tex2 = inputs [1].Generate(resolution);
                    matMax.SetInt("_Luminance", this ["Luminance"] == 0 ? 0 : 1);
                    matMax.SetTexture("_Tex2", tex2.renderTexture);
                    ProTeGe_Texture t = inputs [0].Generate(resolution).ApplyMaterial(matMax);

                    tex2.Release();
                    return(t.renderTexture);
                }
Пример #20
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    int numCells = (int)(Mathf.Pow(2, this ["Density"])) + 1;

                    m.SetFloat("_Density", numCells);
                    m.SetFloat("_Randomness", 1.0f - this ["Order"]);
                    m.SetFloat("_Seed", this["Seed"] / 100);
                    m.SetInt("_DistanceMode", Mathf.RoundToInt(this ["Distance mode"]));

                    ProTeGe_Texture t = new ProTeGe_Texture();

                    t.ApplyMaterial(m);
                    return(t.renderTexture);
                }
Пример #21
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture t = inputs[0].Generate(resolution);

                    UpdateNoise(resolution);

                    m.SetTexture("_NoiseTex", noise.renderTexture);
                    m.SetInt("_Grayscale", this ["Grayscale"] > 0 ? 1 : 0);
                    m.SetFloat("_Strength", this ["Strength"]);

                    t.ApplyMaterial(m);

                    return(t.renderTexture);
                }
Пример #22
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture hor, ver;

                    hor = inputs [1].Generate(resolution);
                    ver = inputs [2].Generate(resolution);
                    matPush.SetFloat("_Horizontal", this ["Horizontal"]);
                    matPush.SetFloat("_Vertical", this ["Vertical"]);
                    matPush.SetTexture("_Tex2", hor.renderTexture);
                    matPush.SetTexture("_Tex3", ver.renderTexture);
                    ProTeGe_Texture t = inputs [0].Generate(resolution).ApplyMaterial(matPush);

                    hor.Release();
                    ver.Release();
                    return(t.renderTexture);
                }
Пример #23
0
            protected override RenderTexture GenerateRenderTexture(int resolution)
            {
                ProTeGe_Texture t  = inputs [0].Generate(resolution);
                ProTeGe_Texture t2 = inputs [1].Generate(resolution);
                ProTeGe_Texture t3 = inputs [2].Generate(resolution);

                m.SetFloat("_Opacity", this["Opacity"]);
                m.SetTexture("_Tex2", t2.renderTexture);
                m.SetTexture("_TexCoef", t3.renderTexture);

                t.ApplyMaterial(m);

                t2.Release();
                t3.Release();
                return(t.renderTexture);
            }
Пример #24
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    AO ["Range"]     = this ["Range"];
                    AO ["Quality"]   = this ["Quality"];
                    AO ["Intensity"] = this ["Intensity"];

                    AO.inputs [0].connectedProcessor = this.inputs[0].connectedProcessor;

                    blur ["Range"]         = this ["Range Blur"];
                    blur ["Quality"]       = this ["Quality Blur"];
                    blur ["Undersampling"] = this ["Undersampling Blur"];

                    blur.inputs [0].connectedProcessor = AO;

                    ProTeGe_Texture t2 = blur.Generate(resolution);

                    return(t2.renderTexture);
                }
Пример #25
0
                protected sealed override RenderTexture GenerateRenderTexture(int resolution)
                {
                    UpdateBandValues();

                    ProTeGe_Texture t = new ProTeGe_Texture(resolution);

                    t.ApplyMaterial(matValue);

                    if (Globals.instance.lowMemoryMode == false)
                    {
                        CreateBandNoises(resolution);

                        for (int i = 0; i < bandValues.Length; i++)
                        {
                            if (bandValues [i] != 0)
                            {
                                matGather.SetFloat("_Opacity", bandValues [i]);
                                matGather.SetTexture("_Tex2", bandNoises [i].renderTexture);
                                t.ApplyMaterial(matGather);
                            }
                        }
                    }
                    else
                    {
                        ReleaseBands();

                        for (int i = 1; i < bandValues.Length; i++)
                        {
                            if (bandValues [i] != 0)
                            {
                                ProTeGe_Texture temp = GetBandNoise(i, resolution);

                                matGather.SetFloat("_Opacity", bandValues [i]);
                                matGather.SetTexture("_Tex2", temp.renderTexture);
                                t.ApplyMaterial(matGather);

                                temp.Release();
                            }
                        }
                    }

                    return(t.renderTexture);
                }
Пример #26
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    int numCells = (int)(Mathf.Pow(2, this ["Density"])) + 1;

                    seeder.SetFloat("_Density", numCells);
                    seeder.SetInt("_DistanceMode", 1);
                    seeder.SetFloat("_Randomness", 1.0f);
                    seeder.SetFloat("_Seed", this["Seed"] / 100);

                    ProTeGe_Texture seed = new ProTeGe_Texture();

                    seed.ApplyMaterial(seeder);

                    generator.SetInt("_Invert", 1);
                    generator.SetFloat("_Seed", this["Seed"] / 100);
                    generator.SetInt("_Mode", 0);

                    seed.ApplyMaterial(generator);

                    return(seed.renderTexture);
                }
Пример #27
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture tex2;

                    tex2 = inputs [1].Generate(resolution);
                    m.SetTexture("_RangeCoefTex", tex2.renderTexture);

                    m.SetInt("_selectiveSampling", this ["Selective Sampling"] == 1 ? 1 : 0);

                    float qualityCoef = Mathf.Lerp(0.3f, 1, this ["Quality"]);

                    float radius = 16 * this["Range"] + 1;

                    m.SetFloat("_Iterations", radius * qualityCoef);

                    m.SetFloat("_RangeVariance", this ["Range variance"]);

                    qualityCoef = Mathf.Ceil(radius * qualityCoef) / radius;

                    float step = 1.0f / Globals.instance.textureSize_preview / qualityCoef;

                    float tmp   = (int)(this ["Sides"]);
                    int   sides = 4 + (int)tmp * 2;

                    float angle = ((sides - 2) * Mathf.PI / sides);

                    ProTeGe_Texture t = inputs [0].Generate(resolution);
                    int             i;

                    for (i = 0; i < sides / 2; i++)
                    {
                        m.SetFloat("_Ox", (Mathf.Cos(angle * i) * step));
                        m.SetFloat("_Oy", (Mathf.Sin(angle * i) * step));
                        t.ApplyMaterial(m);
                    }

                    tex2.Release();

                    return(t.renderTexture);
                }
Пример #28
0
                protected override RenderTexture GenerateRenderTexture(int resolution)
                {
                    ProTeGe_Texture t    = inputs [0].Generate(resolution);
                    float           step = 1.0f / Globals.instance.textureSize_preview;

                    bloomH.SetFloat("_step", step);
                    bloomV.SetFloat("_step", step);
                    bloomH.SetFloat("_Range", this["Range"] + 1);
                    bloomV.SetFloat("_Range", this["Range"] + 1);
                    bloomH.SetFloat("_Threshold", this ["Threshold"]);

                    t.ApplyMaterial(bloomH);

                    t.ApplyMaterial(bloomV);

                    ProTeGe_Texture tmp = inputs [0].Generate(resolution);

                    if (Mathf.RoundToInt(this ["Mode"]) == 0)
                    {
                        matAdd.SetFloat("_Opacity", this ["Strength"]);

                        matAdd.SetTexture("_Tex2", t.renderTexture);

                        tmp.ApplyMaterial(matAdd);
                    }
                    else
                    {
                        matScreen.SetFloat("_Opacity", this["Strength"]);

                        matScreen.SetTexture("_Tex2", t.renderTexture);

                        tmp.ApplyMaterial(matScreen);
                    }

                    t.Release();
                    return(tmp.renderTexture);
                }
Пример #29
0
                private void UpdateNoise(int resolution)
                {
                    if (noise != null)
                    {
                        if (noise.size != Globals.instance.textureSize_preview)
                        {
                            noise.Release();
                            noise = null;
                        }
                    }
                    if (noise == null)
                    {
                        p ["Resolution"] = Globals.instance.textureSize_preview / 2;

                        ProTeGe_Texture r, g, b;

                        p ["Seed"] = 1;
                        r          = p.Generate(resolution);

                        p ["Seed"] = 1.2f;
                        g          = p.Generate(resolution);

                        p ["Seed"] = 1.7f;
                        b          = p.Generate(resolution);

                        mGather.SetTexture("_TexR", r.renderTexture);
                        mGather.SetTexture("_TexG", g.renderTexture);
                        mGather.SetTexture("_TexB", b.renderTexture);

                        noise = new ProTeGe_Texture();
                        noise.ApplyMaterial(mGather);

                        r.Release();
                        g.Release();
                        b.Release();
                    }
                }