Hello. In the context of school I wanted to write a simple program that using the geometry shader will generate a 32x32 pixel terrain.
Unfortunately, when linking the program Shader, I read the following error in my log:
Loading GL_ARB_fragment_shader ext. SUCCESS
Loading GL_ARB_vertex_shader ext. SUCCESS
Loading GL_ARB_geometry_shader4 ext. SUCCESS
Loading GL_ARB_shader_objects ext. SUCCESS
Creating program object: "program1"
Compiling vertex shader: SUCCESS
Compiling fragment shader: SUCCESS
Compiling geometry shader: SUCCESS
GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT: 1024
Linking program shader: FAILED
printProgramInfoLog: Geometry info
-------------
(0) : error C6033: Hardware limitation reached, can only emit 78 vertices of this size
GL_MAX_TEXTURE_UNITS_ARB: 4
OpenGL version: 3.3.0
I’ve lost many hours to find something about it …
The maximum number of vertices emitted is 1024, so why there is 78?
I would be very grateful if someone help me to understand it.
this is my geometry sahder:
#version 150
#extension GL_EXT_geometry_shader4 : enable
uniform sampler2D heightmap;
in vec3 vlight[3];
in vec3 vnormal[3];
in vec3 vpoint[3];
out vec3 light;
out vec3 normal;
out vec3 point;
void main()
{
int i,u,v;
vec4 vertex;
vec2 texture_coord;
vec4 texture_color;
for(i=0; i<32; i++)
for(u=0; u<32; u++)
{
texture_coord.x = i;
texture_coord.y = u;
texture_color = texture2D(heightmap, texture_coord);
vertex.x = -1+i*0.1;
vertex.y = -1+u*0.1;
vertex.z = -1;
vertex.w = 1;
gl_Position = vertex;
gl_PointSize = 0;
light = vlight[0];
normal = vnormal[0];
point = vpoint[0];
EmitVertex();
texture_coord.x = i+1;
texture_coord.y = u;
texture_color = texture2D(heightmap, texture_coord);
vertex.x = -1+(i+1)*0.1;
vertex.y = -1+u*0.1;
vertex.z = 0;
vertex.w = 1;
gl_Position = vertex;
//gl_PointSize = 0;
light = vlight[1];
normal = vnormal[1];
point = vpoint[1];
EmitVertex();
texture_coord.x = i;
texture_coord.y = u+1;
texture_color = texture2D(heightmap, texture_coord);
vertex.x = -1+i*0.1;
vertex.y = -1+(u+1)*0.1;
vertex.z = 0;
vertex.w = 1;
gl_Position = vertex;
//gl_PointSize = 0;
light = vlight[2];
normal = vnormal[2];
point = vpoint[2];
EmitVertex();
EndPrimitive();
}
}
When in loop i change from:
“i<32” and “u<32”
to:
“i<4” and “u<4”
there are 443 = 48 vertives and all is OK.
my graphics card: Gainward GeForce 8400GS 512MB