From 93ff138ba9c6d4025315cafc901f77c9b737b7c0 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 17 Oct 2018 22:28:57 -1000 Subject: [PATCH] 16-bit fog volume LUT; fog is now 256x sexier --- Runtime/Graphics/CBooRenderer.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index ffbb03ea2..f7a48941c 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -532,7 +532,7 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: zeus::CVector2i vpMax(0, 0); zeus::CVector2i vpMin(g_Viewport.x8_width, g_Viewport.xc_height); - bool b1 = true; + bool vpInvalid = true; for (int i=0 ; i<20 ; ++i) { zeus::CVector3f overW; @@ -569,7 +569,7 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: vpMin.x = std::min(vpMin.x, vpX); vpMax.y = std::max(vpMax.y, vpY); vpMin.y = std::min(vpMin.y, vpY); - b1 = false; + vpInvalid = false; } zeus::CVector2i vpSize = {vpMax.x - vpMin.x, vpMax.y - vpMin.y}; @@ -588,6 +588,9 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: rect.x10_height = g_Viewport.xc_height; //CGraphics::SetScissor(vpMin.x, vpMin.y, vpSize.x, vpSize.y); + zeus::CAABox marginAABB((CGraphics::g_GXModelView * aabb.min) - 1.f, + (CGraphics::g_GXModelView * aabb.max) + 1.f); + bool camInModel = marginAABB.pointInside(CGraphics::g_ViewMatrix.origin) && (model || sModel); CFogVolumePlaneShader* fvs; if (!model && !sModel) @@ -602,12 +605,14 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: } RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 0, fvs); - RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1, fvs); + if (camInModel) + RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 1, fvs); CGraphics::ResolveSpareDepth(rect, 0); RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 2, fvs); - RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3, fvs); + if (camInModel) + RenderFogVolumeModel(aabb, model, CGraphics::g_GXModelMatrix, CGraphics::g_ViewMatrix, sModel, 3, fvs); CGraphics::ResolveSpareDepth(rect, 1); @@ -615,14 +620,15 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus:: m_fogVolumeFilters.insert(m_fogVolumeFilters.end(), CFogVolumeFilter()) : m_nextFogVolumeFilter++; fvf->draw2WayPass(color); - fvf->draw1WayPass(color); + if (camInModel) + fvf->draw1WayPass(color); //CGraphics::SetScissor(g_Viewport.x0_left, g_Viewport.x4_top, g_Viewport.x8_width, g_Viewport.xc_height); } void CBooRenderer::GenerateFogVolumeRampTex(boo::IGraphicsDataFactory::Context& ctx) { - u8 data[FOGVOL_RAMP_RES][FOGVOL_RAMP_RES] = {}; + u16 data[FOGVOL_RAMP_RES][FOGVOL_RAMP_RES] = {}; for (int y=0 ; y