Merge pull request #119 from rtw1x1/main

fix: SpeedTree fog fix
This commit is contained in:
rtw1x1
2026-02-19 18:52:59 +00:00
committed by GitHub
5 changed files with 16 additions and 5 deletions

View File

@@ -270,6 +270,8 @@ void CSkyBox::SetCloudTexture(const char * c_szFileName)
m_FaceCloud.m_strfacename = c_szFileName; m_FaceCloud.m_strfacename = c_szFileName;
CGraphicImageInstance * pGraphicImageInstance = GenerateTexture(c_szFileName); CGraphicImageInstance * pGraphicImageInstance = GenerateTexture(c_szFileName);
if (!pGraphicImageInstance)
TraceError("CSkyBox::SetCloudTexture - Failed to load cloud texture: %s", c_szFileName);
m_GraphicImageInstanceMap.insert(TGraphicImageInstanceMap::value_type(m_FaceCloud.m_strfacename, pGraphicImageInstance)); m_GraphicImageInstanceMap.insert(TGraphicImageInstanceMap::value_type(m_FaceCloud.m_strfacename, pGraphicImageInstance));
// 이거 안쓰는거 같은데요? [cronan] // 이거 안쓰는거 같은데요? [cronan]
@@ -868,6 +870,9 @@ void CSkyBox::Render()
void CSkyBox::RenderCloud() void CSkyBox::RenderCloud()
{ {
if (m_FaceCloud.m_strfacename.empty())
return;
CGraphicImageInstance * pCloudGraphicImageInstance = m_GraphicImageInstanceMap[m_FaceCloud.m_strfacename]; CGraphicImageInstance * pCloudGraphicImageInstance = m_GraphicImageInstanceMap[m_FaceCloud.m_strfacename];
if (!pCloudGraphicImageInstance) if (!pCloudGraphicImageInstance)
return; return;

View File

@@ -281,11 +281,15 @@ void CMapManager::BeginEnvironment()
if (mc_pcurEnvironmentData->bDensityFog && mc_pcurEnvironmentData->bFogLevel != 0) 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()]; float fDensity = mc_pcurEnvironmentData->bFogLevel * fFogDensityLevel[CPythonSystem::Instance().GetFogLevel()];
STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP); // pixel fog STATEMANAGER.SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP); // pixel fog
STATEMANAGER.SetRenderState(D3DRS_FOGDENSITY, *((DWORD *) &fDensity)); // vertex 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 // MR-14: -- END OF -- Fog update by Alaric
else else

View File

@@ -240,10 +240,6 @@ void CMapOutdoor::OnBeginEnvironment()
return; return;
CSpeedTreeForestDirectX& rkForest=CSpeedTreeForestDirectX::Instance(); CSpeedTreeForestDirectX& rkForest=CSpeedTreeForestDirectX::Instance();
rkForest.SetFog(
mc_pEnvironmentData->GetFogNearDistance(),
mc_pEnvironmentData->GetFogFarDistance()
);
const D3DLIGHT9& c_rkLight = mc_pEnvironmentData->DirLights[ENV_DIRLIGHT_CHARACTER]; const D3DLIGHT9& c_rkLight = mc_pEnvironmentData->DirLights[ENV_DIRLIGHT_CHARACTER];
rkForest.SetLight( 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_far(fFogFarDistance+1600.0f, 0);
std::pair<float, long> fog_near(fFogNearDistance-3200.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 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); 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_far(kTPRS.m_fFogFarDistance+800.0f, 0);
std::pair<float, long> fog_near(kTPRS.m_fFogNearDistance-3200.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 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); std::vector<std::pair<float ,long> >::iterator near_it = std::upper_bound(m_PatchVector.begin(),m_PatchVector.end(),fog_near);