ytgui / temp

0 stars 0 forks source link

graphic phrases 4 gbuffer and deferred shading #87

Closed ytgui closed 4 years ago

ytgui commented 5 years ago

https://learnopengl-cn.readthedocs.io/zh/latest/05%20Advanced%20Lighting/08%20Deferred%20Shading/

ytgui commented 5 years ago

Deferred shading

ytgui commented 5 years ago

https://learnopengl.com/code_viewer_gh.php?code=src/5.advanced_lighting/8.1.deferred_shading/deferred_shading.cpp

Geometry Pass

// VS
out vec4 gl_Position;
out vec3 FragPos;
out vec2 TexCoords;
out vec3 Normal;

// FS
layout (location = 0) out vec3 gPosition;
layout (location = 1) out vec3 gNormal;
layout (location = 2) out vec4 gAlbedoSpecular;

Lighting Pass

// VS
out vec4 gl_Position;
out vec2 TexCoords;

// FS
void main() {
    // retrieve data from gbuffer
    vec3 FragPos = texture(gPosition, TexCoords).rgb;
    vec3 Normal = texture(gNormal, TexCoords).rgb;
    vec3 Diffuse = texture(gAlbedoSpecular, TexCoords).rgb;
    float Specular = texture(gAlbedoSpecular, TexCoords).a;
}
ytgui commented 4 years ago

MRT in driver

https://gamedev.stackexchange.com/questions/18503/why-would-you-want-multiple-render-targets https://github.com/SaschaWillems/Vulkan/blob/master/examples/deferred/deferred.cpp https://github.com/SaschaWillems/Vulkan