Added lightmap multiplier to allow applying basic lighting on world geometry
This commit is contained in:
parent
444382c1a9
commit
b768473b44
|
@ -329,6 +329,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat)
|
||||||
<< " vec4 KonstColors[4];\n"
|
<< " vec4 KonstColors[4];\n"
|
||||||
<< " vec4 TevColor;\n"
|
<< " vec4 TevColor;\n"
|
||||||
<< " vec4 TintColor;\n"
|
<< " vec4 TintColor;\n"
|
||||||
|
<< " float LightmapMultiplier;\n"
|
||||||
<< "};\n\n";
|
<< "};\n\n";
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
||||||
|
@ -374,6 +375,11 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat)
|
||||||
else if (PassType == "BLOL")
|
else if (PassType == "BLOL")
|
||||||
ShaderCode << ".rgbg";
|
ShaderCode << ".rgbg";
|
||||||
|
|
||||||
|
// Apply lightmap multiplier
|
||||||
|
if ( (PassType == "DIFF") ||
|
||||||
|
(PassType == "CUST" && (Mat.Options() & CMaterial::eLightmap) && iPass == 0) )
|
||||||
|
ShaderCode << " * LightmapMultiplier";
|
||||||
|
|
||||||
ShaderCode << ";\n";
|
ShaderCode << ";\n";
|
||||||
|
|
||||||
ShaderCode << " Konst = vec4(" << gkKonstColor[pPass->KColorSel()] << ", " << gkKonstAlpha[pPass->KAlphaSel()] << ");\n";
|
ShaderCode << " Konst = vec4(" << gkKonstColor[pPass->KColorSel()] << ", " << gkKonstAlpha[pPass->KAlphaSel()] << ");\n";
|
||||||
|
@ -398,7 +404,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat)
|
||||||
<< ".rgb = ";
|
<< ".rgb = ";
|
||||||
|
|
||||||
ShaderCode << "clamp(vec3(TevInD.rgb + ((1.0 - TevInC.rgb) * TevInA.rgb + TevInC.rgb * TevInB.rgb))";
|
ShaderCode << "clamp(vec3(TevInD.rgb + ((1.0 - TevInC.rgb) * TevInA.rgb + TevInC.rgb * TevInB.rgb))";
|
||||||
if ((PassType == "CLR ") && (Lightmap)) ShaderCode << "* 2.0"; // Apply tevscale 2.0 on the color pass if lightmap is present
|
if ((PassType == "CLR ") && (Lightmap)) ShaderCode << "* (2.0 - (1.0 - LightmapMultiplier))"; // Apply tevscale 2.0 on the color pass if lightmap is present. Scale so we don't apply if lightmaps are off.
|
||||||
ShaderCode << ", vec3(0, 0, 0), vec3(1.0, 1.0, 1.0));\n";
|
ShaderCode << ", vec3(0, 0, 0), vec3(1.0, 1.0, 1.0));\n";
|
||||||
|
|
||||||
ShaderCode << " // Alpha Combine\n"
|
ShaderCode << " // Alpha Combine\n"
|
||||||
|
|
|
@ -166,8 +166,10 @@ void CGraphics::SetupAmbientColor()
|
||||||
{
|
{
|
||||||
if (sLightMode == eWorldLighting)
|
if (sLightMode == eWorldLighting)
|
||||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor * sWorldLightMultiplier;
|
sVertexBlock.COLOR0_Amb = sAreaAmbientColor * sWorldLightMultiplier;
|
||||||
else
|
else if (sLightMode == eBasicLighting)
|
||||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor;
|
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor;
|
||||||
|
else
|
||||||
|
sVertexBlock.COLOR0_Amb = CColor::skWhite;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::SetIdentityMVP()
|
void CGraphics::SetIdentityMVP()
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
CColor Konst[4];
|
CColor Konst[4];
|
||||||
CColor TevColor;
|
CColor TevColor;
|
||||||
CColor TintColor;
|
CColor TintColor;
|
||||||
|
float LightmapMultiplier;
|
||||||
};
|
};
|
||||||
static SPixelBlock sPixelBlock;
|
static SPixelBlock sPixelBlock;
|
||||||
|
|
||||||
|
|
|
@ -405,15 +405,16 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
|
||||||
// Color Map (Diffuse)
|
// Color Map (Diffuse)
|
||||||
if (Type == "CLR ")
|
if (Type == "CLR ")
|
||||||
{
|
{
|
||||||
|
pPass->SetRasSel(eRasColor0A0);
|
||||||
|
|
||||||
if (Lightmap)
|
if (Lightmap)
|
||||||
{
|
{
|
||||||
pPass->SetColorInputs(eZeroRGB, eColor0RGB, eTextureRGB, ePrevRGB);
|
pPass->SetColorInputs(eZeroRGB, eColor0RGB, eTextureRGB, eZeroRGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pPass->SetColorInputs(eZeroRGB, eRasRGB, eTextureRGB, ePrevRGB);
|
pPass->SetColorInputs(eZeroRGB, eRasRGB, eTextureRGB, eZeroRGB);
|
||||||
pPass->SetRasSel(eRasColor0A0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -439,7 +440,7 @@ void CMaterialLoader::CreateCorruptionPasses(CMaterial *pMat)
|
||||||
// Lightmap
|
// Lightmap
|
||||||
else if (Type == "DIFF")
|
else if (Type == "DIFF")
|
||||||
{
|
{
|
||||||
pPass->SetColorInputs(eZeroRGB, eKonstRGB, eTextureRGB, eZeroRGB);
|
pPass->SetColorInputs(eZeroRGB, eKonstRGB, eTextureRGB, eRasRGB);
|
||||||
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eKonstAlpha);
|
pPass->SetAlphaInputs(eZeroAlpha, eZeroAlpha, eZeroAlpha, eKonstAlpha);
|
||||||
pPass->SetColorOutput(eColor0Reg);
|
pPass->SetColorOutput(eColor0Reg);
|
||||||
pPass->SetAlphaOutput(eColor0Reg);
|
pPass->SetAlphaOutput(eColor0Reg);
|
||||||
|
|
|
@ -51,6 +51,7 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInf
|
||||||
|
|
||||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||||
|
CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
|
||||||
LoadModelMatrix();
|
LoadModelMatrix();
|
||||||
|
|
||||||
if (ComponentIndex < 0)
|
if (ComponentIndex < 0)
|
||||||
|
|
|
@ -187,8 +187,8 @@ void CSceneNode::LoadLights(const SViewInfo& ViewInfo)
|
||||||
switch (Mode)
|
switch (Mode)
|
||||||
{
|
{
|
||||||
case CGraphics::eNoLighting:
|
case CGraphics::eNoLighting:
|
||||||
// No lighting: default ambient color, no dynamic lights
|
// No lighting: full white ambient, no dynamic lights
|
||||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CGraphics::eBasicLighting:
|
case CGraphics::eBasicLighting:
|
||||||
|
@ -206,6 +206,7 @@ void CSceneNode::LoadLights(const SViewInfo& ViewInfo)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGraphics::sPixelBlock.LightmapMultiplier = (Mode == CGraphics::eWorldLighting ? 1.f : 0.f);
|
||||||
CGraphics::UpdateLightBlock();
|
CGraphics::UpdateLightBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,25 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn
|
||||||
if (!mpModel) return;
|
if (!mpModel) return;
|
||||||
|
|
||||||
bool IsLightingEnabled = CGraphics::sLightMode == CGraphics::eWorldLighting || ViewInfo.GameMode;
|
bool IsLightingEnabled = CGraphics::sLightMode == CGraphics::eWorldLighting || ViewInfo.GameMode;
|
||||||
CGraphics::sVertexBlock.COLOR0_Amb = (IsLightingEnabled ? CColor::skBlack : CColor::skWhite);
|
|
||||||
|
if (IsLightingEnabled)
|
||||||
|
{
|
||||||
|
CGraphics::sNumLights = 0;
|
||||||
|
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack;
|
||||||
|
CGraphics::sPixelBlock.LightmapMultiplier = 1.0f;
|
||||||
|
CGraphics::UpdateLightBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadLights(ViewInfo);
|
||||||
|
if (CGraphics::sLightMode == CGraphics::eNoLighting)
|
||||||
|
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
|
||||||
|
}
|
||||||
|
|
||||||
float Mul = CGraphics::sWorldLightMultiplier;
|
float Mul = CGraphics::sWorldLightMultiplier;
|
||||||
CGraphics::sPixelBlock.TevColor = CColor(Mul,Mul,Mul);
|
CGraphics::sPixelBlock.TevColor = CColor(Mul,Mul,Mul);
|
||||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||||
CGraphics::sNumLights = 0;
|
|
||||||
CGraphics::UpdateLightBlock();
|
|
||||||
LoadModelMatrix();
|
LoadModelMatrix();
|
||||||
|
|
||||||
if (ComponentIndex < 0)
|
if (ComponentIndex < 0)
|
||||||
|
|
Loading…
Reference in New Issue