Exemplo n.º 1
0
        public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            if (renderingData.cameraData.camera.cameraType == CameraType.Preview || renderingData.cameraData.camera.cameraType == CameraType.SceneView || renderingData.cameraData.camera.cameraType == CameraType.Reflection)
            {
                return;
            }

            myCam = renderingData.cameraData.camera;

            if (EnviroSkyMgr.instance != null && EnviroSkyMgr.instance.HasInstance() && EnviroSkyMgr.instance.useSunShafts)
            {
                if (renderingData.cameraData.isSceneViewCamera)
                {
                    return;
                }


                var src  = renderer.cameraColorTarget;
                var dest = UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget;

                if (blitPass == null)
                {
                    Create();
                }

                CreateMaterialsAndTextures();
                blitPass.Setup(myCam, src, dest, EnviroSkyMgr.instance.Components.Sun.transform, EnviroSkyMgr.instance.LightShaftsSettings.thresholdColorSun.Evaluate(EnviroSkyMgr.instance.Time.solarTime), EnviroSkyMgr.instance.LightShaftsSettings.lightShaftsColorSun.Evaluate(EnviroSkyMgr.instance.Time.solarTime));
                renderer.EnqueuePass(blitPass);
            }
        }
        public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            if (renderingData.cameraData.camera.cameraType == CameraType.Preview || renderingData.cameraData.camera.cameraType == CameraType.Reflection)
            {
                return;
            }

            myCam = renderingData.cameraData.camera;

            if (EnviroSkyMgr.instance != null && EnviroSky.instance != null && EnviroSkyMgr.instance.useDistanceBlur)
            {
                if (renderingData.cameraData.isSceneViewCamera && !EnviroSky.instance.showDistanceBlurInEditor)
                {
                    return;
                }

                var src  = renderer.cameraColorTarget;
                var dest = UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget;

                if (blitPass == null)
                {
                    blitPass = new EnviroDistanceBlurPass(UnityEngine.Rendering.Universal.RenderPassEvent.BeforeRenderingTransparents, postProcessMat, distributionTexture);
                }

                blitPass.Setup(myCam, src, dest);
                renderer.EnqueuePass(blitPass);
            }
        }
Exemplo n.º 3
0
        public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            if (renderingData.cameraData.camera.cameraType == CameraType.Preview)
            {
                return;
            }

            myCam = renderingData.cameraData.camera;

            if (EnviroSky.instance != null && EnviroSky.instance.useFog && EnviroSky.instance.PlayerCamera != null)
            {
                var src  = renderer.cameraColorTarget;
                var dest = UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget;

                if (renderingData.cameraData.isSceneViewCamera && !EnviroSky.instance.showFogInEditor)
                {
                    return;
                }

                UpdateMatrix();

                RenderFog();

                if (blitPass == null)
                {
                    Create();
                }

                blitPass.Setup(src, dest);

                renderer.EnqueuePass(blitPass);
            }
        }
 public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
 {
     if (m_Settings.material != null)
     {
         renderer.EnqueuePass(m_RenderQuadPass);
     }
 }
Exemplo n.º 5
0
 public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
 {
     // Enqueues the render pass for execution. Here you can inject one or more render passes in the renderer
     // AddRenderPasses is called everyframe.
     if (m_Settings.material != null)
     {
         renderer.EnqueuePass(m_RenderQuadPass);
     }
 }
Exemplo n.º 6
0
        public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            var src  = renderer.cameraColorTarget;
            var dest = (settings.destination == Target.Color) ? UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget : m_RenderTextureHandle;

            if (settings.blitMaterial == null)
            {
                Debug.LogWarningFormat("Missing Blit Material. {0} blit pass will not execute. Check for missing reference in the assigned renderer.", GetType().Name);
                return;
            }

            blitPass.Setup(src, dest);
            renderer.EnqueuePass(blitPass);
        }
Exemplo n.º 7
0
        public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            if (renderingData.cameraData.camera.cameraType == CameraType.Preview)
            {
                return;
            }

            myCam = renderingData.cameraData.camera;

            if (EnviroSkyLite.instance != null && EnviroSkyLite.instance.usePostEffectFog)
            {
                var src  = renderer.cameraColorTarget;
                var dest = UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget;

                if (!renderingData.cameraData.isSceneViewCamera && renderingData.cameraData.camera == EnviroSkyLite.instance.PlayerCamera)
                {
                    UpdateMatrix();

                    if (currentSimpleFog != EnviroSkyLite.instance.fogSettings.useSimpleFog)
                    {
                        CreateFogMaterial();
                        blitPass         = new EnviroBlitPass(UnityEngine.Rendering.Universal.RenderPassEvent.BeforeRenderingTransparents, material, 0, name);
                        currentSimpleFog = EnviroSkyLite.instance.fogSettings.useSimpleFog;
                    }

                    RenderFog();

                    if (blitPass == null)
                    {
                        Create();
                    }

                    blitPass.Setup(src, dest);

                    renderer.EnqueuePass(blitPass);
                }
            }
        }
Exemplo n.º 8
0
        public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            if (EnviroSkyMgr.instance != null && EnviroSky.instance != null && EnviroSkyMgr.instance.useVolumeClouds && EnviroSky.instance.PlayerCamera != null)
            {
                if (renderingData.cameraData.camera.cameraType == CameraType.Preview)
                {
                    return;
                }

                myCam = renderingData.cameraData.camera;

                var src  = renderer.cameraColorTarget;
                var dest = UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget;

                if (currentReprojectionPixelSize != EnviroSky.instance.cloudsSettings.cloudsQualitySettings.reprojectionPixelSize)
                {
                    currentReprojectionPixelSize = EnviroSky.instance.cloudsSettings.cloudsQualitySettings.reprojectionPixelSize;
                    SetReprojectionPixelSize(EnviroSky.instance.cloudsSettings.cloudsQualitySettings.reprojectionPixelSize);
                }

                if (renderingData.cameraData.isSceneViewCamera && !EnviroSky.instance.showVolumeCloudsInEditor)
                {
                    return;
                }

                RenderVolumeClouds(renderingData.cameraData.cameraTargetDescriptor);

                if (blitPass == null)
                {
                    Create();
                }

                blitPass.Setup(src, dest);

                renderer.EnqueuePass(blitPass);
            }
        }
Exemplo n.º 9
0
        public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            if (renderingData.cameraData.camera.cameraType == CameraType.Preview || renderingData.cameraData.camera.cameraType == CameraType.SceneView || renderingData.cameraData.camera.cameraType == CameraType.Reflection)
            {
                return;
            }

            if (EnviroSkyMgr.instance != null && EnviroSkyMgr.instance.useMoonShafts && EnviroSkyMgr.instance.Camera != null)
            {
                var src  = renderer.cameraColorTarget;
                var dest = UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget;

                if (myCam == null)
                {
                    myCam = EnviroSkyMgr.instance.Camera;
                }

                RenderTextureDescriptor descriptor = renderingData.cameraData.cameraTargetDescriptor;
                descriptor.graphicsFormat = Experimental.Rendering.GraphicsFormat.R32G32B32A32_SFloat;
                RenderTexture newSource = RenderTexture.GetTemporary(descriptor);

                RenderTargetIdentifier newSourceID = new RenderTargetIdentifier(newSource);

                if (getSouceTexture == null || blitPassFinal == null)
                {
                    Create();
                }

                getSouceTexture.Setup(src, newSourceID);
                renderer.EnqueuePass(getSouceTexture);

                RenderLightShaft(renderer, newSource, src, dest, sunShaftsMaterial, simpleSunClearMaterial, EnviroSkyMgr.instance.Components.Moon.transform, EnviroSkyMgr.instance.LightShaftsSettings.thresholdColorMoon.Evaluate(EnviroSkyMgr.instance.Time.solarTime), EnviroSkyMgr.instance.LightShaftsSettings.lightShaftsColorMoon.Evaluate(EnviroSkyMgr.instance.Time.solarTime));

                RenderTexture.ReleaseTemporary(newSource);
            }
        }
Exemplo n.º 10
0
 public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
 {
     renderer.EnqueuePass(m_WaterFXPass);
 }
Exemplo n.º 11
0
        void RenderLightShaft(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, RenderTexture source, RenderTargetIdentifier src, UnityEngine.Rendering.Universal.RenderTargetHandle destination, Material mat, Material clearMat, Transform lightSource, Color treshold, Color clr)
        {
            int divider = 4;

            if (EnviroSkyMgr.instance.LightShaftsSettings.resolution == EnviroPostProcessing.SunShaftsResolution.Normal)
            {
                divider = 2;
            }
            else if (EnviroSkyMgr.instance.LightShaftsSettings.resolution == EnviroPostProcessing.SunShaftsResolution.High)
            {
                divider = 1;
            }

            Vector3 v = Vector3.one * 0.5f;

            if (lightSource)
            {
                v = myCam.WorldToViewportPoint(lightSource.position);
            }
            else
            {
                v = new Vector3(0.5f, 0.5f, 0.0f);
            }

            int rtW = source.width / divider;
            int rtH = source.height / divider;

            RenderTextureDescriptor textureDescriptor = source.descriptor;

            textureDescriptor.width  = rtW;
            textureDescriptor.height = rtH;

            RenderTexture lrColorB;
            RenderTexture lrDepthBuffer;

            // VR Usage
            lrDepthBuffer = RenderTexture.GetTemporary(textureDescriptor);

            // mask out everything except the skybox
            // we have 2 methods, one of which requires depth buffer support, the other one is just comparing images

            mat.SetVector("_BlurRadius4", new Vector4(1.0f, 1.0f, 0.0f, 0.0f) * EnviroSkyMgr.instance.LightShaftsSettings.blurRadius);
            mat.SetVector("_SunPosition", new Vector4(v.x, v.y, v.z, EnviroSkyMgr.instance.LightShaftsSettings.maxRadius));
            mat.SetVector("_SunThreshold", treshold);

            Graphics.Blit(source, lrDepthBuffer, mat, 2);

            // paint a small black small border to get rid of clamping problems
            if (myCam.stereoActiveEye == Camera.MonoOrStereoscopicEye.Mono)
            {
                DrawBorder(lrDepthBuffer, clearMat);
            }

            // radial blur:

            radialBlurIterations = Mathf.Clamp(radialBlurIterations, 1, 4);

            float ofs = EnviroSkyMgr.instance.LightShaftsSettings.blurRadius * (1.0f / 768.0f);

            mat.SetVector("_BlurRadius4", new Vector4(ofs, ofs, 0.0f, 0.0f));
            mat.SetVector("_SunPosition", new Vector4(v.x, v.y, v.z, EnviroSkyMgr.instance.LightShaftsSettings.maxRadius));

            for (int it2 = 0; it2 < radialBlurIterations; it2++)
            {
                // each iteration takes 2 * 6 samples
                // we update _BlurRadius each time to cheaply get a very smooth look

                // VR USAGE
                lrColorB = RenderTexture.GetTemporary(textureDescriptor);


                Graphics.Blit(lrDepthBuffer, lrColorB, mat, 1);
                RenderTexture.ReleaseTemporary(lrDepthBuffer);
                ofs = EnviroSkyMgr.instance.LightShaftsSettings.blurRadius * (((it2 * 2.0f + 1.0f) * 6.0f)) / 768.0f;
                mat.SetVector("_BlurRadius4", new Vector4(ofs, ofs, 0.0f, 0.0f));
                // VR USAGE
                lrDepthBuffer = RenderTexture.GetTemporary(textureDescriptor);


                Graphics.Blit(lrColorB, lrDepthBuffer, mat, 1);
                RenderTexture.ReleaseTemporary(lrColorB);
                ofs = EnviroSkyMgr.instance.LightShaftsSettings.blurRadius * (((it2 * 2.0f + 2.0f) * 6.0f)) / 768.0f;
                mat.SetVector("_BlurRadius4", new Vector4(ofs, ofs, 0.0f, 0.0f));
            }

            // put together:

            if (v.z >= 0.0f)
            {
                mat.SetVector("_SunColor", new Vector4(clr.r, clr.g, clr.b, clr.a) * EnviroSkyMgr.instance.LightShaftsSettings.intensity);
            }
            else
            {
                mat.SetVector("_SunColor", Vector4.zero); // no backprojection !
            }
            mat.SetTexture("_ColorBuffer", lrDepthBuffer);

            //FINAL
            // Graphics.Blit(source, destination, mat, (EnviroSkyMgr.instance.LightShaftsSettings.screenBlendMode == EnviroPostProcessing.ShaftsScreenBlendMode.Screen) ? 0 : 4);

            blitPassFinal.Setup(src, destination);
            renderer.EnqueuePass(blitPassFinal);

            RenderTexture.ReleaseTemporary(lrDepthBuffer);
        }
Exemplo n.º 12
0
 public override void AddRenderPasses(UnityEngine.Rendering.Universal.ScriptableRenderer renderer, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
 {
     renderer.EnqueuePass(m_GrassDisplacementPass);
 }