Fix height fog density calculation with large worlds

#3443
This commit is contained in:
2026-09-22 23:39:23 +02:00
parent f171cb42a4
commit cc51ae4562
4 changed files with 7 additions and 6 deletions
@@ -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;
@@ -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;
+2 -1
View File
@@ -80,8 +80,9 @@ public:
/// <summary>
/// Gets the volumetric fog options.
/// </summary>
/// <param name="view">The rendering view.</param>
/// <param name="result">The result.</param>
virtual void GetVolumetricFogOptions(VolumetricFogOptions& result) const = 0;
virtual void GetVolumetricFogOptions(const RenderView& view, VolumetricFogOptions& result) const = 0;
/// <summary>
/// Gets the exponential height fog data.
+1 -1
View File
@@ -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;