Triangulate a quad with a hole in it using tessellation
Asked Answered
R

1

6

Is it possible to triangulate a quad with a hole in it using tesselation shader? For example,

enter image description here enter image description here enter image description here

  1. Imagine I have a Quad.
  2. Then I want to make a hole to the center of the quad.
  3. There need to be a lot more of vertices to make that hole.

And the questions:

  • Can I do that using Tessellation shader? If so, how?
  • Should I use Geometry shader instead?
Roughhew answered 18/5, 2013 at 23:6 Comment(2)
Another variant worth considering would be using the fragment shader, by just discarding the fragments of the "hole". You could use a texture for that, our use some paramaters to describe the position and size of the hole. Note that "old" GL also has the alpha test which allowed to do such things.Unbelievable
@Unbelievable thanks for the comment. As this will be done in a huge quad, modifying the texture isn't viable; I need to create more mesh.Roughhew
T
2

That is not a typical application of the tessellation shader, and that's also not what is done. Basically, you have a coarse 3d model, which is passed to your graphics card. The graphics card actually implements the tessellation algorithm, which creates a more refined 3d model by tessellating the primitives.

You have to supply two shaders: Tessellation control- and evaluation shaders (in OpenGL terms)

In the tessellation control shader you can "parameterize" the tessellation algorithm (inner and outer tessellation factors etc). Then the tessellation algorithm is applied. Thereafter the tessellation evaluation shader is used to, e.g. interpolate vertex attributes for the fine vertices.

What you want to do reminds me of CSG (http://en.wikipedia.org/wiki/Constructive_solid_geometry). It's true that the tessellation shader creates new data, but you may just paramterize the algorithm. You cannot "implement" the tessellation algorithm. Ad Geometry shader: it's true that you can emit (limited amount of) new primitives, but it also does not apply to your problem.

Torto answered 21/5, 2013 at 21:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.