From c2bed156d13d5b0a21be32079e0c2e9c778522d9 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Tue, 4 Jul 2023 13:25:23 -0300 Subject: [PATCH] Fix Area lights being mirrored around Y axis (0 is width -1) --- Components/Hlms/Pbs/src/OgreHlmsPbs.cpp | 2 +- .../ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp | 2 +- .../UpdatingDecalsAndAreaLightTexGameState.cpp | 2 +- .../Tutorial_TextureBakingGameState.cpp | 2 +- Samples/Media/Hlms/Pbs/Any/AreaLights_piece_ps.any | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp b/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp index de4df4f3439..ce070a12bae 100644 --- a/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp +++ b/Components/Hlms/Pbs/src/OgreHlmsPbs.cpp @@ -2617,7 +2617,7 @@ namespace Ogre // vec4 areaApproxLights[numLights].tangent; Quaternion qRot = light->getParentNode()->_getDerivedOrientation(); - Vector3 xAxis = viewMatrix3 * qRot.xAxis(); + Vector3 xAxis = viewMatrix3 * -qRot.xAxis(); *light1BufferPtr++ = xAxis.x; *light1BufferPtr++ = xAxis.y; *light1BufferPtr++ = xAxis.z; diff --git a/Samples/2.0/ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp b/Samples/2.0/ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp index a999c8e54a8..2a12af2bb93 100644 --- a/Samples/2.0/ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp +++ b/Samples/2.0/ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp @@ -147,7 +147,7 @@ namespace Demo { Ogre::v1::MeshPtr lightPlaneMeshV1 = Ogre::v1::MeshManager::getSingleton().createPlane( "LightPlane v1", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::Plane( Ogre::Vector3::UNIT_Z, 0.0f ), 1.0f, 1.0f, 1, 1, true, 1, 1.0f, 1.0f, + Ogre::Plane( Ogre::Vector3::NEGATIVE_UNIT_Z, 0.0f ), 1.0f, 1.0f, 1, 1, true, 1, 1.0f, 1.0f, Ogre::Vector3::UNIT_Y, Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC ); Ogre::MeshPtr lightPlaneMesh = Ogre::MeshManager::getSingleton().createByImportingV1( diff --git a/Samples/2.0/ApiUsage/UpdatingDecalsAndAreaLightTex/UpdatingDecalsAndAreaLightTexGameState.cpp b/Samples/2.0/ApiUsage/UpdatingDecalsAndAreaLightTex/UpdatingDecalsAndAreaLightTexGameState.cpp index a7ab79deeb4..9ed76b06a80 100644 --- a/Samples/2.0/ApiUsage/UpdatingDecalsAndAreaLightTex/UpdatingDecalsAndAreaLightTexGameState.cpp +++ b/Samples/2.0/ApiUsage/UpdatingDecalsAndAreaLightTex/UpdatingDecalsAndAreaLightTexGameState.cpp @@ -171,7 +171,7 @@ namespace Demo { Ogre::v1::MeshPtr lightPlaneMeshV1 = Ogre::v1::MeshManager::getSingleton().createPlane( "LightPlane v1", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::Plane( Ogre::Vector3::UNIT_Z, 0.0f ), 1.0f, 1.0f, 1, 1, true, 1, 1.0f, 1.0f, + Ogre::Plane( Ogre::Vector3::NEGATIVE_UNIT_Z, 0.0f ), 1.0f, 1.0f, 1, 1, true, 1, 1.0f, 1.0f, Ogre::Vector3::UNIT_Y, Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC ); Ogre::MeshPtr lightPlaneMesh = Ogre::MeshManager::getSingleton().createByImportingV1( diff --git a/Samples/2.0/Tutorials/Tutorial_TextureBaking/Tutorial_TextureBakingGameState.cpp b/Samples/2.0/Tutorials/Tutorial_TextureBaking/Tutorial_TextureBakingGameState.cpp index 369a72f0eef..6e1cc92fb1b 100644 --- a/Samples/2.0/Tutorials/Tutorial_TextureBaking/Tutorial_TextureBakingGameState.cpp +++ b/Samples/2.0/Tutorials/Tutorial_TextureBaking/Tutorial_TextureBakingGameState.cpp @@ -73,7 +73,7 @@ namespace Demo { Ogre::v1::MeshPtr lightPlaneMeshV1 = Ogre::v1::MeshManager::getSingleton().createPlane( "LightPlane v1", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::Plane( Ogre::Vector3::UNIT_Z, 0.0f ), 1.0f, 1.0f, 1, 1, true, 1, 1.0f, 1.0f, + Ogre::Plane( Ogre::Vector3::NEGATIVE_UNIT_Z, 0.0f ), 1.0f, 1.0f, 1, 1, true, 1, 1.0f, 1.0f, Ogre::Vector3::UNIT_Y, Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC ); Ogre::MeshPtr lightPlaneMesh = Ogre::MeshManager::getSingleton().createByImportingV1( diff --git a/Samples/Media/Hlms/Pbs/Any/AreaLights_piece_ps.any b/Samples/Media/Hlms/Pbs/Any/AreaLights_piece_ps.any index e6a57a3c8cd..791075e1ed5 100644 --- a/Samples/Media/Hlms/Pbs/Any/AreaLights_piece_ps.any +++ b/Samples/Media/Hlms/Pbs/Any/AreaLights_piece_ps.any @@ -53,8 +53,8 @@ /*&& dot( -lightDir, light1Buf.areaApproxLights[i].direction.xyz ) > 0*/ @insertpiece( andObjAreaApproxLightMaskCmp ) ) { projectedPosInPlane.xyz -= light1Buf.areaApproxLights[i].position.xyz; - float3 areaLightBitangent = cross( light1Buf.areaApproxLights[i].direction.xyz, - light1Buf.areaApproxLights[i].tangent.xyz ); + float3 areaLightBitangent = cross( light1Buf.areaApproxLights[i].tangent.xyz, + light1Buf.areaApproxLights[i].direction.xyz ); float2 invHalfRectSize = float2( light1Buf.areaApproxLights[i].direction.w, light1Buf.areaApproxLights[i].tangent.w ); //lightUV is in light space, in range [-0.5; 0.5]