Skip to content

Commit

Permalink
Use non-1.0 alpha component for default lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Nov 8, 2019
1 parent 6e3b23e commit 55c4a58
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
6 changes: 0 additions & 6 deletions src/Core/OpenGL/CShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,6 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
if (pPass->Texture())
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
bool UseLightmapMultiplier = (PassType == "DIFF") ||
(PassType == "CUST" && (rkMat.Options() & EMaterialOption::Lightmap) && iPass == 0);
Expand Down
10 changes: 6 additions & 4 deletions src/Core/Render/CGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ CGraphics::SLightBlock CGraphics::sLightBlock;

CGraphics::ELightingMode CGraphics::sLightMode;
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;
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, 1.f)),
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, 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, 0.3f)),
CLight::BuildDirectional(CVector3f(0), CVector3f( 0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 0.3f))
};

// ************ FUNCTIONS ************
Expand Down Expand Up @@ -167,9 +167,11 @@ void CGraphics::SetDefaultLighting()
sDefaultDirectionalLights[0].Load();
sDefaultDirectionalLights[1].Load();
sDefaultDirectionalLights[2].Load();
sNumLights = 0;
UpdateLightBlock();

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

Expand Down
12 changes: 8 additions & 4 deletions src/Core/Resource/Factory/CMaterialLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include <Common/FileIO.h>
#include <assimp/scene.h>

enum class EMP3RenderConfig {
enum class EMP3RenderConfig
{
NoBloomTransparent,
NoBloomAdditiveIncandecence,
FullRenderOpaque,
Expand All @@ -30,7 +31,8 @@ enum class EMP3RenderConfig {
XRayOpaque
};

enum class EPASS {
enum class EPASS
{
DIFF,
RIML,
BLOL,
Expand All @@ -47,15 +49,17 @@ enum class EPASS {
TOON
};

enum class EINT {
enum class EINT
{
OPAC,
BLOD,
BLOI,
BNIF,
XRBR
};

enum class ECLR {
enum class ECLR
{
CLR,
DIFB
};
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Scene/CModelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand
if (IsLightingEnabled)
{
CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
CGraphics::UpdateLightBlock();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Scene/CScriptNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void CScriptNode::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCo
if (CGraphics::sLightMode == CGraphics::ELightingMode::World && LightingOptions == eDisableWorldLighting)
{
CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack;
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.f;
CGraphics::UpdateLightBlock();
}
Expand Down
2 changes: 1 addition & 1 deletion 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::skBlack;
CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skWhite : CColor::skTransparentBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.0f;
CGraphics::UpdateLightBlock();
}
Expand Down

0 comments on commit 55c4a58

Please sign in to comment.