LIGHTING NOW DONE IN VIEW SPACE
This commit is contained in:
parent
96112e5251
commit
39b5ac0774
|
@ -38,14 +38,23 @@ layout(set = 2, binding = 0) uniform CameraData
|
|||
|
||||
void main()
|
||||
{
|
||||
|
||||
Out2.materialIndex = gl_InstanceIndex;
|
||||
Out2.eid = integerData[0];
|
||||
Out2.lightLayerIndex = integerData[1];
|
||||
|
||||
Out.vertPos = worldTransform * vec4(aVertexPos, 1.0f);
|
||||
// for transforming gBuffer position and normal data
|
||||
mat4 modelViewMat = cameraData.viewMat * worldTransform;
|
||||
|
||||
// gBuffer position will be in view space
|
||||
Out.vertPos = modelViewMat * vec4(aVertexPos, 1.0f);
|
||||
|
||||
// uvs for texturing in fragment shader
|
||||
Out.uv = aUV;
|
||||
Out.normal.rgb = mat3(transpose(inverse(worldTransform))) * aNormal.rgb;
|
||||
|
||||
// normals are also in view space
|
||||
Out.normal.rgb = mat3(transpose(inverse(modelViewMat))) * aNormal.rgb;
|
||||
Out.normal.rgb = normalize (Out.normal.rgb);
|
||||
|
||||
// clip space for rendering
|
||||
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||
}
|
Binary file not shown.
|
@ -108,7 +108,7 @@ namespace SHADE
|
|||
{
|
||||
//cpuCameraData.viewProjectionMatrix = camera->GetViewMatrix() * camera->GetProjectionMatrix();
|
||||
cpuCameraData.viewProjectionMatrix = SHMatrix::Transpose(projMatrix * viewMatrix);
|
||||
cpuCameraData.viewMatrix = viewMatrix;
|
||||
cpuCameraData.viewMatrix = SHMatrix::Transpose(viewMatrix);
|
||||
}
|
||||
|
||||
Handle<SHRenderGraph> SHRenderer::GetRenderGraph(void) const noexcept
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||
#include "SHLightComponent.h"
|
||||
#include "Math/Vector/SHVec4.h"
|
||||
#include "Math/SHMatrix.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -41,9 +42,11 @@ namespace SHADE
|
|||
{
|
||||
SHDirectionalLightData* lightPtr = reinterpret_cast<SHDirectionalLightData*>(address);
|
||||
|
||||
SHVec4 transformedDir = viewMat * SHVec4(lightData.direction[0], lightData.direction[1], lightData.direction[2], 0.0f);
|
||||
|
||||
lightPtr->cullingMask = lightData.cullingMask;
|
||||
//lightPtr->direction = viewMat * SHVec4 (lightData.direction[0], lightData.direction[1], lightData.direction[2], 0.0f);
|
||||
lightPtr->direction = lightData.direction;
|
||||
lightPtr->direction = SHVec3 (transformedDir.x, transformedDir.y, transformedDir.z);
|
||||
//lightPtr->direction = lightData.direction;
|
||||
lightPtr->diffuseColor = lightData.color;
|
||||
lightPtr->active = lightComp->isActive;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue