Pswin
April 10, 2010, 12:51am
1
hi
my geomtry shader dosent work in core 150. my OpenGL version is 3.3
vertex shader code
#version 150 core
in vec3 in_Position;
uniform mat4 in_ModelViewMatrix;
in vec4 in_VertexColor;
out vec4 VertexColor;
void main(void)
{
VertexColor = in_VertexColor;
gl_Position = in_ModelViewMatrix * vec4(in_Position,1.0);
}
geomtry shader:
#version 150
#extension GL_EXT_geometry_shader4 : enable
void main(void)
{
//increment variable
int i;
//Pass-thru!
for(i=0; i< gl_VerticesIn; i++){
gl_Position = gl_PositionIn[i];
EmitVertex();
}
EndPrimitive();
}
fragment shader:
#version 150 core
in vec4 VertexColor;
out vec4 out_Color;
void main(void)
{
out_Color = vec4(0);
}
what is wrong?
Pswin
April 10, 2010, 1:28am
3
any thing doesn’t show in screen but it compile successfully
Your fragment shader is outputting solid black with an alpha of zero (vec4(0)). Is your background also black?
Regards,
Patrick
I’d say you’d want to make two changes to make it work.
declare a layout of the type and maximum quantity your geometry shader should output. e.g.:
layout(triangle, max_vertices = 3) out;
Instead of glPositionIn[i], you want to use gl_in[i].glPosition
I have a tutorial for geometry shaders at http://www.opengl.org/wiki/Tutorial4:_Using_Indices_and_Geometry_Shaders_(C_/SDL) that may be of help.
Pswin
April 10, 2010, 7:17am
6
no
my background is white. and I’m not using blending
Do you try it on both amd card and nvidia card?
You need to specify the input and output layout for geometry shader either in the shader or in the application.
system
Closed
October 19, 2021, 7:28pm
8
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.