public PostProcessPass(RenderPassEvent evt, bool renderOpaques = false)
        {
            m_IsOpaquePostProcessing = renderOpaques;
            m_TemporaryColorTexture.Init("_TemporaryColorTexture");

            renderPassEvent = evt;
        }
        public ScreenSpaceShadowComputePass(RenderPassEvent evt, ComputeShader computeShader)
        {
            VxShadowMapConstantBuffer._ShadowData = Shader.PropertyToID("_MainLightShadowData");

            VxShadowMapConstantBuffer._InvViewProjMatrix = Shader.PropertyToID("_InvViewProjMatrix");
            VxShadowMapConstantBuffer._ScreenSize        = Shader.PropertyToID("_ScreenSize");
            VxShadowMapConstantBuffer._BeginOffset       = Shader.PropertyToID("_BeginOffset");
            VxShadowMapConstantBuffer._VoxelZBias        = Shader.PropertyToID("_VoxelZBias");
            VxShadowMapConstantBuffer._VoxelUpBias       = Shader.PropertyToID("_VoxelUpBias");

            VxShadowMapConstantBuffer._VxShadowMapsBuffer      = Shader.PropertyToID("_VxShadowMapsBuffer");
            VxShadowMapConstantBuffer._CameraDepthTexture      = Shader.PropertyToID("_CameraDepthTexture");
            VxShadowMapConstantBuffer._ScreenSpaceShadowOutput = Shader.PropertyToID("_ScreenSpaceShadowOutput");

            bool R8_UNorm = SystemInfo.IsFormatSupported(GraphicsFormat.R8_UNorm, FormatUsage.LoadStore);
            bool R8_SNorm = SystemInfo.IsFormatSupported(GraphicsFormat.R8_SNorm, FormatUsage.LoadStore);
            bool R8_UInt  = SystemInfo.IsFormatSupported(GraphicsFormat.R8_UInt, FormatUsage.LoadStore);
            bool R8_SInt  = SystemInfo.IsFormatSupported(GraphicsFormat.R8_SInt, FormatUsage.LoadStore);

            bool R8 = R8_UNorm || R8_SNorm || R8_UInt || R8_SInt;

            m_ColorFormat = R8 ? RenderTextureFormat.R8 : RenderTextureFormat.RFloat;
            m_ScreenSpaceShadowsComputeShader = computeShader;
            m_ScreenSpaceShadowmapTexture.Init("_ScreenSpaceShadowmapTexture");
            renderPassEvent = evt;
        }
Example #3
0
        /// <summary>
        /// Create the CopyColorPass
        /// </summary>
        public BloomPass(RenderPassEvent renderPassEvent, string tag)
        {
            this.renderPassEvent = renderPassEvent;
            m_ProfilerTag        = tag;
            m_TemporaryColorTexture.Init("_TemporaryColorTexture");

            Init();
        }
Example #4
0
        public override void Create()
        {
            var passIndex = settings.blitMaterial != null ? settings.blitMaterial.passCount - 1 : 1;

            settings.blitMaterialPassIndex = Mathf.Clamp(settings.blitMaterialPassIndex, -1, passIndex);
            blitPass = new BlitPass(settings.Event, settings.blitMaterial, settings.blitMaterialPassIndex, name);
            m_RenderTextureHandle.Init(settings.textureId);
        }
        public AdditionalLightsShadowCasterPass(RenderPassEvent evt)
        {
            renderPassEvent = evt;

            int maxLights = LightweightRenderPipeline.maxVisibleAdditionalLights;

            m_AdditionalLightShadowMatrices  = new Matrix4x4[maxLights];
            m_AdditionalLightSlices          = new ShadowSliceData[maxLights];
            m_AdditionalLightsShadowStrength = new float[maxLights];

            AdditionalShadowsConstantBuffer._AdditionalLightsWorldToShadow = Shader.PropertyToID("_AdditionalLightsWorldToShadow");
            AdditionalShadowsConstantBuffer._AdditionalShadowStrength      = Shader.PropertyToID("_AdditionalShadowStrength");
            AdditionalShadowsConstantBuffer._AdditionalShadowOffset0       = Shader.PropertyToID("_AdditionalShadowOffset0");
            AdditionalShadowsConstantBuffer._AdditionalShadowOffset1       = Shader.PropertyToID("_AdditionalShadowOffset1");
            AdditionalShadowsConstantBuffer._AdditionalShadowOffset2       = Shader.PropertyToID("_AdditionalShadowOffset2");
            AdditionalShadowsConstantBuffer._AdditionalShadowOffset3       = Shader.PropertyToID("_AdditionalShadowOffset3");
            AdditionalShadowsConstantBuffer._AdditionalShadowmapSize       = Shader.PropertyToID("_AdditionalShadowmapSize");
            m_AdditionalLightsShadowmap.Init("_AdditionalLightsShadowmapTexture");
        }
        public ForwardRenderer(ForwardRendererData data) : base(data)
        {
            Downsampling downsamplingMethod = LightweightRenderPipeline.asset.opaqueDownsampling;

            Material blitMaterial               = CoreUtils.CreateEngineMaterial(data.blitShader);
            Material copyDepthMaterial          = CoreUtils.CreateEngineMaterial(data.copyDepthShader);
            Material samplingMaterial           = CoreUtils.CreateEngineMaterial(data.samplingShader);
            Material screenspaceShadowsMaterial = CoreUtils.CreateEngineMaterial(data.screenSpaceShadowShader);

            // Note: Since all custom render passes inject first and we have stable sort,
            // we inject the builtin passes in the before events.
            m_MainLightShadowCasterPass        = new MainLightShadowCasterPass(RenderPassEvent.BeforeRenderingShadows);
            m_AdditionalLightsShadowCasterPass = new AdditionalLightsShadowCasterPass(RenderPassEvent.BeforeRenderingShadows);
            m_DepthPrepass = new DepthOnlyPass(RenderPassEvent.BeforeRenderingPrepasses, RenderQueueRange.opaque);
            m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass(RenderPassEvent.BeforeRenderingPrepasses, screenspaceShadowsMaterial);
            m_FeedBackPass = new RenderFeedBackPass(RenderPassEvent.BeforeRenderingOpaques, RenderQueueRange.opaque, data.opaqueLayerMask);

            m_RenderOpaqueForwardPass      = new RenderOpaqueForwardPass(RenderPassEvent.BeforeRenderingOpaques, RenderQueueRange.opaque, data.opaqueLayerMask);
            m_CopyDepthPass                = new CopyDepthPass(RenderPassEvent.BeforeRenderingOpaques, copyDepthMaterial);
            m_OpaquePostProcessPass        = new PostProcessPass(RenderPassEvent.BeforeRenderingOpaques, true);
            m_DrawSkyboxPass               = new DrawSkyboxPass(RenderPassEvent.BeforeRenderingSkybox);
            m_CopyColorPass                = new CopyColorPass(RenderPassEvent.BeforeRenderingTransparents, samplingMaterial, downsamplingMethod);
            m_RenderTransparentForwardPass = new RenderTransparentForwardPass(RenderPassEvent.BeforeRenderingTransparents, RenderQueueRange.transparent, data.transparentLayerMask);
            m_PostProcessPass              = new PostProcessPass(RenderPassEvent.BeforeRenderingPostProcessing);
            m_CapturePass   = new CapturePass(RenderPassEvent.AfterRendering);
            m_FinalBlitPass = new FinalBlitPass(RenderPassEvent.AfterRendering, blitMaterial);

#if UNITY_EDITOR
            m_SceneViewDepthCopyPass = new SceneViewDepthCopyPass(RenderPassEvent.AfterRendering + 9, copyDepthMaterial);
#endif

            // RenderTexture format depends on camera and pipeline (HDR, non HDR, etc)
            // Samples (MSAA) depend on camera and pipeline
            m_CameraColorAttachment.Init("_CameraColorTexture");
            m_CameraDepthAttachment.Init("_CameraDepthAttachment");
            m_DepthTexture.Init("_CameraDepthTexture");
            m_OpaqueColor.Init("_CameraOpaqueTexture");
            m_ForwardLights = new ForwardLights();
        }
        public MainLightShadowCasterPass(RenderPassEvent evt)
        {
            renderPassEvent = evt;

            m_MainLightShadowMatrices = new Matrix4x4[k_MaxCascades + 1];
            m_CascadeSlices           = new ShadowSliceData[k_MaxCascades];
            m_CascadeSplitDistances   = new Vector4[k_MaxCascades];

            MainLightShadowConstantBuffer._WorldToShadow = Shader.PropertyToID("_MainLightWorldToShadow");
            MainLightShadowConstantBuffer._ShadowData    = Shader.PropertyToID("_MainLightShadowData");
            MainLightShadowConstantBuffer._CascadeShadowSplitSpheres0    = Shader.PropertyToID("_CascadeShadowSplitSpheres0");
            MainLightShadowConstantBuffer._CascadeShadowSplitSpheres1    = Shader.PropertyToID("_CascadeShadowSplitSpheres1");
            MainLightShadowConstantBuffer._CascadeShadowSplitSpheres2    = Shader.PropertyToID("_CascadeShadowSplitSpheres2");
            MainLightShadowConstantBuffer._CascadeShadowSplitSpheres3    = Shader.PropertyToID("_CascadeShadowSplitSpheres3");
            MainLightShadowConstantBuffer._CascadeShadowSplitSphereRadii = Shader.PropertyToID("_CascadeShadowSplitSphereRadii");
            MainLightShadowConstantBuffer._ShadowOffset0 = Shader.PropertyToID("_MainLightShadowOffset0");
            MainLightShadowConstantBuffer._ShadowOffset1 = Shader.PropertyToID("_MainLightShadowOffset1");
            MainLightShadowConstantBuffer._ShadowOffset2 = Shader.PropertyToID("_MainLightShadowOffset2");
            MainLightShadowConstantBuffer._ShadowOffset3 = Shader.PropertyToID("_MainLightShadowOffset3");
            MainLightShadowConstantBuffer._ShadowmapSize = Shader.PropertyToID("_MainLightShadowmapSize");

            m_MainLightShadowmap.Init("_MainLightShadowmapTexture");
        }
Example #8
0
 public ScreenSpaceShadowResolvePass(RenderPassEvent evt, Material screenspaceShadowsMaterial)
 {
     m_ScreenSpaceShadowsMaterial = screenspaceShadowsMaterial;
     m_ScreenSpaceShadowmap.Init("_ScreenSpaceShadowmapTexture");
     renderPassEvent = evt;
 }
Example #9
0
 public override void Create()
 {
     bloomPass = new BloomPass(settings.Event, name);
     m_SrcRenderTextureHandle.Init(settings.srcTextureId);
     m_CameraColorTextureHandle.Init("_CameraColorTexture");
 }
 public SSShadowDownSamplePass(RenderPassEvent evt, Material screenspaceShadowsMaterial)
 {
     m_SSDownSampleMaterial = screenspaceShadowsMaterial;
     m_ScreenSpaceShadowmap.Init("_ScreenSpaceShadowmapDownSampleTexture");
     renderPassEvent = evt;
 }