unsafe void IManagerDevice.OnDeviceInit()
        {
            if (m_markerConstantBuffer == null)
            {
                m_markerConstantBuffer = MyManagers.Buffers.CreateConstantBuffer("MyPostprocessMarkCascades.MarkerConstantBuffer", sizeof(MyMarkerConstants), usage: ResourceUsage.Dynamic);
            }

            if (m_psMarker == PixelShaderId.NULL)
            {
                m_psMarker = MyShaders.CreatePs("Shadows\\StencilMarker.hlsl");
            }
            if (m_vsMarker == VertexShaderId.NULL)
            {
                m_vsMarker = MyShaders.CreateVs("Shadows\\StencilMarker.hlsl");
            }
            if (m_psDrawCoverage == PixelShaderId.NULL)
            {
                m_psDrawCoverage = MyShaders.CreatePs("Shadows\\CascadeCoverage.hlsl");
            }
            if (m_inputLayout == InputLayoutId.NULL)
            {
                m_inputLayout = MyShaders.CreateIL(m_vsMarker.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3));
            }

            m_vertexBuffer = CreateVertexBuffer();
            m_indexBuffer  = CreateIndexBuffer();
        }
Example #2
0
 unsafe void IManagerDevice.OnDeviceInit()
 {
     if (m_ps == PixelShaderId.NULL)
     {
         m_ps = MyShaders.CreatePs("Shadows\\RedToAll.hlsl");
     }
 }
        public MyShaderBundle GetShaderBundle(MyRenderPassType pass, MyMeshDrawTechnique technique, MyInstanceLodState state, bool isCm, bool isNg, bool isExt)
        {
            // Modify input:
            switch (technique)
            {
            case MyMeshDrawTechnique.DECAL:
            case MyMeshDrawTechnique.DECAL_CUTOUT:
            case MyMeshDrawTechnique.DECAL_NOPREMULT:
                break;

            default:
                isCm  = true;
                isNg  = true;
                isExt = true;
                break;
            }

            MyShaderBundleKey key = new MyShaderBundleKey
            {
                Pass      = pass,
                Technique = technique,
                IsCm      = isCm,
                IsNg      = isNg,
                IsExt     = isExt,
                State     = state,
            };

            if (m_cache.ContainsKey(key))
            {
                return(m_cache[key]);
            }

            MyVertexInputComponent[] viComps = GetVertexInputComponents(pass);
            VertexLayoutId           vl      = MyVertexLayouts.GetLayout(viComps);
            string             vsFilepath    = GetShaderDirpath(technique) + "Vertex.hlsl";
            string             psFilepath    = GetShaderDirpath(technique) + "Pixel.hlsl";
            List <ShaderMacro> macros        = new List <ShaderMacro>();

            AddMacrosForRenderingPass(pass, ref macros);
            AddMacrosForTechnique(technique, isCm, isNg, isExt, ref macros);
            AddMacrosVertexInputComponents(viComps, ref macros);
            AddMacrosState(state, ref macros);

            VertexShaderId vs = MyShaders.CreateVs(vsFilepath, macros.ToArray());

            ((VertexShader)vs).DebugName = GetVsDebugName(pass, technique, macros);
            PixelShaderId ps = MyShaders.CreatePs(psFilepath, macros.ToArray());

            ((PixelShader)ps).DebugName = GetPsDebugName(pass, technique, macros);;
            InputLayoutId  il           = MyShaders.CreateIL(vs.BytecodeId, vl);
            MyShaderBundle shaderBundle = new MyShaderBundle(ps, vs, il);

            m_cache.Add(key, shaderBundle);
            return(shaderBundle);
        }
Example #4
0
        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);
        }
Example #5
0
        public static void Draw(IRtvBindable renderTarget)
        {
            ISrvBindable srvBind = null;

            if (m_selRtvTexture != null)
            {
                srvBind = m_selRtvTexture;
            }
            if (m_selUavTexture != null)
            {
                srvBind = m_selUavTexture;
            }
            if (m_selBorrowedRtvTexture != null)
            {
                srvBind = m_selBorrowedRtvTexture;
            }
            if (m_selBorrowedUavTexture != null)
            {
                srvBind = m_selBorrowedUavTexture;
            }

            if (srvBind == null) // no texture is selected
            {
                return;
            }

            if (m_ps == PixelShaderId.NULL)
            {
                m_ps = MyShaders.CreatePs("Debug/DebugRt.hlsl");
            }

            MyRenderContext RC = MyImmediateRC.RC;

            RC.SetPrimitiveTopology(PrimitiveTopology.TriangleList);
            RC.SetViewport(0, 0, MyRender11.ViewportResolution.X, MyRender11.ViewportResolution.Y);
            RC.SetRtv(renderTarget);
            RC.SetBlendState(null);
            RC.PixelShader.Set(m_ps);
            RC.PixelShader.SetSrv(0, srvBind);
            RC.PixelShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            MyScreenPass.DrawFullscreenQuad();

            Deselect();
        }
Example #6
0
        void IManagerDevice.OnDeviceInit()
        {
            if (m_ps == PixelShaderId.NULL)
            {
                switch (m_type)
                {
                case Type.HARD:
                    m_ps = MyShaders.CreatePs("Shadows\\PostprocessHardShadows.hlsl");
                    break;

                case Type.SIMPLE:
                    m_ps = MyShaders.CreatePs("Shadows\\PostprocessSimpleShadows.hlsl");
                    break;

                default:
                    MyRenderProxy.Assert(false, "Unknown type of postproces!");
                    break;
                }
            }
        }
Example #7
0
        internal static unsafe void Init()
        {
            //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));

            m_directionalEnvironmentLightPixel  = MyShaders.CreatePs("Lighting/LightDir.hlsl");
            m_directionalEnvironmentLightSample = MyShaders.CreatePs("Lighting/LightDir.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_pointlightsTiledPixel  = MyShaders.CreatePs("Lighting/LightPoint.hlsl");
            m_pointlightsTiledSample = MyShaders.CreatePs("Lighting/LightPoint.hlsl", MyRender11.ShaderSampleFrequencyDefine());

            m_preparePointLights = MyShaders.CreateCs("Lighting/PrepareLights.hlsl", new[] { new ShaderMacro("NUMTHREADS", TILE_SIZE) });

            m_spotlightProxyVs  = MyShaders.CreateVs("Lighting/LightSpot.hlsl");
            m_spotlightPsPixel  = MyShaders.CreatePs("Lighting/LightSpot.hlsl");
            m_spotlightPsSample = MyShaders.CreatePs("Lighting/LightSpot.hlsl", MyRender11.ShaderSampleFrequencyDefine());
            m_spotlightProxyIl  = MyShaders.CreateIL(m_spotlightProxyVs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION_PACKED));

            m_pointlightCullHwBuffer = MyManagers.Buffers.CreateSrv(
                "MyLightRendering", MyRender11Constants.MAX_POINT_LIGHTS, sizeof(MyPointlightConstants),
                usage: ResourceUsage.Dynamic);
        }
 public MyShaderBundle(PixelShaderId ps, VertexShaderId vs, InputLayoutId il)
 {
     PixelShader  = ps;
     VertexShader = vs;
     InputLayout  = il;
 }
Example #9
0
 private unsafe static void Init()
 {
     m_ps          = MyShaders.CreatePs("Postprocess/PostprocessColorizeExportedEexture.hlsl");
     m_cb          = MyManagers.Buffers.CreateConstantBuffer("ExportedTexturesColor", sizeof(Vector4), usage: ResourceUsage.Dynamic);
     m_initialized = true;
 }
Example #10
0
 internal static void Init()
 {
     m_ps = MyShaders.CreatePs("Postprocess/DepthResolve.hlsl");
 }
 private unsafe static void Init()
 {
     m_ps          = MyShaders.CreatePs("postprocess_colorize_exported_texture.hlsl");
     m_cb          = MyHwBuffers.CreateConstantsBuffer(sizeof(Vector4), "ExportedTexturesColor");
     m_initialized = true;
 }
Example #12
0
 internal static void Init()
 {
     m_ps = MyShaders.CreatePs("Postprocess/EdgeDetection.hlsl");
 }