/// <summary> /// Updates the from light view projection /// </summary> public override void UpdateFromLightViewProjection(Camera camera, ISceneLight light) { if (light is ISceneLightPoint lightPoint) { var vp = GetFromPointLightViewProjection(lightPoint); this.ToShadowMatrix = vp[0]; this.LightPosition = lightPoint.Position; this.FromLightViewProjectionArray = vp; } }
/// <summary> /// Updates the from light view projection /// </summary> public override void UpdateFromLightViewProjection(Camera camera, ISceneLight light) { if (light is ISceneLightDirectional lightDirectional) { this.MatrixSet.Update(camera, lightDirectional.Direction); lightDirectional.ToShadowSpace = this.MatrixSet.GetWorldToShadowSpace(); lightDirectional.ToCascadeOffsetX = this.MatrixSet.GetToCascadeOffsetX(); lightDirectional.ToCascadeOffsetY = this.MatrixSet.GetToCascadeOffsetY(); lightDirectional.ToCascadeScale = this.MatrixSet.GetToCascadeScale(); var vp = this.MatrixSet.GetWorldToCascadeProj(); this.ToShadowMatrix = vp[0]; this.LightPosition = this.MatrixSet.GetLigthPosition(); this.FromLightViewProjectionArray = vp; } }
/// <summary> /// Updates the from light view projection /// </summary> public override void UpdateFromLightViewProjection(Camera camera, ISceneLight light) { if (light is ISceneLightSpot lightSpot) { var near = 1f; var projection = Matrix.PerspectiveFovLH(lightSpot.AngleRadians * 2f, 1f, near, lightSpot.Radius); var pos = lightSpot.Position; var look = lightSpot.Position + (lightSpot.Direction * lightSpot.Radius); var view = Matrix.LookAtLH(pos, look, Vector3.Up); var vp = view * projection; this.ToShadowMatrix = vp; this.LightPosition = lightSpot.Position; this.FromLightViewProjectionArray = new[] { vp }; } }
/// <summary> /// Updates the from light view projection /// </summary> public abstract void UpdateFromLightViewProjection(Camera camera, ISceneLight light);