public void Process(SpotLightComponent spotLight, ShadowMapComponent shadowMap, CameraComponent shadowMapCamera) { var world = Matrix.Invert(shadowMapCamera.Camera.ViewProjection); this.Effect.WorldViewProjection = world * this.FrameService.CameraComponent.Camera.ViewProjection; this.Effect.CameraPosition = this.FrameService.CameraComponent.Camera.Position; this.Effect.Albedo = this.FrameService.GBuffer.Albedo; this.Effect.Normal = this.FrameService.GBuffer.Normal; this.Effect.Depth = this.FrameService.GBuffer.Depth; this.Effect.Material = this.FrameService.GBuffer.Material; this.Effect.GBufferSampler = SamplerState.LinearClamp; this.Effect.InverseViewProjection = Matrix.Invert(this.FrameService.CameraComponent.Camera.ViewProjection); this.Effect.Position = shadowMapCamera.Camera.Position; this.Effect.Color = spotLight.Color.ToVector4(); this.Effect.Strength = spotLight.Strength; this.Effect.ShadowMap = shadowMap.DepthMap; this.Effect.ShadowSampler = ShadowMapSampler.State; this.Effect.ShadowViewProjection = shadowMapCamera.Camera.ViewProjection; this.Effect.Apply(); this.Volume.Render(this.Device); }
public (SpotLightComponent spotLight, ShadowMapComponent shadowMap, CameraComponent viewPoint) CreateSpotLight(int resolution) { var entity = this.Entities.Create(); var spotLight = new SpotLightComponent(entity, Color.White, 100.0f); var shadowMap = ShadowMapComponent.Create(entity, this.Device, resolution); var camera = new CameraComponent(entity, new PerspectiveCamera(this.Device.Viewport.AspectRatio)); this.Components.Add(spotLight, shadowMap, camera); return(spotLight, shadowMap, camera); }