Fix: SSAO计算时使用了错误的法向量

main
wuyize 2024-04-11 22:42:33 +08:00
parent 7bee8eb5dc
commit 16fbdd5afd
1 changed files with 1 additions and 1 deletions

View File

@ -28,7 +28,7 @@ void main()
// get input for SSAO algorithm
vec3 worldPos = texelFetch(gPosition, pixelLocation, 0).xyz;
vec3 fragPos = (view * vec4(worldPos, 1.0)).xyz;
vec3 normal = normalize((texelFetch(gNormal, pixelLocation, 0).xyz - vec3(0.5)) * 2);
vec3 normal = normalize(mat3(view) * ((texelFetch(gNormal, pixelLocation, 0).xyz - vec3(0.5)) * 2));
vec3 randomVec = normalize(texture(texNoise, vec2(pixelLocation) * noiseScale).xyz);
// create TBN change-of-basis matrix: from tangent-space to view-space
vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));