PDA

View Full Version : GS in GLSL 1.2 need help...



Mars_999
08-20-2011, 10:55 AM
Hello, I am new to GS in GLSL and would like to create a tessellated triangle and have it calculate the normals per vertex....

This is what I have so far....


void main()
{
float centerX, centerY;
for(int x = 0; x < 8; x++)
{
for(int y = 0; y < 8; y++)
{
centerX = -0.9 + 0.2 * x;
centerY = 0.9 - 0.2 * y;
gl_Position = gl_ModelViewProjectionMatrix * vec4(centerX - 0.1, centerY - 0.1, 0.0, 1);
EmitVertex();

gl_Position = gl_ModelViewProjectionMatrix * vec4(centerX, centerY + 0.1, 0.0, 1);
EmitVertex();

gl_Position = gl_ModelViewProjectionMatrix * vec4(centerX + 0.1, centerY - 0.1, 0.0, 1);
EmitVertex();

EndPrimitive();
}
}
}


but it only shows a grid of triangles... I want to take my current quad(2 triangles) and tessellate it to have more polygons to avoid texture tearing on hill sides ect...

Thanks!

BTW any tutorials on GLSL 1.2 version of this would be great as I can't find any...

Aleksandar
08-20-2011, 01:00 PM
BTW any tutorials on GLSL 1.2 version of this would be great as I can't find any...
It is quite normal that GLSL 1.2 geometry shader tutorial are rare. Geometry shaders are included in GLSL 1.5 for the first time (without a need for the extensions). :)

If you have a hardware capable to use geometry shaders, why don't you install drivers with GL3.3 support. I guess everything will be much easier and you won't need to use extensions in GLSL. But if you prefer to stay on GL2.0/2.1, then I should suggest some very ancient links:

Probably the first known GLSL GS tutorial (Nov. 2006.):
http://appsrv.cse.cuhk.edu.hk/~ymxie/Geometry_Shader/

Also pretty old one (Jan. 2007.):
http://www.icare3d.org/blog_techno/gpu/opengl_geometry_shader_marching_cubes.html

And don't forget ultimate samples pack on:
http://www.g-truc.net/