Ejemplo n.º 1
0
        public HDRenderPipelineInstance(HDRenderPipeline owner)
        {
            m_Owner = owner;

            m_CameraColorBuffer        = Shader.PropertyToID("_CameraColorTexture");
            m_CameraSubsurfaceBuffer   = Shader.PropertyToID("_CameraSubsurfaceTexture");
            m_CameraFilteringBuffer    = Shader.PropertyToID("_CameraFilteringBuffer");
            m_CameraDepthStencilBuffer = Shader.PropertyToID("_CameraDepthTexture");
            m_CameraStencilBuffer      = Shader.PropertyToID("_CameraStencilTexture");

            m_CameraColorBufferRT        = new RenderTargetIdentifier(m_CameraColorBuffer);
            m_CameraSubsurfaceBufferRT   = new RenderTargetIdentifier(m_CameraSubsurfaceBuffer);
            m_CameraFilteringBufferRT    = new RenderTargetIdentifier(m_CameraFilteringBuffer);
            m_CameraDepthStencilBufferRT = new RenderTargetIdentifier(m_CameraDepthStencilBuffer);
            m_CameraStencilBufferRT      = new RenderTargetIdentifier(m_CameraStencilBuffer);

            m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer");

            m_CombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
            m_DebugDisplayShadowMap       = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayShadowMap");

            m_ShadowPass = new ShadowRenderPass(owner.shadowSettings);

            // Init Gbuffer description
            m_gbufferManager.gbufferCount = m_LitRenderLoop.GetMaterialGBufferCount();
            RenderTextureFormat[]    RTFormat;
            RenderTextureReadWrite[] RTReadWrite;
            m_LitRenderLoop.GetMaterialGBufferDescription(out RTFormat, out RTReadWrite);

            for (int gbufferIndex = 0; gbufferIndex < m_gbufferManager.gbufferCount; ++gbufferIndex)
            {
                m_gbufferManager.SetBufferDescription(gbufferIndex, "_GBufferTexture" + gbufferIndex, RTFormat[gbufferIndex], RTReadWrite[gbufferIndex]);
            }

            m_VelocityBuffer = Shader.PropertyToID("_VelocityTexture");
            if (ShaderConfig.s_VelocityInGbuffer == 1)
            {
                // If velocity is in GBuffer then it is in the last RT. Assign a different name to it.
                m_gbufferManager.SetBufferDescription(m_gbufferManager.gbufferCount, "_VelocityTexture", Builtin.RenderLoop.GetVelocityBufferFormat(), Builtin.RenderLoop.GetVelocityBufferReadWrite());
                m_gbufferManager.gbufferCount++;
            }
            m_VelocityBufferRT = new RenderTargetIdentifier(m_VelocityBuffer);

            m_DistortionBuffer   = Shader.PropertyToID("_DistortionTexture");
            m_DistortionBufferRT = new RenderTargetIdentifier(m_DistortionBuffer);

            m_LitRenderLoop.Build();

            if (owner.lightLoopProducer)
            {
                m_LightLoop = owner.lightLoopProducer.CreateLightLoop();
            }

            if (m_LightLoop != null)
            {
                m_LightLoop.Build(owner.textureSettings);
            }

            m_SkyManager.skyParameters = owner.skyParametersToUse;
        }