Exemplo n.º 1
0
        /// <summary>
        /// Renders the shadow map using the orthographic camera created in
        /// CalculateFrustum.
        /// </summary>
        /// <param name="modelList">The list of models to be rendered</param>
        protected void RenderShadowMap(int splitIndex)
        {
            PrepareViewportForCascade(splitIndex);

            // Set up the effect
            MyEffectShadowMap shadowMapEffect = MyRender.GetEffect(MyEffects.ShadowMap) as Effects.MyEffectShadowMap;

            shadowMapEffect.SetDitheringTexture((SharpDX.Direct3D9.Texture)MyTextureManager.GetTexture <MyTexture2D>(@"Textures\Models\Dither.png"));
            shadowMapEffect.SetHalfPixel(MyShadowRenderer.NumSplits * MyRender.GetShadowCascadeSize(), MyRender.GetShadowCascadeSize());

            // Clear shadow map
            shadowMapEffect.SetTechnique(MyEffectShadowMap.ShadowTechnique.Clear);

            MyRender.GetFullscreenQuad().Draw(shadowMapEffect);

            shadowMapEffect.SetViewProjMatrix((Matrix)m_lightCameras[splitIndex].ViewProjMatrixAtZero);

            MyRender.GetRenderProfiler().StartProfilingBlock("draw elements");
            // Draw the models
            DrawElements(m_lightCameras[splitIndex].CastingRenderElements, shadowMapEffect, true, m_lightCameras[splitIndex].WorldMatrix.Translation, splitIndex, true);

            m_lightCameras[splitIndex].CastingRenderElements.Clear();

            MyRender.GetRenderProfiler().EndProfilingBlock();
        }