Skip to content

Commit

Permalink
Updates to lighting a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
“Malcolm committed Dec 15, 2024
1 parent 6a9cdef commit f46461e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions platform/darwin/src/gltf/GLTFMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,14 @@ simd_float4x4 GLTFNormalMatrixFromModelMatrix(simd_float4x4 m) {
} };
return mout;
}

simd_double4x4 GLTFNormalMatrixFromModelMatrixD(simd_double4x4 m) {
simd_double3x3 nm = simd_inverse(simd_transpose(GLTFMatrixUpperLeft3x3D(m)));
simd_double4x4 mout = { {
{ nm.columns[0][0], nm.columns[0][1], nm.columns[0][2], 0 },
{ nm.columns[1][0], nm.columns[1][1], nm.columns[1][2], 0 },
{ nm.columns[2][0], nm.columns[2][1], nm.columns[2][2], 0 },
{ 0, 0, 0, 1 }
} };
return mout;
}
2 changes: 2 additions & 0 deletions platform/darwin/src/gltf/GLTFMath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ simd_float3x3 GLTFTextureMatrixFromTransform(GLTFTextureTransform transform);

simd_float4x4 GLTFNormalMatrixFromModelMatrix(simd_float4x4 m);

simd_double4x4 GLTFNormalMatrixFromModelMatrixD(simd_double4x4 m);


#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions platform/darwin/src/gltf/MetalRenderer+GLTFAsset.mm
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ simd_float3 double3_to_float3(simd_double3 input) {
auto mvp = matrix_multiply(_projectionMatrix, model->_modelViewMatrix);
auto mvpF = matrix_double_to_float(mvp);
vertexUniforms.modelViewProjectionMatrix = mvpF;
auto normalMatrix = GLTFNormalMatrixFromModelMatrixD( model->_modelViewMatrix);
vertexUniforms.normalMatrix = matrix_double_to_float(normalMatrix);



Expand Down

0 comments on commit f46461e

Please sign in to comment.