Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm experienced with OpenGL 3+. I'm dabbling with tessellation shaders and have now got to a point where I have a nicely tessellated teapot/plane demo (quick look here)

As can be seen from the screenshots, the lighting is broken (though admittedly doesn't look too bad in the image)

I've tried to add a normal map to the equation but it still doesn't come out right, I can calculate the normals, tangents and binormals per triangle in the geometry shader but still looks wrong.

I think the question would be; How do I add per fragment lighting to a tessellated model?

The teapot is 32 16-point patches, the plane is one single 16 point patch.

The shaders are here, but they are a complete mess, so I don't blame anyone who cant make sense of them. But peruse at your leisure if you like.

Also, if this question is more suited to be somewhere else i.e. Stack Overflow or the Programming stack please let me know.

share|improve this question
1  
"How do I add per fragment lighting to a tessellated model?" The same way you would for a non-tessellated model. You ought to be able to take the same fragment shader you use for a regular model and use it for a tessellated one (obviously, you need to match interfaces). If your bumpmapping is getting in the way, try it without bumpmapping. –  Nicol Bolas Nov 27 '12 at 21:50
    
In order for me to utilize a standard fragment shading model I need smoothed normals, which are fine if I use a non tessellated model, the normals are passed as attributes to the vertex shader, then smoothed across to the fragment shader. The problem is that after tessellation, there are no normals for the new polygons. Calculating them in the geometry shader results in a faceted look, and I can't smooth them as I only have access to one triangle in the geometry shader. –  Finlaybob Nov 28 '12 at 13:01
1  
"The problem is that after tessellation, there are no normals for the new polygons." If you can calculate positions for the new triangles, you can calculate normals just fine too. And how are you calculating your texture coordinates? –  Nicol Bolas Nov 28 '12 at 15:05
    
Of course I can calculate the normals, I said that already! What I cannot do is change the normal based on the surrounding normals, which results in facets (like this). texture coords come from glTessCoord, the built in variable in the tessellation evaluation shader. –  Finlaybob Nov 28 '12 at 16:30
1  
Are you talking about OpenGL 4.x's tessellation functionality or the old gluTess stuff? They're not at all the same, nor are they compatible. "What I cannot do is change the normal based on the surrounding normals" Then you're not calculating the vertex normals. That's what your Tessellation Evaluation Shader should be doing. –  Nicol Bolas Nov 28 '12 at 16:44
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.