Use non-1.0 alpha component for default lighting

This commit is contained in:
Jack Andersen 2019-11-07 14:54:35 -10:00
parent 6e3b23ec50
commit 55c4a5818e
6 changed files with 17 additions and 17 deletions

View File

@ -463,12 +463,6 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
if (pPass->Texture()) if (pPass->Texture())
ShaderCode << " Tex = texture(Texture" << iPass << ", TevCoord)"; ShaderCode << " Tex = texture(Texture" << iPass << ", TevCoord)";
// A couple pass types require special swizzles to access different texture color channels as alpha
if ((PassType == "TRAN") || (PassType == "INCA") || (PassType == "BLOI"))
ShaderCode << ".rgbr";
else if (PassType == "BLOL")
ShaderCode << ".rgbg";
// Apply lightmap multiplier // Apply lightmap multiplier
bool UseLightmapMultiplier = (PassType == "DIFF") || bool UseLightmapMultiplier = (PassType == "DIFF") ||
(PassType == "CUST" && (rkMat.Options() & EMaterialOption::Lightmap) && iPass == 0); (PassType == "CUST" && (rkMat.Options() & EMaterialOption::Lightmap) && iPass == 0);

View File

@ -22,13 +22,13 @@ CGraphics::SLightBlock CGraphics::sLightBlock;
CGraphics::ELightingMode CGraphics::sLightMode; CGraphics::ELightingMode CGraphics::sLightMode;
uint32 CGraphics::sNumLights; uint32 CGraphics::sNumLights;
const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 1.f); const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 0.5f);
CColor CGraphics::sAreaAmbientColor = CColor::skBlack; CColor CGraphics::sAreaAmbientColor = CColor::skBlack;
float CGraphics::sWorldLightMultiplier; float CGraphics::sWorldLightMultiplier;
CLight CGraphics::sDefaultDirectionalLights[3] = { CLight CGraphics::sDefaultDirectionalLights[3] = {
CLight::BuildDirectional(CVector3f(0), CVector3f (0.f, -0.866025f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)), CLight::BuildDirectional(CVector3f(0), CVector3f (0.f, -0.866025f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 0.3f)),
CLight::BuildDirectional(CVector3f(0), CVector3f(-0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)), CLight::BuildDirectional(CVector3f(0), CVector3f(-0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 0.3f)),
CLight::BuildDirectional(CVector3f(0), CVector3f( 0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)) CLight::BuildDirectional(CVector3f(0), CVector3f( 0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 0.3f))
}; };
// ************ FUNCTIONS ************ // ************ FUNCTIONS ************
@ -167,9 +167,11 @@ void CGraphics::SetDefaultLighting()
sDefaultDirectionalLights[0].Load(); sDefaultDirectionalLights[0].Load();
sDefaultDirectionalLights[1].Load(); sDefaultDirectionalLights[1].Load();
sDefaultDirectionalLights[2].Load(); sDefaultDirectionalLights[2].Load();
sNumLights = 0;
UpdateLightBlock(); UpdateLightBlock();
sVertexBlock.COLOR0_Amb = CColor::skGray; sVertexBlock.COLOR0_Amb = CColor::skGray;
sVertexBlock.COLOR0_Amb.A = 0.5f;
UpdateVertexBlock(); UpdateVertexBlock();
} }

View File

@ -8,7 +8,8 @@
#include <Common/FileIO.h> #include <Common/FileIO.h>
#include <assimp/scene.h> #include <assimp/scene.h>
enum class EMP3RenderConfig { enum class EMP3RenderConfig
{
NoBloomTransparent, NoBloomTransparent,
NoBloomAdditiveIncandecence, NoBloomAdditiveIncandecence,
FullRenderOpaque, FullRenderOpaque,
@ -30,7 +31,8 @@ enum class EMP3RenderConfig {
XRayOpaque XRayOpaque
}; };
enum class EPASS { enum class EPASS
{
DIFF, DIFF,
RIML, RIML,
BLOL, BLOL,
@ -47,7 +49,8 @@ enum class EPASS {
TOON TOON
}; };
enum class EINT { enum class EINT
{
OPAC, OPAC,
BLOD, BLOD,
BLOI, BLOI,
@ -55,7 +58,8 @@ enum class EINT {
XRBR XRBR
}; };
enum class ECLR { enum class ECLR
{
CLR, CLR,
DIFB DIFB
}; };

View File

@ -75,7 +75,7 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand
if (IsLightingEnabled) if (IsLightingEnabled)
{ {
CGraphics::sNumLights = 0; CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack; CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.f; CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
CGraphics::UpdateLightBlock(); CGraphics::UpdateLightBlock();
} }

View File

@ -180,7 +180,7 @@ void CScriptNode::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCo
if (CGraphics::sLightMode == CGraphics::ELightingMode::World && LightingOptions == eDisableWorldLighting) if (CGraphics::sLightMode == CGraphics::ELightingMode::World && LightingOptions == eDisableWorldLighting)
{ {
CGraphics::sNumLights = 0; CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack; CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.f; CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
CGraphics::UpdateLightBlock(); CGraphics::UpdateLightBlock();
} }

View File

@ -62,7 +62,7 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderComman
if (IsLightingEnabled) if (IsLightingEnabled)
{ {
CGraphics::sNumLights = 0; CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skWhite : CColor::skBlack; CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skWhite : CColor::skTransparentBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.0f; CGraphics::sPixelBlock.LightmapMultiplier = 1.0f;
CGraphics::UpdateLightBlock(); CGraphics::UpdateLightBlock();
} }