Пример #1
0
        private void UnwrapShadowCasters(SpotLight sLight, float lightDirAngle, float angleBias)
        {
            graphics.GraphicsDevice.SetRenderTarget(unwrapTarget);
            graphics.GraphicsDevice.Clear(Color.Transparent);

            unwrapSpotlight.Parameters["LightPos"].SetValue(sLight.Position);
            unwrapSpotlight.Parameters["MinAngle"].SetValue(lightDirAngle - (sLight.outerAngle / 2f));
            unwrapSpotlight.Parameters["MaxAngle"].SetValue(lightDirAngle + (sLight.outerAngle / 2f));

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp, null, null, unwrapSpotlight);
            spriteBatch.Draw(midGroundTarget, new Rectangle(0, 0, fullScreen.Width, fullScreen.Width), Color.White);
            spriteBatch.End();
        }
Пример #2
0
        private void CreateLightMap(SpotLight sLight, float lightDirAngle, float angleBias)
        {
            graphics.GraphicsDevice.SetRenderTarget(postProcessTarget);
            graphics.GraphicsDevice.Clear(Color.Black);

            spotLight.Parameters["LightPos"].SetValue(sLight.Position);
            spotLight.Parameters["LightPow"].SetValue(sLight.Power);
            spotLight.Parameters["Radius"].SetValue(sLight.Radius);
            spotLight.Parameters["OuterMinAngle"].SetValue(lightDirAngle - (sLight.outerAngle / 2f));
            spotLight.Parameters["OuterMaxAngle"].SetValue(lightDirAngle + (sLight.outerAngle / 2f));
            spotLight.Parameters["CenterAngle"].SetValue(lightDirAngle);
            spotLight.Parameters["HalfInnerArc"].SetValue(sLight.innerAngle / 2f);
            spotLight.Parameters["HalfOuterArc"].SetValue(sLight.outerAngle / 2f);
            spotLight.Parameters["AngleBias"].SetValue(angleBias);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp, null, null, spotLight);
            spriteBatch.Draw(occlusionMap, fullScreen, Color.White);
            spriteBatch.End();
        }