2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-07-09 06:05:51 +00:00

Properly-scaled fog rendering

This commit is contained in:
Jack Andersen 2016-08-08 08:23:12 -10:00
parent a910ddd912
commit e7a339344d
5 changed files with 9 additions and 12 deletions

View File

@ -91,8 +91,8 @@ void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ)
boo::SWindowRect windowRect = m_vm.m_mainWindow->getWindowFrame(); boo::SWindowRect windowRect = m_vm.m_mainWindow->getWindowFrame();
float aspect = windowRect.size[0] / float(windowRect.size[1]); float aspect = windowRect.size[0] / float(windowRect.size[1]);
CGraphics::SetPerspective(55.0, aspect, 1.f, 15.f); CGraphics::SetPerspective(55.0, aspect, 0.1f, 1000.f);
CGraphics::SetFog(ERglFogMode::PerspExp, 10.f, 15.f, zeus::CColor::skRed); CGraphics::SetFog(ERglFogMode::PerspExp, 7.f, 15.f, zeus::CColor::skRed);
//CGraphics::SetFog(ERglFogMode::PerspExp, 10.f + std::sin(m_theta) * 5.f, 15.f + std::sin(m_theta) * 5.f, zeus::CColor::skRed); //CGraphics::SetFog(ERglFogMode::PerspExp, 10.f + std::sin(m_theta) * 5.f, 15.f + std::sin(m_theta) * 5.f, zeus::CColor::skRed);
zeus::CFrustum frustum; zeus::CFrustum frustum;
frustum.updatePlanes(CGraphics::g_GXModelView, zeus::SProjPersp(55.0, aspect, 0.1f, 1000.f)); frustum.updatePlanes(CGraphics::g_GXModelView, zeus::SProjPersp(55.0, aspect, 0.1f, 1000.f));

View File

@ -71,16 +71,14 @@ void CGraphics::SetFog(ERglFogMode mode, float startz, float endz, const zeus::C
{ {
if (mode == ERglFogMode::None) if (mode == ERglFogMode::None)
{ {
g_Fog.m_start = 1.f; g_Fog.m_start = 4096.f;
} }
else else
{ {
float projRange = g_Proj.x18_far - g_Proj.x14_near;
float userRange = endz - startz; float userRange = endz - startz;
g_Fog.m_color = color; g_Fog.m_color = color;
g_Fog.m_start = (startz - g_Proj.x14_near) / projRange; g_Fog.m_start = startz;
g_Fog.m_rangeScale = projRange / userRange; g_Fog.m_rangeScale = 1.f / userRange;
} }
} }

View File

@ -188,8 +188,8 @@ public:
struct CFogState struct CFogState
{ {
zeus::CColor m_color; zeus::CColor m_color;
float m_rangeScale = 4096.f; float m_rangeScale = 1.f;
float m_start = 1.f; float m_start = 4096.f;
}; };
static CProjectionState g_Proj; static CProjectionState g_Proj;

View File

@ -54,8 +54,7 @@ static const char* LightingGLSL =
static const char* MainPostGLSL = static const char* MainPostGLSL =
"vec4 MainPostFunc(vec4 colorIn)\n" "vec4 MainPostFunc(vec4 colorIn)\n"
"{\n" "{\n"
" float fogZ = (vtf.mvPos.z - fog.start) * fog.rangeScale;\n" " float fogZ = (-vtf.mvPos.z - fog.start) * fog.rangeScale;\n"
" return vec4(fogZ, fogZ, fogZ, 1.0);\n"
" return mix(fog.color, colorIn, clamp(exp2(-8.0 * fogZ), 0.0, 1.0));\n" " return mix(fog.color, colorIn, clamp(exp2(-8.0 * fogZ), 0.0, 1.0));\n"
"}\n" "}\n"
"\n"; "\n";

2
hecl

@ -1 +1 @@
Subproject commit 200706dc92e9a458b18da295eff60f9711964556 Subproject commit 16eaa99c0af151404fc431f9adc76fc4739e86fc