Exemplo n.º 1
0
        // Shadow Map zeichnen
        private void DrawShadowMap(Effect effect, ShaderModel shaderModel, Light light)
        {
            // Lichtmatrizen übergeben
            effect.Parameters["View"].SetValue(light.ViewMatrix);
            effect.Parameters["Projection"].SetValue(light.ProjectionMatrix);

            foreach (ModelMesh mesh in shaderModel.DrawingModel.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    part.Effect = effect;
                    part.Effect.CurrentTechnique = part.Effect.Techniques["ShadowMap"];
                    effect.Parameters["World"].SetValue(mesh.ParentBone.Transform * shaderModel.WorldMatrix);
                }
                mesh.Draw();
            }
        }
Exemplo n.º 2
0
 private void SetupLights()
 {
     Vector3 position = new Vector3(0.0f, 14.5f, 0.0f);
     Lamp lamp = new Lamp(this, Matrix.CreateRotationX(MathHelper.ToRadians(-90)) * Matrix.CreateTranslation(position));
     Light = new Light(this, lamp, Light.RotationAxis.X, position);
     Components.Add(lamp);
     Components.Add(Light);
 }
Exemplo n.º 3
0
        // PCF Map zeichnen
        private void DrawPCFMap(Effect effect, ShaderModel shaderModel, Light light, RenderTarget2D shadowMapTexture)
        {
            ICamera camera = (ICamera)Services.GetService(typeof(ICamera));

            // Kameramatrizen übergeben
            effect.Parameters["View"].SetValue(camera.ViewMatrix);
            effect.Parameters["Projection"].SetValue(camera.ProjectionMatrix);

            // Lichtview und -projection übergeben
            effect.Parameters["LightView"].SetValue(light.ViewMatrix);
            effect.Parameters["LightProjection"].SetValue(light.ProjectionMatrix);

            // Shadow Map übergeben
            effect.Parameters["ShadowMapLight0Texture"].SetValue(shadowMapTexture);
            effect.Parameters["ShadowMapSize"].SetValue(shadowMapSize);

            foreach (ModelMesh mesh in shaderModel.DrawingModel.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    part.Effect = effect;
                    part.Effect.CurrentTechnique = part.Effect.Techniques["PCFMap"];

                    effect.Parameters["World"].SetValue(mesh.ParentBone.Transform * shaderModel.WorldMatrix);
                }
                mesh.Draw();
            }
        }