Fix: SSAO计算时使用了错误的法向量
parent
7bee8eb5dc
commit
16fbdd5afd
|
@ -28,7 +28,7 @@ void main()
|
||||||
// get input for SSAO algorithm
|
// get input for SSAO algorithm
|
||||||
vec3 worldPos = texelFetch(gPosition, pixelLocation, 0).xyz;
|
vec3 worldPos = texelFetch(gPosition, pixelLocation, 0).xyz;
|
||||||
vec3 fragPos = (view * vec4(worldPos, 1.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);
|
vec3 randomVec = normalize(texture(texNoise, vec2(pixelLocation) * noiseScale).xyz);
|
||||||
// create TBN change-of-basis matrix: from tangent-space to view-space
|
// create TBN change-of-basis matrix: from tangent-space to view-space
|
||||||
vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
|
vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
|
||||||
|
|
Loading…
Reference in New Issue