public void Process(SunlightComponent sunlight, CascadedShadowMapComponent shadowMap, CameraComponent shadowMapCamera) { 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.SurfaceToLight = -shadowMapCamera.Camera.Forward; this.Effect.Color = sunlight.Color.ToVector4(); this.Effect.Strength = sunlight.Strength; this.Effect.ShadowMap = shadowMap.DepthMapArray; this.Effect.ShadowSampler = ShadowMapSampler.State; this.Effect.ShadowMatrix = shadowMap.GlobalShadowMatrix; this.Effect.Splits = shadowMap.Splits; this.Effect.Offsets = shadowMap.Offsets; this.Effect.Scales = shadowMap.Scales; this.Effect.ApplySunlightTechnique(); this.PostProcessTriangle.Render(this.Device); }
private void RenderMedia(ParticipatingMediaComponent media, CascadedShadowMapComponent shadowMap, PerspectiveCamera camera) { this.Device.SetRenderTarget(media.ParticipatingMediaBuffer); this.Device.Clear(ClearOptions.Target, Color.Black, 1.0f, 0); this.MediaEffect.Noise = this.Noise; this.MediaEffect.NoiseSampler = SamplerState.PointWrap; this.MediaEffect.VolumeBack = media.VolumeBackBuffer; this.MediaEffect.VolumeFront = media.VolumeFrontBuffer; this.MediaEffect.VolumeSampler = SamplerState.LinearClamp; this.MediaEffect.Depth = this.FrameService.GBuffer.Depth; this.MediaEffect.GBufferSampler = SamplerState.LinearClamp; this.MediaEffect.InverseViewProjection = Matrix.Invert(camera.ViewProjection); this.MediaEffect.CameraPosition = camera.Position; this.MediaEffect.Strength = media.Strength; this.MediaEffect.ShadowMap = shadowMap.DepthMapArray; this.MediaEffect.ShadowSampler = ShadowMapSampler.State; this.MediaEffect.ShadowMatrix = shadowMap.GlobalShadowMatrix; this.MediaEffect.Splits = shadowMap.Splits; this.MediaEffect.Offsets = shadowMap.Offsets; this.MediaEffect.Scales = shadowMap.Scales; this.MediaEffect.ViewDistance = camera.FarPlane; this.MediaEffect.MinLight = 0.1f; this.MediaEffect.Apply(); this.PostProcessTriangle.Render(this.Device); }
private Entity CreatePrimaryLightSource() { var entity = this.Entities.Create(); this.Components.Add(new SunlightComponent(entity, Color.White, 3)); this.Components.Add(CascadedShadowMapComponent.Create(entity, this.Device, 2048, DefaultCascadeDistances)); var position = Vector3.Up; var lookAt = (Vector3.Left * 0.75f) + (Vector3.Backward * 0.1f); var forward = Vector3.Normalize(lookAt - position); var camera = new PerspectiveCamera(1.0f, position, forward); this.Components.Add(new CameraComponent(entity, camera)); return(entity); }