Skip to content

Commit

Permalink
Fix Area lights being mirrored around Y axis (0 is width -1)
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Jul 4, 2023
1 parent 07c2b0a commit c2bed15
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Components/Hlms/Pbs/src/OgreHlmsPbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions Samples/Media/Hlms/Pbs/Any/AreaLights_piece_ps.any
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit c2bed15

Please sign in to comment.