diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index ee5bb6a..9b9b640 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -12,9 +12,10 @@ namespace New3D { -CNew3D::CNew3D(const Util::Config::Node &config) +CNew3D::CNew3D(const Util::Config::Node &config, std::string gameName) : m_r3dShader(config), - m_r3dScrollFog(config) + m_r3dScrollFog(config), + m_gameName(gameName) { m_cullingRAMLo = nullptr; m_cullingRAMHi = nullptr; @@ -781,8 +782,16 @@ void CNew3D::RenderViewport(UINT32 addr) vp->lightingParams[3] = std::max(0.f, std::min(*(float *)&vpnode[0x07], 1.0f)); // sun intensity (clamp to 0-1) vp->lightingParams[4] = (float)((vpnode[0x24] >> 8) & 0xFF) * (1.0f / 255.0f); // ambient intensity vp->lightingParams[5] = 0.0; // reserved + + // this is a hack because we haven't yet found in memory where these are set + // these two games use a slightly different light model to the test of the games + if (m_gameName == "lamachin" || m_gameName == "dayto2pe") { + vp->sunClamp = false; + } + else { + vp->sunClamp = true; + } - vp->sunClamp = 1; // TODO work out how this is passed, doesn't appear to be in the viewport .. or in the model data vp->intensityClamp = (m_step == 0x10); // just step 1.0 ? vp->hardwareStep = m_step; diff --git a/Src/Graphics/New3D/New3D.h b/Src/Graphics/New3D/New3D.h index 81983d0..bb9cb14 100644 --- a/Src/Graphics/New3D/New3D.h +++ b/Src/Graphics/New3D/New3D.h @@ -150,7 +150,7 @@ public: * Parameters: * config Run-time configuration. */ - CNew3D(const Util::Config::Node &config); + CNew3D(const Util::Config::Node &config, std::string gameName); ~CNew3D(void); private: @@ -191,6 +191,9 @@ private: * Data */ + // Misc + std::string m_gameName; + // Stepping int m_step; int m_offset; // offset to subtract for words 3 and higher of culling nodes diff --git a/Src/Graphics/New3D/R3DShader.cpp b/Src/Graphics/New3D/R3DShader.cpp index 177fb4c..d469e40 100644 --- a/Src/Graphics/New3D/R3DShader.cpp +++ b/Src/Graphics/New3D/R3DShader.cpp @@ -16,6 +16,7 @@ uniform int hardwareStep; uniform vec3 lighting[2]; // also used in fragment shader uniform bool lightEnabled; // also used in fragment shader uniform bool fixedShading; // also used in fragment shader +uniform bool sunClamp; // also used in fragment shader // attributes attribute vec3 inVertex; @@ -36,16 +37,17 @@ vec4 GetVertexColour() vec4 polyColour = inColour; if(fixedShading) { - if(hardwareStep==0x15) { - if(lightEnabled) { - polyColour.rgb *= (inFixedShade + lighting[1].y); // per vertex brightness + ambient - } - else { - polyColour.rgb += lighting[1].y; // this is similar to above but basically a flat shaded version. So poly colour + ambient - } + + float lightAmbient = lighting[1].y; + if(!sunClamp) { + lightAmbient = 0; // guess work here. La machine guns is the only game to use this light model. Black is black in this game, it's not effected by ambient + } + + if(lightEnabled) { + polyColour.rgb *= (inFixedShade + lightAmbient); // per vertex brightness + ambient } else { - polyColour.rgb *= inFixedShade; //todo work out what ambient does. Probably a min clamp or 1-min clamp for signed values + polyColour.rgb += lightAmbient; // this is similar to above but basically a flat shaded version. So poly colour + ambient } } diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp index d93517c..feccc43 100644 --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -829,7 +829,7 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In // Initialize the renderers CRender2D *Render2D = new CRender2D(s_runtime_config); - IRender3D *Render3D = s_runtime_config["New3DEngine"].ValueAs() ? ((IRender3D *) new New3D::CNew3D(s_runtime_config)) : ((IRender3D *) new Legacy3D::CLegacy3D(s_runtime_config)); + IRender3D *Render3D = s_runtime_config["New3DEngine"].ValueAs() ? ((IRender3D *) new New3D::CNew3D(s_runtime_config, Model3->GetGame().name)) : ((IRender3D *) new Legacy3D::CLegacy3D(s_runtime_config)); if (OKAY != Render2D->Init(xOffset, yOffset, xRes, yRes, totalXRes, totalYRes)) goto QuitError; if (OKAY != Render3D->Init(xOffset, yOffset, xRes, yRes, totalXRes, totalYRes)) @@ -971,7 +971,7 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In // Recreate renderers and attach to the emulator Render2D = new CRender2D(s_runtime_config); - Render3D = s_runtime_config["New3DEngine"].ValueAs() ? ((IRender3D *) new New3D::CNew3D(s_runtime_config)) : ((IRender3D *) new Legacy3D::CLegacy3D(s_runtime_config)); + Render3D = s_runtime_config["New3DEngine"].ValueAs() ? ((IRender3D *) new New3D::CNew3D(s_runtime_config, Model3->GetGame().name)) : ((IRender3D *) new Legacy3D::CLegacy3D(s_runtime_config)); if (OKAY != Render2D->Init(xOffset, yOffset, xRes, yRes, totalXRes, totalYRes)) goto QuitError; if (OKAY != Render3D->Init(xOffset, yOffset, xRes, yRes, totalXRes, totalYRes))