Sign in to follow this  
aiuvoanh

How to check edges in vertex shader?

Recommended Posts

I want to handle seam edges in texture space, but I really do not know how to check edges in 3D that are parametrized in texture space because as I know, vertex shader just handle only one vertex at a time. So how to do it.

Is there anybody experienced this sort of situation, please help me?. Thank in advance.

Share this post


Link to post
Share on other sites
You could do this by putting the vertex data into a texture buffer and inside the vertex shader you'd be able to read out all the vertices associated with the primitive. The vertex shader can then generate appropriate output to feed to the rasteriser stage.

In the limit (although I wouldn't recommend it for performance reasons) your vertex shader can now access the data for the entire model, not even limited to just the current primitive.

Your input to the drawing command is then several copies of an "instanced" primitive (whose vertex coords aren't used in the final output). This will then provide an instance number (which tells you which tri or quad you're drawing) and you can supply a corner number as one of the parts of your input vertex so you know which corner you're generating in this run of the vertex shader.

This has an advantage in that you probably shouldn't have to change the format of the main VBO, just attach it to a texture lookup instead of using it as the drawing input so there'd be very little impact to the host code.

The risk is that by doing multiple texture reads inside the vertex shader, it will slow that down. However modern GPUs are actually extremely good at doing the texture data fetches and actually those fetches will be far outnumbered by the fetches to do your texture mapping during rasterisation.

Share this post


Link to post
Share on other sites
Thank you robotech_er, let me try, and is there any way to check that an edge cross a chart boundary in the sense that 1 vertex located in a chart and the other located in another one?

Share this post


Link to post
Share on other sites
[quote name='Katie' timestamp='1312965415' post='4847074']
You could do this by putting the vertex data into a texture buffer and inside the vertex shader you'd be able to read out all the vertices associated with the primitive. The vertex shader can then generate appropriate output to feed to the rasteriser stage.

In the limit (although I wouldn't recommend it for performance reasons) your vertex shader can now access the data for the entire model, not even limited to just the current primitive.

Your input to the drawing command is then several copies of an "instanced" primitive (whose vertex coords aren't used in the final output). This will then provide an instance number (which tells you which tri or quad you're drawing) and you can supply a corner number as one of the parts of your input vertex so you know which corner you're generating in this run of the vertex shader.

This has an advantage in that you probably shouldn't have to change the format of the main VBO, just attach it to a texture lookup instead of using it as the drawing input so there'd be very little impact to the host code.

The risk is that by doing multiple texture reads inside the vertex shader, it will slow that down. However modern GPUs are actually extremely good at doing the texture data fetches and actually those fetches will be far outnumbered by the fetches to do your texture mapping during rasterisation.
[/quote]

Thank you so much, you probably has lots of experience with GPU programming. I will try all of methods I can.

Share this post


Link to post
Share on other sites
And I think that to check an edge continue in surface but discontinue in texture space, and edge in surface is always continue, the distance is one unit, in meanwhile the distance in texture space is greater than one. Is that right, everybody?

Share this post


Link to post
Share on other sites
The fast silhouettes article linked in my signature has a method to do it without geometry shaders, but you need to put in some additional per-vertex data to make it work. Still, it might give you some inspiration for other ideas on how to get it working.

Share this post


Link to post
Share on other sites
[quote name='Jason Z' timestamp='1313091994' post='4847861']
The fast silhouettes article linked in my signature has a method to do it without geometry shaders, but you need to put in some additional per-vertex data to make it work. Still, it might give you some inspiration for other ideas on how to get it working.
[/quote]

404....

It could be interesting, because I need a fast backfacing edge algorithm, so I'd check it out.

Share this post


Link to post
Share on other sites
[quote name='szecs' timestamp='1313093350' post='4847873']
[quote name='Jason Z' timestamp='1313091994' post='4847861']
The fast silhouettes article linked in my signature has a method to do it without geometry shaders, but you need to put in some additional per-vertex data to make it work. Still, it might give you some inspiration for other ideas on how to get it working.
[/quote]

404....

It could be interesting, because I need a fast backfacing edge algorithm, so I'd check it out.
[/quote]

I'll report it to the GDNet guys... it is hosted here on gamedev (or should be anyways...)

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