Beispiel #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();
        }
        protected void RenderShadowMap(Matrix lightViewProjectionAtZero)
        {
            // Set up the effect
            MyEffectShadowMap shadowMapEffect = MyRender.GetEffect(MyEffects.ShadowMap) as MyEffectShadowMap;

            shadowMapEffect.SetViewProjMatrix(lightViewProjectionAtZero);
            shadowMapEffect.SetDitheringTexture((SharpDX.Direct3D9.Texture)MyTextureManager.GetTexture <MyTexture2D>(@"Textures\Models\Dither.png"));
            shadowMapEffect.SetHalfPixel(MySpotShadowRenderer.SpotShadowMapSize, MySpotShadowRenderer.SpotShadowMapSize);

            // Draw the models
            DrawElements(m_renderElementsForShadows, shadowMapEffect, true, MyRenderCamera.Position, MyShadowRenderer.NumSplits, false);
        }
        protected void RenderShadowMap(Matrix lightViewProjection)
        {
            // Set up the effect
            MyEffectShadowMap shadowMapEffect = MyRender.GetEffect(MyEffects.ShadowMap) as MinerWars.AppCode.Game.Effects.MyEffectShadowMap;

            shadowMapEffect.SetViewProjMatrix(lightViewProjection);

            /*
             * m_culledElements.Clear();
             * foreach (MyRender.MyRenderElement element in m_renderElementsForShadows)
             * {
             * m_culledElements.Add(element);
             * }
             */
            // Draw the models
            DrawElements(m_renderElementsForShadows, shadowMapEffect, false, MyPerformanceCounter.NoSplit);
        }
        /// <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();
        }