/// <summary> /// Updates per spot light variables /// </summary> /// <param name="light">Light</param> /// <param name="transform">Translation matrix</param> /// <param name="viewProjection">View * projection matrix</param> /// <param name="shadowMaps">Shadow map flags</param> /// <param name="shadowMap">Cubic shadow map</param> public void UpdatePerLight( SceneLightPoint light, Matrix transform, Matrix viewProjection, IShadowMap shadowMap) { this.PointLight = new BufferLightPoint(light); this.World = transform; this.WorldViewProjection = transform * viewProjection; this.ShadowMapPoint = shadowMap?.Texture; }
/// <summary> /// Constructor /// </summary> /// <param name="light">Light</param> public BufferLightPoint(SceneLightPoint light) { this.Position = light.Position; this.DiffuseColor = light.DiffuseColor; this.SpecularColor = light.SpecularColor; this.Intensity = light.Intensity; this.Radius = light.Radius; this.CastShadow = light.CastShadow ? 1 : 0; this.MapIndex = light.ShadowMapIndex; var perspectiveMatrix = Matrix.PerspectiveFovLH(MathUtil.PiOverTwo, 1, 0.1f, this.Radius + 0.1f); this.PerspectiveValues = new Vector2(perspectiveMatrix[2, 2], perspectiveMatrix[3, 2]); this.Pad1 = 1000; this.Pad2 = 2000; this.Pad3 = 3000; }