コード例 #1
0
ファイル: MyLightsRendering.cs プロジェクト: viktorius/Viktor
        private static void RenderDirectionalEnvironmentLight(ISrvTexture postProcessedShadows, IRtvTexture ambientOcclusion)
        {
            PixelShaderId    directionalPixelShader;
            MyShadowsQuality shadowsQuality = MyRender11.Settings.User.ShadowQuality.GetShadowsQuality();

            if (!MyRender11.Settings.EnableShadows || !MyRender11.DebugOverrides.Shadows || shadowsQuality == MyShadowsQuality.DISABLED)
            {
                if (m_directionalEnvironmentLightNoShadow == PixelShaderId.NULL)
                {
                    m_directionalEnvironmentLightNoShadow = MyShaders.CreatePs("Lighting/LightDir.hlsl", new[] { new ShaderMacro("NO_SHADOWS", null) });
                }

                directionalPixelShader = m_directionalEnvironmentLightNoShadow;
            }
            else
            {
                directionalPixelShader = m_directionalEnvironmentLightPixel;
            }

            //context.VertexShader.Set(MyCommon.FullscreenShader.VertexShader);
            RC.PixelShader.Set(directionalPixelShader);
            RC.AllShaderStages.SetConstantBuffer(4, MyRender11.DynamicShadows.ShadowCascades.CascadeConstantBuffer);
            RC.PixelShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MySamplerStateManager.Shadowmap);

            MyFileTextureManager texManager = MyManagers.FileTextures;

            RC.PixelShader.SetSrv(MyCommon.SKYBOX_SLOT, texManager.GetTexture(MyRender11.Environment.Data.Skybox, MyFileTextureEnum.CUBEMAP, true));

            ISrvBindable skybox = MyRender11.IsIntelBrokenCubemapsWorkaround
                ? MyGeneratedTextureManager.IntelFallbackCubeTex
                : (ISrvBindable)MyManagers.EnvironmentProbe.Cubemap;

            RC.PixelShader.SetSrv(MyCommon.SKYBOX_IBL_SLOT, skybox);

            RC.PixelShader.SetSrv(MyCommon.CASCADES_SM_SLOT, MyRender11.DynamicShadows.ShadowCascades.CascadeShadowmapArray);
            RC.PixelShader.SetSrv(MyCommon.SHADOW_SLOT, postProcessedShadows);

            RC.PixelShader.SetSrv(MyCommon.AMBIENT_BRDF_LUT_SLOT,
                                  MyCommon.GetAmbientBrdfLut());

            RC.PixelShader.SetSrv(MyCommon.AO_SLOT, ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.LBuffer);
            if (MyRender11.MultisamplingEnabled)
            {
                RC.PixelShader.Set(m_directionalEnvironmentLightSample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.LBuffer);
            }
            RC.PixelShader.SetSrv(MyCommon.SHADOW_SLOT, null);
        }