protected static void DrawElements(List <MyRender.MyRenderElement> elements, MyEffectShadowMap effect, bool relativeCamera, int perfCounterIndex)
        {
            // Draw shadows.
            effect.SetTechnique(MyEffectShadowMap.ShadowTechnique.GenerateShadow);
            DrawShadowsForElements(effect, relativeCamera, elements, false, perfCounterIndex);

            effect.SetTechnique(MyEffectShadowMap.ShadowTechnique.GenerateShadowForVoxels);
            DrawShadowsForElements(effect, relativeCamera, elements, true, perfCounterIndex);
        }
Esempio n. 2
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();
        }
        protected static void DrawElements(List <MyRender.MyRenderElement> elements, MyEffectShadowMap effect, bool relativeCamera, Vector3D cameraPos, int perfCounterIndex, bool ditheredShadows)
        {
            // Draw shadows.
            effect.SetTechnique(MyEffectShadowMap.ShadowTechnique.GenerateShadow);
            DrawShadowsForElements(effect, relativeCamera, cameraPos, elements, false, false, false, false, perfCounterIndex, ditheredShadows);

            effect.SetTechnique(MyEffectShadowMap.ShadowTechnique.GenerateShadowForVoxels);
            DrawShadowsForElements(effect, relativeCamera, cameraPos, elements, true, false, false, false, perfCounterIndex, ditheredShadows);

            effect.SetTechnique(MyEffectShadowMap.ShadowTechnique.GenerateShadowForSkinned);
            DrawShadowsForElements(effect, relativeCamera, cameraPos, elements, false, true, false, false, perfCounterIndex, ditheredShadows);

            effect.SetTechnique(MyEffectShadowMap.ShadowTechnique.GenerateShadowInstanced);
            DrawShadowsForElements(effect, relativeCamera, cameraPos, elements, false, false, true, false, perfCounterIndex, ditheredShadows);

            effect.SetTechnique(MyEffectShadowMap.ShadowTechnique.GenerateShadowInstancedGeneric);
            DrawShadowsForElements(effect, relativeCamera, cameraPos, elements, false, false, false, true, perfCounterIndex, ditheredShadows);

            // We don't want to keep objects alive
            Clear();
        }
        /// <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 MinerWars.AppCode.Game.Effects.MyEffectShadowMap;

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

            shadowMapEffect.SetViewProjMatrix(m_lightCameras[splitIndex].ViewProjectionMatrix);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("draw elements");
            // Draw the models
            DrawElements(m_lightCameras[splitIndex].CastingRenderElements, shadowMapEffect, false, splitIndex);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }