示例#1
0
        private void DownSample4x(RenderTexture source, RenderTexture dest)
        {
            float off = 1.0f;

            BlurMaterial.SetFloat("_OffsetScale", off);
            Graphics.Blit(source, dest, BlurMaterial);
        }
示例#2
0
        private void FourTapCone(RenderTexture source, RenderTexture dest, int iteration)
        {
            float off = BlurMinSpread + iteration * BlurSpread;

            BlurMaterial.SetFloat("_OffsetScale", off);
            Graphics.Blit(source, dest, BlurMaterial);
        }
示例#3
0
        private void PerformBlur(RenderTexture src, RenderTexture dest)
        {
            float off = BlurSpread;

            BlurMaterial.SetTexture("_MainTex", src);
            BlurMaterial.SetFloat("_Shift", off);
            Graphics.Blit(src, dest, BlurMaterial);
        }
示例#4
0
        private void PerformBlur(RenderTexture src, RenderTexture dest, int iteration)
        {
            float offset = iteration * BlurSpread;

            offset *= gaussFilter[iteration];

            BlurMaterial.SetTexture("_MainTex", src);
            BlurMaterial.SetFloat("_Shift", offset);
            Graphics.Blit(src, dest, BlurMaterial);
        }
示例#5
0
    void RenderShadowMap()
    {
        //ideally, a cheaper version should be rendered here.
        //So lets render a version with no lighting stuff
        Profiler.BeginSample(Fog.name + " shadows");
        Fog.FogVolumeShader.maximumLOD = 100;

        SetQuality(textureSize);


        GetRT(ref RT_Opacity, (int)textureSize, "Opacity");

        ThisCamera.targetTexture = RT_Opacity;

        // print(Fog.ShadowCameraSkippedFrames);



        ThisCamera.Render();
        Fog.RT_Opacity = RT_Opacity;

        // Shader.SetGlobalTexture("RT_Opacity", RT_Opacity);


        if (RT_Opacity != null)
        {
            GetRT(ref RT_PostProcess, (int)textureSize, "Shadow PostProcess");
            PostProcessMaterial.SetFloat("ShadowColor", Fog.ShadowColor.a);
            // PostProcessMaterial.SetFloat("_jitter", Fog._jitter);
            Graphics.Blit(RT_Opacity, RT_PostProcess, PostProcessMaterial);
            // ThisCamera.targetTexture = null;
            Graphics.Blit(RT_PostProcess, RT_Opacity);
            //RenderTexture.ReleaseTemporary(RT_Opacity);
            if (iterations > 0)
            {
                Blur(RT_Opacity, (int)textureSize >> Downsampling);
            }
            else
            {
                Shader.SetGlobalTexture("RT_OpacityBlur", RT_Opacity);
                Fog.RT_OpacityBlur = RT_Opacity;
            }
            Fog.RT_Opacity = RT_Opacity;
        }
        //Shader.SetGlobalTexture("RT_Opacity", RT_Opacity);
        BlurMaterial.SetFloat("ShadowColor", Fog.ShadowColor.a);

        // back to normal
        Fog.FogVolumeShader.maximumLOD = 600;

        Profiler.EndSample();
    }
示例#6
0
    void RenderShadowMap()
    {
        SetQuality(textureSize);

        GetRT(ref RT_Opacity, (int)textureSize, "Opacity");

        if (RT_Opacity != null)
        {
            ThisCamera.targetTexture = RT_Opacity;
        }

        //ideally, a cheaper version should be rendered here.
        //So lets render a version with no lighting stuff
        //Jitter is also BAD here, so lets turn it off
        Fog.FogVolumeShader.maximumLOD = 100;
        //this is throwing an error when deactivating
        if (RT_Opacity)
        {
            ThisCamera.Render();
        }
        //back to normal
        Fog.FogVolumeShader.maximumLOD = 600;

        GetRT(ref RT_PostProcess, (int)textureSize, "Shadow PostProcess");
        PostProcessMaterial.SetFloat("ShadowColor", Fog.ShadowColor.a);
        // PostProcessMaterial.SetFloat("_jitter", Fog._jitter);
        if (RT_Opacity != null)
        {
            Graphics.Blit(RT_Opacity, RT_PostProcess, PostProcessMaterial);
            ThisCamera.targetTexture = null;
            Graphics.Blit(RT_PostProcess, RT_Opacity);

            if (iterations > 0)
            {
                Blur(RT_Opacity, (int)textureSize >> Downsampling);
            }
            else
            {
                Shader.SetGlobalTexture("RT_OpacityBlur", RT_Opacity);
                Fog.RT_OpacityBlur = RT_Opacity;
                Fog.RT_Opacity     = RT_Opacity;
            }
        }
        //Shader.SetGlobalTexture("RT_Opacity", RT_Opacity);
        BlurMaterial.SetFloat("ShadowColor", Fog.ShadowColor.a);
    }
示例#7
0
        private void Start()
        {
            //不支持后期特效
            if (!SystemInfo.supportsImageEffects)
            {
                Log.Warning("HighlightingSystem : Image effects is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持渲染纹理格式
            if (!SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGB32))
            {
                Log.Warning("HighlightingSystem : RenderTextureFormat.ARGB32 is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting Stencil着色器
            if (!Shader.Find("Hidden/Highlighted/StencilOpaque").isSupported)
            {
                Log.Warning("HighlightingSystem : HighlightingStencilOpaque shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting StencilTransparent着色器
            if (!Shader.Find("Hidden/Highlighted/StencilTransparent").isSupported)
            {
                Log.Warning("HighlightingSystem : HighlightingStencilTransparent shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting StencilZ着色器
            if (!Shader.Find("Hidden/Highlighted/StencilOpaqueZ").isSupported)
            {
                Log.Warning("HighlightingSystem : HighlightingStencilOpaqueZ shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持Highlighting StencilTransparentZ着色器
            if (!Shader.Find("Hidden/Highlighted/StencilTransparentZ").isSupported)
            {
                Log.Warning("HighlightingSystem : HighlightingStencilTransparentZ shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持HighlightingBlur着色器
            if (!BlurShader.isSupported)
            {
                Log.Warning("HighlightingSystem : HighlightingBlur shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            //不支持HighlightingComposite着色器
            if (!CompositeShader.isSupported)
            {
                Log.Warning("HighlightingSystem : HighlightingComposite shader is not supported on this platform! Disabling.");
                enabled = false;
                return;
            }

            BlurMaterial.SetFloat("_Intensity", BlurIntensity);
        }
示例#8
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        #region Density convolution
        UniformFogCamera.cullingMask = 1 << FogVolumeScreen.instance.FogVolumeLayer;
        Shader.SetGlobalFloat("FOV_compensation", initFOV / SceneCamera.fieldOfView);
        BlurMaterial.SetFloat("_Falloff", _Falloff);
        BlurMaterial.SetFloat("_Dither", _Dither);
        ConvolveFogVolume();
        screenX = source.width;
        screenY = source.height;
        RenderTexture RT_DensityBlur = RenderTexture.GetTemporary(screenX, screenY, 0, source.format);

        Graphics.Blit(source, RT_DensityBlur);

        for (int i = 0; i < iterations; i++)
        {
            RenderTexture RT_DensityBlur2 = RenderTexture.GetTemporary(screenX, screenY, 0, source.format);
            FourTapCone(RT_DensityBlur, RT_DensityBlur2, i);
            RenderTexture.ReleaseTemporary(RT_DensityBlur);
            RT_DensityBlur = RT_DensityBlur2;
        }
        //  Graphics.Blit(RT_DensityBlur, destination);

        #endregion

        #region Bloom

        float widthMod = 2.0f / (float)_BloomDowsample;
        fastBloomMaterial.SetFloat("_Saturation", _Saturation);
        fastBloomMaterial.SetVector("_Parameter", new Vector4(blurSize * widthMod, 0.0f, threshold, intensity));
        var rtW = source.width / _BloomDowsample;
        var rtH = source.height / _BloomDowsample;

        // downsample
        RenderTexture rt = RenderTexture.GetTemporary(rtW, rtH, 0, source.format);
        rt.filterMode = FilterMode.Bilinear;

        if (!SceneBloom)
        {
            Graphics.Blit(RT_FogVolumeConvolution, rt, fastBloomMaterial, 1);
        }
        else
        {
            Graphics.Blit(RT_DensityBlur, rt, fastBloomMaterial, 1);
        }

        var passOffs = blurType == BlurType.Standard ? 0 : 2;

        for (int i = 1; i < blurIterations; i++)
        {
            fastBloomMaterial.SetVector("_Parameter", new Vector4(blurSize * widthMod + (i * 1.0f), 0.0f, threshold, intensity));

            // vertical blur
            RenderTexture rt2 = RenderTexture.GetTemporary(rtW / i, rtH / i, 0, source.format);
            rt2.filterMode = FilterMode.Bilinear;
            Graphics.Blit(rt, rt2, fastBloomMaterial, 2 + passOffs);
            RenderTexture.ReleaseTemporary(rt);
            rt = rt2;

            // horizontal blur
            rt2            = RenderTexture.GetTemporary(rtW / i, rtH / i, 0, source.format);
            rt2.filterMode = FilterMode.Bilinear;
            Graphics.Blit(rt, rt2, fastBloomMaterial, 3 + passOffs);
            RenderTexture.ReleaseTemporary(rt);
            rt = rt2;
        }

        fastBloomMaterial.SetTexture("_Bloom", rt);

        Graphics.Blit(RT_DensityBlur, destination, fastBloomMaterial, 0);
        RenderTexture.ReleaseTemporary(RT_DensityBlur);
        RenderTexture.ReleaseTemporary(rt);
        #endregion
    }