UnityStandardAssets.ImageEffects.NoiseAndGrain.DrawNoiseQuadGrid(UnityEngine.RenderTexture, UnityEngine.RenderTexture, UnityEngine.Material, UnityEngine.Texture2D, UnityEngine.Mesh, int)

Here are the examples of the csharp api UnityStandardAssets.ImageEffects.NoiseAndGrain.DrawNoiseQuadGrid(UnityEngine.RenderTexture, UnityEngine.RenderTexture, UnityEngine.Material, UnityEngine.Texture2D, UnityEngine.Mesh, int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : NoiseAndGrain.cs
License : Apache License 2.0
Project Creator : 365082218

void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (CheckResources() == false || (null == noiseTexture))
            {
                Graphics.Blit(source, destination);
                if (null == noiseTexture)
                {
                    Debug.LogWarning("Noise & Grain effect failing as noise texture is not replacedigned. please replacedign.", transform);
                }
                return;
            }

            softness = Mathf.Clamp(softness, 0.0f, 0.99f);

            if (dx11Grain && supportDX11)
            {
                // We have a fancy, procedural noise pattern in this version, so no texture needed

                dx11NoiseMaterial.SetFloat("_DX11NoiseTime", Time.frameCount);
                dx11NoiseMaterial.SetTexture("_NoiseTex", noiseTexture);
                dx11NoiseMaterial.SetVector("_NoisePerChannel", monochrome ? Vector3.one : intensities);
                dx11NoiseMaterial.SetVector("_MidGrey", new Vector3(midGrey, 1.0f / (1.0f - midGrey), -1.0f / midGrey));
                dx11NoiseMaterial.SetVector("_NoiseAmount", new Vector3(generalIntensity, blackIntensity, whiteIntensity) * intensityMultiplier);

                if (softness > Mathf.Epsilon)
                {
                    RenderTexture rt = RenderTexture.GetTemporary((int)(source.width * (1.0f - softness)), (int)(source.height * (1.0f - softness)));
                    DrawNoiseQuadGrid(source, rt, dx11NoiseMaterial, noiseTexture, mesh, monochrome ? 3 : 2);
                    dx11NoiseMaterial.SetTexture("_NoiseTex", rt);
                    Graphics.Blit(source, destination, dx11NoiseMaterial, 4);
                    RenderTexture.ReleaseTemporary(rt);
                }
                else
                    DrawNoiseQuadGrid(source, destination, dx11NoiseMaterial, noiseTexture, mesh, (monochrome ? 1 : 0));
            }
            else
            {
                // normal noise (DX9 style)

                if (noiseTexture)
                {
                    noiseTexture.wrapMode = TextureWrapMode.Repeat;
                    noiseTexture.filterMode = filterMode;
                }

                noiseMaterial.SetTexture("_NoiseTex", noiseTexture);
                noiseMaterial.SetVector("_NoisePerChannel", monochrome ? Vector3.one : intensities);
                noiseMaterial.SetVector("_NoiseTilingPerChannel", monochrome ? Vector3.one * monochromeTiling : tiling);
                noiseMaterial.SetVector("_MidGrey", new Vector3(midGrey, 1.0f / (1.0f - midGrey), -1.0f / midGrey));
                noiseMaterial.SetVector("_NoiseAmount", new Vector3(generalIntensity, blackIntensity, whiteIntensity) * intensityMultiplier);

                if (softness > Mathf.Epsilon)
                {
                    RenderTexture rt2 = RenderTexture.GetTemporary((int)(source.width * (1.0f - softness)), (int)(source.height * (1.0f - softness)));
                    DrawNoiseQuadGrid(source, rt2, noiseMaterial, noiseTexture, mesh, 2);
                    noiseMaterial.SetTexture("_NoiseTex", rt2);
                    Graphics.Blit(source, destination, noiseMaterial, 1);
                    RenderTexture.ReleaseTemporary(rt2);
                }
                else
                    DrawNoiseQuadGrid(source, destination, noiseMaterial, noiseTexture, mesh, 0);
            }
        }