diff --git a/HPL2/core/resource/fs_basic_translucent_material.sc b/HPL2/core/resource/fs_basic_translucent_material.sc index 36be140ca..e4cfc8bc7 100644 --- a/HPL2/core/resource/fs_basic_translucent_material.sc +++ b/HPL2/core/resource/fs_basic_translucent_material.sc @@ -59,7 +59,7 @@ void main() #endif #ifdef USE_BLEND_MODE_MULX2 float fBlendMulAlpha = u_lightLevel * fFinalAlpha; - vFinalColor.xyz = mul(vFinalColor.xyz, fBlendMulAlpha) + mul(vec3(0.5,0.5,0.5), vec3(1.0 - fBlendMulAlpha)); + vFinalColor.xyz = mul(vFinalColor.xyz, fBlendMulAlpha) + mul(vec3(0.5,0.5,0.5), (1.0 - fBlendMulAlpha)); #endif #ifdef USE_BLEND_MODE_ALPHA vFinalColor.xyz *= u_lightLevel; diff --git a/HPL2/core/sources/graphics/RendererDeferred.cpp b/HPL2/core/sources/graphics/RendererDeferred.cpp index 8b3d6401a..2b0a03409 100644 --- a/HPL2/core/sources/graphics/RendererDeferred.cpp +++ b/HPL2/core/sources/graphics/RendererDeferred.cpp @@ -283,25 +283,22 @@ namespace hpl { switch (light.m_light->GetLightType()) { case eLightType_Point: return cMath::MatrixScale(light.m_light->GetRadius() * kLightRadiusMul_Medium); - case eLightType_Spot: - { - cLightSpot* pLightSpot = static_cast(light.m_light); + case eLightType_Spot: { + cLightSpot* pLightSpot = static_cast(light.m_light); - float fFarHeight = pLightSpot->GetTanHalfFOV() * pLightSpot->GetRadius() * 2.0f; - // Note: Aspect might be wonky if there is no gobo. - float fFarWidth = fFarHeight * pLightSpot->GetAspect(); - - return cMath::MatrixScale( - cVector3f(fFarWidth, fFarHeight, light.m_light->GetRadius())); // x and y = "far plane", z = radius - } - case eLightType_Box: - { - cLightBox* pLightBox = static_cast(light.m_light); + float fFarHeight = pLightSpot->GetTanHalfFOV() * pLightSpot->GetRadius() * 2.0f; + // Note: Aspect might be wonky if there is no gobo. + float fFarWidth = fFarHeight * pLightSpot->GetAspect(); - auto mtx = cMath::MatrixScale(pLightBox->GetSize()); - mtx.SetTranslation(pLightBox->GetWorldPosition()); - return mtx; - } + return cMath::MatrixScale( + cVector3f(fFarWidth, fFarHeight, light.m_light->GetRadius())); // x and y = "far plane", z = radius + } + case eLightType_Box: { + cLightBox* pLightBox = static_cast(light.m_light); + auto mtx = cMath::MatrixScale(pLightBox->GetSize()); + mtx.SetTranslation(pLightBox->GetWorldPosition()); + return mtx; + } default: break; } @@ -1611,8 +1608,7 @@ namespace hpl { shaderProgram.m_textures.push_back({ m_s_diffuseMap, options.m_gBuffer.m_colorImage->GetHandle(), 0 }); shaderProgram.m_uniforms.push_back({ m_u_lightColor, lightColor }); - shaderProgram.m_modelTransform = - cMath::MatrixMul(light->m_light->GetWorldMatrix(), detail::GetLightMtx(*light)).GetTranspose(); + shaderProgram.m_modelTransform = detail::GetLightMtx(*light).GetTranspose(); switch (pLightBox->GetBlendFunc()) { case eLightBoxBlendFunc_Add: @@ -1654,8 +1650,7 @@ namespace hpl { shaderProgram.m_configuration.m_frontStencilTest = CreateStencilTest( StencilFunction::Always, StencilFail::Keep, StencilDepthFail::Replace, StencilDepthPass::Keep, 0xff, 0xff); - shaderProgram.m_modelTransform = - cMath::MatrixMul(light->m_light->GetWorldMatrix(), detail::GetLightMtx(*light).GetTranspose()); + shaderProgram.m_modelTransform = detail::GetLightMtx(*light).GetTranspose(); GraphicsContext::DrawRequest drawRequest{ layoutStream, shaderProgram }; // drawRequest.m_clear = GraphicsContext::ClearRequest{0, 0, 0, ClearOp::Stencil};