From 55c4a5818e802f6a9f473e3907fe878eb78d540e Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 7 Nov 2019 14:54:35 -1000 Subject: [PATCH] Use non-1.0 alpha component for default lighting --- src/Core/OpenGL/CShaderGenerator.cpp | 6 ------ src/Core/Render/CGraphics.cpp | 10 ++++++---- src/Core/Resource/Factory/CMaterialLoader.h | 12 ++++++++---- src/Core/Scene/CModelNode.cpp | 2 +- src/Core/Scene/CScriptNode.cpp | 2 +- src/Core/Scene/CStaticNode.cpp | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Core/OpenGL/CShaderGenerator.cpp b/src/Core/OpenGL/CShaderGenerator.cpp index fe3a4960..829447b6 100644 --- a/src/Core/OpenGL/CShaderGenerator.cpp +++ b/src/Core/OpenGL/CShaderGenerator.cpp @@ -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); diff --git a/src/Core/Render/CGraphics.cpp b/src/Core/Render/CGraphics.cpp index 96f20b6b..8cd07c3d 100644 --- a/src/Core/Render/CGraphics.cpp +++ b/src/Core/Render/CGraphics.cpp @@ -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 ************ @@ -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(); } diff --git a/src/Core/Resource/Factory/CMaterialLoader.h b/src/Core/Resource/Factory/CMaterialLoader.h index d78ac7b2..ac92511f 100644 --- a/src/Core/Resource/Factory/CMaterialLoader.h +++ b/src/Core/Resource/Factory/CMaterialLoader.h @@ -8,7 +8,8 @@ #include #include -enum class EMP3RenderConfig { +enum class EMP3RenderConfig +{ NoBloomTransparent, NoBloomAdditiveIncandecence, FullRenderOpaque, @@ -30,7 +31,8 @@ enum class EMP3RenderConfig { XRayOpaque }; -enum class EPASS { +enum class EPASS +{ DIFF, RIML, BLOL, @@ -47,7 +49,8 @@ enum class EPASS { TOON }; -enum class EINT { +enum class EINT +{ OPAC, BLOD, BLOI, @@ -55,7 +58,8 @@ enum class EINT { XRBR }; -enum class ECLR { +enum class ECLR +{ CLR, DIFB }; diff --git a/src/Core/Scene/CModelNode.cpp b/src/Core/Scene/CModelNode.cpp index a0aa9637..30be15e4 100644 --- a/src/Core/Scene/CModelNode.cpp +++ b/src/Core/Scene/CModelNode.cpp @@ -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(); } diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index eada2aec..2c8964f6 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -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(); } diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index 80922bab..6993644a 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -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(); }