Skip to content

Commit

Permalink
Default zero mat/amb alpha so bloom does not get overpowered
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Nov 17, 2019
1 parent 6e2bf5b commit 37c4627
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Core/Render/CGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ CGraphics::SLightBlock CGraphics::sLightBlock;

CGraphics::ELightingMode CGraphics::sLightMode;
uint32 CGraphics::sNumLights;
const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 0.5f);
CColor CGraphics::sAreaAmbientColor = CColor::skBlack;
const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 0.0f);
CColor CGraphics::sAreaAmbientColor = CColor::skTransparentBlack;
float CGraphics::sWorldLightMultiplier;
CLight CGraphics::sDefaultDirectionalLights[3] = {
CLight::BuildDirectional(CVector3f(0), CVector3f (0.f, -0.866025f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 0.3f)),
Expand Down Expand Up @@ -171,7 +171,7 @@ void CGraphics::SetDefaultLighting()
UpdateLightBlock();

sVertexBlock.COLOR0_Amb = CColor::skGray;
sVertexBlock.COLOR0_Amb.A = 0.5f;
sVertexBlock.COLOR0_Mat = CColor::skWhite;
UpdateVertexBlock();
}

Expand All @@ -182,7 +182,7 @@ void CGraphics::SetupAmbientColor()
else if (sLightMode == ELightingMode::Basic)
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor;
else
sVertexBlock.COLOR0_Amb = CColor::skWhite;
sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite;
}

void CGraphics::SetIdentityMVP()
Expand Down
3 changes: 2 additions & 1 deletion src/Core/Render/CRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ void CRenderer::RenderSky(CModel *pSkyboxModel, const SViewInfo& rkViewInfo)
glEnable(GL_CULL_FACE);

CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite;
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skTransparentWhite;
CGraphics::sPixelBlock.SetAllTevColors(CColor::skWhite);
CGraphics::sPixelBlock.TintColor = CColor::skWhite;
CGraphics::sNumLights = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Resource/CMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
CGraphics::sPixelBlock.TevColor[iTev] = mTevColors[iTev];

// Set color channels
// COLOR0_Amb is initialized by the node instead of by the material
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite;
// COLOR0_Amb,Mat is initialized by the node instead of by the material

// Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise)
if ((mOptions & EMaterialOption::DepthWrite) || (Options & ERenderOption::NoAlpha)) glDepthMask(GL_TRUE);
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Resource/Factory/CMaterialLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ bool CMaterialLoader::SetupIncandecenceStage(STevTracker& Tracker, CMaterial* pM
auto pPass = std::make_unique<CMaterialPass>(pMat);
SetMP3IntermediateIntoMaterialPass(pPass.get(), *IntermediateInca);

/* KColor is set as the INCA mod color in game */
pPass->SetKColorSel(kKonstOne);
pPass->SetColorInputs(kZeroRGB, kKonstRGB, kTextureRGB, kPrevRGB);
pPass->SetColorOutput(kPrevReg);
Expand Down Expand Up @@ -1036,6 +1037,7 @@ bool CMaterialLoader::SetupIncandecenceStageNoBloom(STevTracker& Tracker, CMater
auto pPass = std::make_unique<CMaterialPass>(pMat);
SetMP3IntermediateIntoMaterialPass(pPass.get(), *IntermediateInca);

/* KColor is set as the INCA mod color in game */
pPass->SetKColorSel(kKonstOne);
pPass->SetColorInputs(kZeroRGB, kKonstRGB, kTextureRGB, kPrevRGB);
pPass->SetAlphaInputs(kZeroAlpha, kZeroAlpha, kZeroAlpha, kPrevAlpha);
Expand Down Expand Up @@ -1073,6 +1075,7 @@ bool CMaterialLoader::SetupStartingIncandecenceStage(STevTracker& Tracker, CMate
auto pPass = std::make_unique<CMaterialPass>(pMat);
SetMP3IntermediateIntoMaterialPass(pPass.get(), *IntermediateInca);

/* KColor is set as the INCA mod color in game */
pPass->SetKColorSel(kKonstOne);
pPass->SetColorInputs(kZeroRGB, kTextureRGB, kKonstRGB, kZeroRGB);
if (IntermediateInca->mSettings & EPassSettings::BloomContribution)
Expand Down
1 change: 1 addition & 0 deletions src/Core/Scene/CCharacterNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void CCharacterNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCom
CGraphics::SetDefaultLighting();
CGraphics::UpdateLightBlock();
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skTransparentWhite;
CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
CGraphics::sPixelBlock.SetAllTevColors(CColor::skWhite);
CGraphics::sPixelBlock.TintColor = TintColor(rkViewInfo);
Expand Down
5 changes: 4 additions & 1 deletion src/Core/Scene/CModelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand
CGraphics::SetDefaultLighting();
CGraphics::UpdateLightBlock();
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skTransparentWhite;
CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
CGraphics::sPixelBlock.SetAllTevColors(CColor::skWhite);
}
Expand All @@ -84,9 +85,11 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand
{
LoadLights(rkViewInfo);
if (CGraphics::sLightMode == CGraphics::ELightingMode::None)
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite;
}

CGraphics::sVertexBlock.COLOR0_Mat = CColor::skTransparentWhite;

float Mul = CGraphics::sWorldLightMultiplier;
CGraphics::sPixelBlock.SetAllTevColors(CColor(Mul,Mul,Mul));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Scene/CScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void CScene::SetActiveArea(CWorld *pWorld, CGameArea *pArea)
}

uint32 NumLightLayers = mpArea->NumLightLayers();
CGraphics::sAreaAmbientColor = CColor::skBlack;
CGraphics::sAreaAmbientColor = CColor::skTransparentBlack;

for (uint32 iLyr = 0; iLyr < NumLightLayers; iLyr++)
{
Expand Down
8 changes: 5 additions & 3 deletions src/Core/Scene/CSceneNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void CSceneNode::LoadModelMatrix()
void CSceneNode::BuildLightList(CGameArea *pArea)
{
mLightCount = 0;
mAmbientColor = CColor::skBlack;
mAmbientColor = CColor::skTransparentBlack;

uint32 Index = mLightLayerIndex;
if ((pArea->NumLightLayers() <= Index) || (pArea->NumLights(Index) == 0)) Index = 0;
Expand All @@ -152,7 +152,7 @@ void CSceneNode::BuildLightList(CGameArea *pArea)

// Default ambient color to white if there are no lights on the selected layer
uint32 NumLights = pArea->NumLights(Index);
if (NumLights == 0) mAmbientColor = CColor::skWhite;
if (NumLights == 0) mAmbientColor = CColor::skTransparentWhite;

for (uint32 iLight = 0; iLight < NumLights; iLight++)
{
Expand Down Expand Up @@ -192,7 +192,7 @@ void CSceneNode::LoadLights(const SViewInfo& rkViewInfo)
{
case CGraphics::ELightingMode::None:
// No lighting: full white ambient, no dynamic lights
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite;
break;

case CGraphics::ELightingMode::Basic:
Expand All @@ -210,6 +210,8 @@ void CSceneNode::LoadLights(const SViewInfo& rkViewInfo)
break;
}

CGraphics::sVertexBlock.COLOR0_Mat = CColor::skTransparentWhite;

CGraphics::sPixelBlock.LightmapMultiplier = (Mode == CGraphics::ELightingMode::World ? 1.f : 0.f);
CGraphics::UpdateLightBlock();
}
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Scene/CScriptNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void CScriptNode::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCo
{
CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentBlack;
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skTransparentWhite;
CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
CGraphics::UpdateLightBlock();
}
Expand All @@ -192,6 +193,7 @@ void CScriptNode::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCo
{
CGraphics::SetDefaultLighting();
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skTransparentWhite;
}

else
Expand Down
6 changes: 4 additions & 2 deletions src/Core/Scene/CStaticNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderComman
if (IsLightingEnabled)
{
CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skWhite : CColor::skTransparentBlack;
CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skTransparentWhite : CColor::skTransparentBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.0f;
CGraphics::UpdateLightBlock();
}
Expand All @@ -71,9 +71,11 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderComman
{
LoadLights(rkViewInfo);
if (CGraphics::sLightMode == CGraphics::ELightingMode::None || UseWhiteAmbient)
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite;
}

CGraphics::sVertexBlock.COLOR0_Mat = CColor::skBlack;

float Mul = CGraphics::sWorldLightMultiplier;
CGraphics::sPixelBlock.SetAllTevColors(CColor(Mul,Mul,Mul));
CGraphics::sPixelBlock.TintColor = TintColor(rkViewInfo);
Expand Down

0 comments on commit 37c4627

Please sign in to comment.