saski
02-19-2011, 04:39 AM
howdy folks,
very basic question: do I have to pass color values and texture coordinates through a geometry shader?
I wrote a simple passthough GS that renders the geometry fine but OpenGL fails to include color and texcoord values. If I remove the GS and use only the vertex shader and fragment shader, color and texcoords are fine.
Maybe someone can give me a hint?
Thx in advance :)
Here's my GS:
------------
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
void main() {
gl_Position = vec4(0,0,0,0);
for(int i = 0; i < gl_in.length(); i++) {
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}
And here my VS:
---------------
attribute vec4 li_vtx;
attribute vec3 li_normal;
attribute vec2 li_texcoord;
attribute vec4 li_ambient;
uniform mat4 u_pjmatrix; // projection matrix
uniform mat4 u_mvmatrix; // modelview matrix
varying vec2 g_texcoord;
varying vec4 g_gambient;
void main(void) {
g_gambient = li_ambient;
g_texcoord = li_texcoord;
gl_Position = u_pjmatrix * u_mvmatrix * li_vtx;
}
And finally my FS:
------------------
uniform sampler2D u_colormap;
varying vec2 g_texcoord;
varying vec4 g_gambient;
void main(void) {
vec4 texcolor = texture2D(u_colormap, g_texcoord.st);
gl_FragColor = g_gambient * texcolor;
}
very basic question: do I have to pass color values and texture coordinates through a geometry shader?
I wrote a simple passthough GS that renders the geometry fine but OpenGL fails to include color and texcoord values. If I remove the GS and use only the vertex shader and fragment shader, color and texcoords are fine.
Maybe someone can give me a hint?
Thx in advance :)
Here's my GS:
------------
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
void main() {
gl_Position = vec4(0,0,0,0);
for(int i = 0; i < gl_in.length(); i++) {
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}
And here my VS:
---------------
attribute vec4 li_vtx;
attribute vec3 li_normal;
attribute vec2 li_texcoord;
attribute vec4 li_ambient;
uniform mat4 u_pjmatrix; // projection matrix
uniform mat4 u_mvmatrix; // modelview matrix
varying vec2 g_texcoord;
varying vec4 g_gambient;
void main(void) {
g_gambient = li_ambient;
g_texcoord = li_texcoord;
gl_Position = u_pjmatrix * u_mvmatrix * li_vtx;
}
And finally my FS:
------------------
uniform sampler2D u_colormap;
varying vec2 g_texcoord;
varying vec4 g_gambient;
void main(void) {
vec4 texcolor = texture2D(u_colormap, g_texcoord.st);
gl_FragColor = g_gambient * texcolor;
}