Saturday, 11 May 2013

GLSL tessellation Shaders under Mac OSX

So this interesting post appeared the other day saying that tessellation shaders were working  on Mac OSX. According to the documents and other things like GLView this is not the case.

I decided to spend the day investigating the claims to a) see if they were true, and b) see how I could replicate this in my own library.

The following video shows how I used the Mac OpenGL profiler to dig into the source code and find out how to do this.

 The main code elements you need are the following defines

#ifdef DARWIN
        #define GL_TESS_CONTROL_SHADER 0x00008e88
        #define GL_TESS_EVALUATION_SHADER 0x00008e87
    #ifndef GL_PATCHES
        #define GL_PATCHES 0x0000000e
Once this has been defined somewhere you can use the default OpenGL commands to create a shader, I chose to use the demo code / shader here the main thing to remember is that you must use GL_PATCHES to draw to the tessellation units.

The other problem is that code like
glPatchParameteri(GL_PATCH_VERTICES, 16); 
is not available as the glPatchParam functions are not exposed, the good news is that you can set all of this in the shader so it is not too much of an issue. The updates have now been rolled into the core ngl library, and I will add some demos soon.

1 comment:

  1. The number of vertices per input patch to the tessellation control shader is *not* defined by the tessellation control shader. Only the number of vertices per *output* patch is.