fix: SpeedTree fog fix

This commit is contained in:
rtw1x1
2026-02-19 18:51:43 +00:00
parent 7ef5077b97
commit 3f8a664c2c
5 changed files with 16 additions and 5 deletions

View File

@@ -281,11 +281,15 @@ void CMapManager::BeginEnvironment()
if (mc_pcurEnvironmentData->bDensityFog && mc_pcurEnvironmentData->bFogLevel != 0)
{
const float fFogDensityLevel[3] = { 0.000020f, 0.000010f, 0.000005f };
const float fFogDensityLevel[3] = { 0.000006f, 0.000004f, 0.000002f };
float fDensity = mc_pcurEnvironmentData->bFogLevel * fFogDensityLevel[CPythonSystem::Instance().GetFogLevel()];
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP); // pixel fog
STATEMANAGER.SetRenderState(D3DRS_FOGDENSITY, *((DWORD *) &fDensity)); // vertex fog
float fApproxFogFar = 2.3f / fDensity;
CSpeedTreeForestDirectX& rkForest = CSpeedTreeForestDirectX::Instance();
rkForest.SetFog(0.0f, fApproxFogFar);
}
// MR-14: -- END OF -- Fog update by Alaric
else

View File

@@ -240,10 +240,6 @@ void CMapOutdoor::OnBeginEnvironment()
return;
CSpeedTreeForestDirectX& rkForest=CSpeedTreeForestDirectX::Instance();
rkForest.SetFog(
mc_pEnvironmentData->GetFogNearDistance(),
mc_pEnvironmentData->GetFogFarDistance()
);
const D3DLIGHT9& c_rkLight = mc_pEnvironmentData->DirLights[ENV_DIRLIGHT_CHARACTER];
rkForest.SetLight(

View File

@@ -75,6 +75,9 @@ void CMapOutdoor::__RenderTerrain_RenderHardwareTransformPatch()
std::pair<float, long> fog_far(fFogFarDistance+1600.0f, 0);
std::pair<float, long> fog_near(fFogNearDistance-3200.0f, 0);
if (mc_pEnvironmentData && mc_pEnvironmentData->bDensityFog)
fog_far.first = 1e10f;
std::vector<std::pair<float ,long> >::iterator far_it = std::upper_bound(m_PatchVector.begin(),m_PatchVector.end(),fog_far);
std::vector<std::pair<float ,long> >::iterator near_it = std::upper_bound(m_PatchVector.begin(),m_PatchVector.end(),fog_near);

View File

@@ -30,6 +30,9 @@ void CMapOutdoor::__RenderTerrain_RenderSoftwareTransformPatch()
std::pair<float, long> fog_far(kTPRS.m_fFogFarDistance+800.0f, 0);
std::pair<float, long> fog_near(kTPRS.m_fFogNearDistance-3200.0f, 0);
if (mc_pEnvironmentData && mc_pEnvironmentData->bDensityFog)
fog_far.first = 1e10f;
std::vector<std::pair<float ,long> >::iterator far_it = std::upper_bound(m_PatchVector.begin(),m_PatchVector.end(),fog_far);
std::vector<std::pair<float ,long> >::iterator near_it = std::upper_bound(m_PatchVector.begin(),m_PatchVector.end(),fog_near);