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 void RenderDensity(ParticipatingMediaComponent media, TransformComponent transform, PerspectiveCamera camera) { this.ShadowMapEffect.WorldViewProjection = transform.Matrix * camera.ViewProjection; this.ShadowMapEffect.Albedo = this.Albedo; this.ShadowMapEffect.MaskSampler = SamplerState.AnisotropicWrap; this.RenderDistance(this.BackRasterizerState, media.VolumeBackBuffer, media.Geometry); this.RenderDistance(this.FrontRasterizerState, media.VolumeFrontBuffer, media.Geometry); }
public void Process(ParticipatingMediaComponent media, TransformComponent transform) { var shadowMap = this.FrameService.ShadowMap; var sunlight = this.FrameService.Sunlight; var camera = this.FrameService.CameraComponent.Camera; this.RenderDensity(media, transform, camera); this.RenderMedia(media, shadowMap, camera); this.RenderMediaToLightTarget(media, sunlight); }
public (ParticipatingMediaComponent, TransformComponent) Create(int resolutionWidth, int resolutionHeight) { var entity = this.Entities.Create(); var cube = CubeGenerator.Generate(this.Device); var participatingMedia = ParticipatingMediaComponent.Create(entity, this.Device, cube, resolutionWidth, resolutionHeight, 1.0f, Color.White); var transform = new TransformComponent(entity); this.Components.Add(participatingMedia); this.Components.Add(transform); return(participatingMedia, transform); }
private void RenderMediaToLightTarget(ParticipatingMediaComponent media, SunlightComponent sunlight) { this.Device.SetRenderTarget(this.FrameService.LBuffer.Light); this.Device.BlendState = BlendState.AlphaBlend; this.PostProcessEffect.Media = media.ParticipatingMediaBuffer; this.PostProcessEffect.MediaColor = media.Color.ToVector3(); this.PostProcessEffect.LightColor = sunlight.Color.ToVector3(); this.PostProcessEffect.LightInfluence = media.LightInfluence; this.PostProcessEffect.DitherPattern = this.DitherPattern; this.PostProcessEffect.DitherPatternSampler = SamplerState.PointWrap; this.PostProcessEffect.ScreenDimensions = new Vector2(this.FrameService.LBuffer.Light.Width, this.FrameService.LBuffer.Light.Height); this.PostProcessEffect.Apply(); this.PostProcessTriangle.Render(this.Device); }