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); }
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); }
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); }
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); }
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(); } }
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); }
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); }
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); }