Remove NormalMatrix shader uniform.

It doesn't provide much value given its costs. It also didn't work properly with auto-batched draws.
This commit is contained in:
Sasha Szpakowski
2024-06-17 20:57:28 -03:00
parent e180b256b8
commit bfc4212f30
5 changed files with 17 additions and 71 deletions
+2 -19
View File
@@ -1116,25 +1116,8 @@ void Graphics::applyShaderUniforms(id<MTLRenderCommandEncoder> renderEncoder, lo
builtins->transformMatrix = getTransform();
builtins->projectionMatrix = getDeviceProjection();
// The normal matrix is the transpose of the inverse of the rotation portion
// (top-left 3x3) of the transform matrix.
{
Matrix3 normalmatrix = Matrix3(builtins->transformMatrix).transposedInverse();
const float *e = normalmatrix.getElements();
for (int i = 0; i < 3; i++)
{
builtins->normalMatrix[i].x = e[i * 3 + 0];
builtins->normalMatrix[i].y = e[i * 3 + 1];
builtins->normalMatrix[i].z = e[i * 3 + 2];
builtins->normalMatrix[i].w = 0.0f;
}
}
// Store DPI scale in an unused component of another vector.
builtins->normalMatrix[0].w = (float) getCurrentDPIScale();
// Same with point size.
builtins->normalMatrix[1].w = getPointSize();
builtins->scaleParams.x = = (float) getCurrentDPIScale();
builtins->scaleParams.y = getPointSize();
uint32 flags = Shader::CLIP_TRANSFORM_Z_NEG1_1_TO_0_1;
builtins->clipSpaceParams = Shader::computeClipSpaceParams(flags);