Default zero mat/amb alpha so bloom does not get overpowered

This commit is contained in:
Jack Andersen 2019-11-17 12:03:09 -10:00
parent 6e2bf5be83
commit 37c462725c
10 changed files with 27 additions and 14 deletions

View File

@ -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)),
@ -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();
}
@ -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()

View File

@ -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;

View File

@ -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);

View File

@ -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);
@ -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);
@ -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)

View File

@ -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);

View File

@ -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);
}
@ -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));
}

View File

@ -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++)
{

View File

@ -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;
@ -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++)
{
@ -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:
@ -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();
}

View File

@ -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();
}
@ -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

View File

@ -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();
}
@ -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);