diff --git a/Source/Engine/Level/Actors/ExponentialHeightFog.cpp b/Source/Engine/Level/Actors/ExponentialHeightFog.cpp index ce6807095..56a3bed3b 100644 --- a/Source/Engine/Level/Actors/ExponentialHeightFog.cpp +++ b/Source/Engine/Level/Actors/ExponentialHeightFog.cpp @@ -128,9 +128,9 @@ bool ExponentialHeightFog::IntersectsItself(const Ray& ray, Real& distance, Vect return false; } -void ExponentialHeightFog::GetVolumetricFogOptions(VolumetricFogOptions& result) const +void ExponentialHeightFog::GetVolumetricFogOptions(const RenderView& view, VolumetricFogOptions& result) const { - const float height = (float)GetPosition().Y; + const float height = (float)(GetPosition().Y - view.Origin.Y); const float density = FogDensity / 1000.0f; const float heightFalloff = FogHeightFalloff / 1000.0f; @@ -145,7 +145,7 @@ void ExponentialHeightFog::GetVolumetricFogOptions(VolumetricFogOptions& result) void ExponentialHeightFog::GetExponentialHeightFogData(const RenderView& view, ShaderExponentialHeightFogData& result) const { - const float height = (float)GetPosition().Y; + const float height = (float)(GetPosition().Y - view.Origin.Y); const float density = FogDensity / 1000.0f; const float heightFalloff = FogHeightFalloff / 1000.0f; const float viewHeight = view.Position.Y; diff --git a/Source/Engine/Level/Actors/ExponentialHeightFog.h b/Source/Engine/Level/Actors/ExponentialHeightFog.h index fad0df2bb..2a82b5e7c 100644 --- a/Source/Engine/Level/Actors/ExponentialHeightFog.h +++ b/Source/Engine/Level/Actors/ExponentialHeightFog.h @@ -154,7 +154,7 @@ public: bool IntersectsItself(const Ray& ray, Real& distance, Vector3& normal) override; // [IFogRenderer] - void GetVolumetricFogOptions(VolumetricFogOptions& result) const override; + void GetVolumetricFogOptions(const RenderView& view, VolumetricFogOptions& result) const override; void GetExponentialHeightFogData(const RenderView& view, ShaderExponentialHeightFogData& result) const override; void DrawFog(GPUContext* context, RenderContext& renderContext, GPUTextureView* output) override; diff --git a/Source/Engine/Renderer/DrawCall.h b/Source/Engine/Renderer/DrawCall.h index 6e55af877..a52de8bae 100644 --- a/Source/Engine/Renderer/DrawCall.h +++ b/Source/Engine/Renderer/DrawCall.h @@ -80,8 +80,9 @@ public: /// /// Gets the volumetric fog options. /// + /// The rendering view. /// The result. - virtual void GetVolumetricFogOptions(VolumetricFogOptions& result) const = 0; + virtual void GetVolumetricFogOptions(const RenderView& view, VolumetricFogOptions& result) const = 0; /// /// Gets the exponential height fog data. diff --git a/Source/Engine/Renderer/RenderList.cpp b/Source/Engine/Renderer/RenderList.cpp index 5fa1f4672..d64f9607b 100644 --- a/Source/Engine/Renderer/RenderList.cpp +++ b/Source/Engine/Renderer/RenderList.cpp @@ -228,7 +228,7 @@ void RenderFogData::Init(const RenderView& view, IFogRenderer* renderer) { Renderer = renderer; renderer->GetExponentialHeightFogData(view, ExponentialHeightFogData); - renderer->GetVolumetricFogOptions(VolumetricFog); + renderer->GetVolumetricFogOptions(view, VolumetricFog); if (!VolumetricFog.UseVolumetricFog()) { ExponentialHeightFogData.VolumetricFogMaxDistance = -1;