Ejemplo n.º 1
0
        static void RenderDirectionalEnvironmentLight()
        {
            PixelShaderId directionalPixelShader;

            if (!MyRenderProxy.Settings.EnableShadows)
            {
                if (DirectionalEnvironmentLight_NoShadow == PixelShaderId.NULL)
                {
                    DirectionalEnvironmentLight_NoShadow = MyShaders.CreatePs("light_dir.hlsl", new[] { new ShaderMacro("NO_SHADOWS", null) });
                }

                directionalPixelShader = DirectionalEnvironmentLight_NoShadow;
            }
            else
            {
                directionalPixelShader = DirectionalEnvironmentLight_Pixel;
            }
            MySunlightConstantsLayout constants;

            constants.Direction = MyEnvironment.DirectionalLightDir;
            constants.Color     = MyEnvironment.DirectionalLightIntensity;

            var mapping = MyMapping.MapDiscard(m_sunlightConstants);

            mapping.WriteAndPosition(ref constants);
            mapping.Unmap();

            //context.VertexShader.Set(MyCommon.FullscreenShader.VertexShader);
            RC.SetPS(directionalPixelShader);
            RC.SetCB(1, m_sunlightConstants);
            RC.SetCB(4, MyRender11.DynamicShadows.ShadowCascades.CascadeConstantBuffer);
            RC.DeviceContext.PixelShader.SetSamplers(0, MyRender11.StandardSamplers);
            RC.DeviceContext.PixelShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MyRender11.m_shadowmapSamplerState);

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkybox, MyTextureEnum.CUBEMAP, true)));

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT,
                                                           MyRender11.IsIntelBrokenCubemapsWorkaround ? MyTextures.GetView(MyTextures.IntelFallbackCubeTexId) : MyEnvironmentProbe.Instance.cubemapPrefiltered.ShaderView);
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX2_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkybox, MyTextureEnum.CUBEMAP, true)));
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX2_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, MyRender11.DynamicShadows.ShadowCascades.CascadeShadowmapArray.ShaderView);
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SHADOW_SLOT, MyRender11.PostProcessedShadows.ShaderView);

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.AMBIENT_BRDF_LUT_SLOT,
                                                           MyCommon.GetAmbientBrdfLut());

            RC.BindSRV(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            if (MyRender11.MultisamplingEnabled)
            {
                RC.SetPS(DirectionalEnvironmentLight_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            }
        }
Ejemplo n.º 2
0
        static void RenderPointlightsTiled()
        {
            RC.BindSRV(MyCommon.TILE_LIGHT_INDICES_SLOT, MyScreenDependants.m_tileIndices);
            RC.BindRawSRV(MyCommon.POINTLIGHT_SLOT, m_pointlightCullHwBuffer.Srv);
            RC.BindSRV(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            RC.SetPS(PointlightsTiled_Pixel);
            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            if (MyRender11.MultisamplingEnabled)
            {
                RC.SetPS(PointlightsTiled_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            }
        }
        static void RenderDirectionalEnvironmentLight(ISrvTexture postProcessedShadows)
        {
            PixelShaderId    directionalPixelShader;
            MyShadowsQuality shadowsQuality = MyRender11.RenderSettings.ShadowQuality.GetShadowsQuality();

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

                directionalPixelShader = DirectionalEnvironmentLight_NoShadow;
            }
            else
            {
                directionalPixelShader = DirectionalEnvironmentLight_Pixel;
            }

            //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, MyScreenDependants.m_ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.LBuffer);
            if (MyRender11.MultisamplingEnabled)
            {
                RC.PixelShader.Set(DirectionalEnvironmentLight_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.LBuffer);
            }
            RC.PixelShader.SetSrv(MyCommon.SHADOW_SLOT, null);
        }
Ejemplo n.º 4
0
        public static void DisplayHdrIntensity(ISrvBindable srv)
        {
            RC.PixelShader.Set(m_psDisplayHdrIntensity);
            RC.PixelShader.SetSrv(5, srv);
            RC.SetBlendState(null);
            IBorrowedRtvTexture outTex = MyManagers.RwTexturesPool.BorrowRtv("MyHdrDebugTools.DisplayHdrIntensity.OutTex", srv.Size.X, srv.Size.Y, Format.B8G8R8X8_UNorm);

            MyScreenPass.RunFullscreenPixelFreq(outTex);
            MyDebugTextureDisplay.Select(outTex);

            RC.PixelShader.SetSrv(5, null);
            RC.SetRtvs(MyGBuffer.Main, MyDepthStencilAccess.ReadOnly);
            outTex.Release();
        }
        static void RenderPointlightsTiled()
        {
            RC.PixelShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            RC.PixelShader.SetRawSrv(MyCommon.TILE_LIGHT_INDICES_SLOT, MyScreenDependants.m_tileIndices.m_srv);
            RC.AllShaderStages.SetRawSrv(MyCommon.POINTLIGHT_SLOT, m_pointlightCullHwBuffer.Srv);
            RC.PixelShader.SetSrv(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            RC.PixelShader.Set(PointlightsTiled_Pixel);
            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.LBuffer);
            if (MyRender11.MultisamplingEnabled)
            {
                RC.PixelShader.Set(PointlightsTiled_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.LBuffer);
            }
        }
Ejemplo n.º 6
0
        static void RenderDirectionalEnvironmentLight()
        {
            MySunlightConstantsLayout constants;

            constants.Direction = MyEnvironment.DirectionalLightDir;
            constants.Color     = MyEnvironment.DirectionalLightIntensity;

            var mapping = MyMapping.MapDiscard(m_sunlightConstants);

            mapping.stream.Write(constants);
            mapping.Unmap();

            //context.VertexShader.Set(MyCommon.FullscreenShader.VertexShader);
            RC.SetPS(DirectionalEnvironmentLight_Pixel);
            RC.SetCB(1, m_sunlightConstants);
            RC.SetCB(4, MyShadows.m_csmConstants);
            RC.Context.PixelShader.SetSamplers(0, MyRender11.StandardSamplers);
            RC.Context.PixelShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MyRender11.m_shadowmapSamplerState);
            RC.Context.PixelShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, MyShadows.m_cascadeShadowmapArray.ShaderView);

            var z = Vector4.Transform(new Vector4(0.5f, 0.5f, -MyEnvironment.FarClipping, 1), MyEnvironment.Projection);


            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkybox, MyTextureEnum.CUBEMAP, true)));
            //RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT,
                                                     MyRender11.IsIntelBrokenCubemapsWorkaround ? MyTextures.GetView(MyTextures.IntelFallbackCubeTexId) : MyGeometryRenderer.m_envProbe.cubemapPrefiltered.ShaderView);
            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX2_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkybox, MyTextureEnum.CUBEMAP, true)));
            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX2_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.Context.PixelShader.SetShaderResource(MyCommon.SHADOW_SLOT, MyRender11.m_shadowsHelper.ShaderView);

            RC.Context.PixelShader.SetShaderResource(MyCommon.AMBIENT_BRDF_LUT_SLOT,
                                                     MyCommon.GetAmbientBrdfLut());

            RC.BindSRV(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            if (MyRender11.MultisamplingEnabled)
            {
                RC.SetPS(DirectionalEnvironmentLight_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            }
        }