render: SSAO

This commit is contained in:
2022-02-05 19:25:44 +08:00
parent 05a85ac27f
commit 92b0ace7a2
9 changed files with 289 additions and 26 deletions

View File

@@ -14,7 +14,7 @@ layout (location = 3) in float light;
out vec3 fragPosWorld;
out float fragPosLightspaceZ;
out float fragDepthNDC;
out float fragDepthView;
out vec2 fragTexCoord;
out vec3 fragNormal;
out float fragLight;
@@ -25,14 +25,16 @@ void main() {
fragNormal = normalize(normal);
fragLight = light;
gl_Position = projection * view * model * vec4(vert, 1);
fragDepthNDC = gl_Position.z / gl_Position.w;
vec4 pos4 = model * vec4(vert, 1);
fragPosWorld = pos4.xyz / pos4.w;
vec4 fragPosLightspace = lightspace * vec4(fragPosWorld, 1.0f);
fragPosLightspaceZ = fragPosLightspace.z / fragPosLightspace.w *0.5f + 0.5f;
vec4 posView = view * pos4;
fragDepthView = posView.z;
gl_Position = projection * posView;
fragPosWorld -= viewPos;
}