Sign in to follow this  
MARS_999

GS in GLSL 1.2

Recommended Posts

Anyone have any tutorials on how to take in TRIANGLES and output the TRIANGLE_STRIPS for tessellation using GL2.1 with the geometry shader?

#version 120
#extension GL_EXT_gpu_shader4 : enable
#extension GL_EXT_geometry_shader4 : enable

I can't find much of any useful info on the GLSL 1.2 version....

Thanks!

Share this post


Link to post
Share on other sites
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....
[code]
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();
}
}
}
[/code]

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...

Share this post


Link to post
Share on other sites
So, the first point is that the GS is not really for tessellation. Yes, you can approximate it by outputting new triangles but it's not quite the same thing (works in a different domain for one thing).

If you want to approximate tessellation then you'll need to use the input vertices and create a new set of vertices between them, the maths for which shouldn't be too hard (mostly lerps to get vertices between each location as required).

iirc GLSL1.2 just expanded the language a bit, it should't be too hard to get up to speed on it from the spec.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this