Sign in to follow this  
Followers 0
cippyboy

OpenGL
Generating Barycentric Coordinates similar to hardware tesselation ?

2 posts in this topic

I was thinking about a way to do tessellation under OpenGL ES 3 using instancing. What I thought about doing is store 3 times the vertex data per vertex ( the 3 constituent vertices of a triangle, while ofcourse giving up on indexing ) and then set up a uniform block with the barycentric coordinates and using instancing I could render 3*n triangles per each original triangle and then interpolate for their final values. This will later on be coupled with vertex shader texture sampling into a depth map. This all sounds good in theory but I'm wondering if there is already out there a library of some sort to give me an n-complexity set of barycentric coordinates for sub-triangles. Like n=1 (instance) would result in 1,0,0 - 0,1,0 - 0,0,1 or the original triangle. n=3(instances) would create a vertex inside the triangle and the 3 related sub-triangles. I know GL4+ hardware does this, I'm looking for some already written code that does this, if you happen to know.
 

Edited by cippyboy
0

Share this post


Link to post
Share on other sites

If anyone stumbles upon this, I figured out where to get the barycentric coordinates from, GL 4.0 tesselation factors (more specifically I wrote the values out with a shader storage buffer smile.png ) but there's a small caveat, you don't get indices for those barycentric coordinates. So like you get 7 sets of coordinates but there's 6 triangles involved (for level 2). I'll probably write my own barycentric generator and the related indices to go along with it. I also switched the technique a bit to get vertex data from uniform buffers, the small problem here is that you're limited to around 1024 vertices in a uniform buffer, but those are the initial vertices anyway, the tessellated mesh will have that times the number of instances, so in theory you can get to high numbers pretty fast.

 

UPDATE : Section 2.X.2.1 of the ARB_tesselation_shader spec seems to go in detail about those coordinates.

 

http://www.opengl.org/registry/specs/ARB/tessellation_shader.txt

Edited by cippyboy
0

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  
Followers 0