OPTIM: shader optimization

This commit is contained in:
2025-12-26 14:29:59 +09:00
parent d6216b20fc
commit cead54c32e
12 changed files with 196 additions and 109 deletions

View File

@@ -14,9 +14,10 @@ void main()
// Avoid per-pixel matrix inverses. With a perspective projection, a view-space ray can be
// reconstructed directly from the projection diagonal and then rotated to world space.
vec3 viewDir = normalize(vec3(ndc.x / sceneData.proj[0][0], ndc.y / sceneData.proj[1][1], -1.0));
vec3 worldDir = normalize(transpose(mat3(sceneData.view)) * viewDir);
// view matrix is rigid-body => transpose(mat3(view)) preserves length for normalized vectors.
vec3 worldDir = transpose(mat3(sceneData.view)) * viewDir;
vec2 uv = dir_to_equirect(worldDir);
vec2 uv = dir_to_equirect_normalized(worldDir);
// Sample a dedicated background environment map when available.
// The engine binds iblBackground2D to a texture that may differ from the IBL specular map.
vec3 col = textureLod(iblBackground2D, uv, 0.0).rgb;