Hello!
I have tried to implement deferred rendering for a week already
Before I can go forward to the lighting calculations g-buffers must be correct.
Color/Texture buffer is fine, but when I enable only positions or normals then I donāt see nothing on the screen. Iām sure that problem is somewhere in the following code.
My rendering pipeline:
1) Clear scene
2) Bind FBO with MRT
3) Bind shader
4)
glGetFloatv(GL_MODELVIEW_MATRIX, mm);
glGetFloatv(GL_PROJECTION_MATRIX, pm);
gbuffer_shader->set("mm", mm);
gbuffer_shader->set("pm", pm);
5) Move camera
6) Draw scene
7) Unbind shader
8) Render FBO to the fullscreen quad
Vertex Shader:
varying vec3 vertex_position;
varying vec3 normal_vector;
uniform mat4 mm;
uniform mat4 pm;
void main() {
gl_Position = mm * pm * gl_Vertex;
vertex_position = vec3(mm * gl_Vertex);
normal_vector = vec3(gl_NormalMatrix * gl_Normal);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;
}
Fragment Shader:
varying vec3 vertex_position;
varying vec3 normal_vector;
uniform sampler2D texture0, texture1;
vec4 texel, texel0, texel1;
uniform vec4 color;
void main() {
texel0 = texture2D(texture0, gl_TexCoord[0].st);
texel1 = texture2D(texture1, gl_TexCoord[1].st);
texel = texel0 * texel1;
gl_FragData[0] = texel;
gl_FragData[1] = vec4(vertex_position, 1);
gl_FragData[2] = vec4(normal_vector, 1);
}
I would like to get position colors exactly like this image.
Any help will be appreciated!