private void RenderShadowMap(SpotLight spotLight) { this.GraphicsDevice.SetRenderTarget(spotLight.ShadowMap); this.GraphicsDevice.Clear(Color.Transparent); this.DepthWriterEffect.Parameters["View"].SetValue(spotLight.ViewMatrix); this.DepthWriterEffect.Parameters["Projection"].SetValue(spotLight.ProjectionMatrix); this.DepthWriterEffect.Parameters["LightPosition"].SetValue(spotLight.Position); this.DepthWriterEffect.Parameters["DepthPrecision"].SetValue(spotLight.FarPlane); this.RenderSceneForShadows(); }
/// <summary> /// Parses a <see cref="SpotLight" /> from the given XML node. /// </summary> /// <param name="node">The XML node.</param> /// <returns>A <see cref="SceneNode" /> instance.</returns> public SceneNode ParseSpotLight(XElement node) { SpotLight spotLight = new SpotLight( this.ParseVector3(node.Element("position")), Quaternion.Identity, Vector3.One, this.ParseVector3(node.Element("direction")), this.ParseColor(node.Element("color")), float.Parse(node.Attribute("intensity").Value), float.Parse(node.Element("clip").Attribute("near").Value), float.Parse(node.Element("clip").Attribute("far").Value), float.Parse(node.Element("projection").Attribute("field-of-view").Value), float.Parse(node.Attribute("bias").Value), bool.Parse(node.Attribute("cast-shadows").Value), int.Parse(node.Attribute("resolution").Value)); SceneNode sceneNode = new SceneNode(); sceneNode.AttachEntity(spotLight); return sceneNode; }