Menu
Forums
Login | Register

Home > Forums > OpenGL ES > FLAT_SHADING in ES question Page :  1 
FLAT_SHADING in ES question
The OpenGL ES tutorial on this website uses glShadeModel(GL_FLAT), but according to the OpenGL ES 2.0 spec this is not a supported OpenGL ES command. Is this an issue with the spec not being right or the tutorial?

Furthermore, if you can't use glShadeModel(GL_FLAT) in ES, how are you supposed to get these effects through shaders. I'm a shader programmer, and I don't see how I can accomplish this. GL_FLAT basically says the fixed functionality of OpenGL isn't going to interpolate the color, but there's no way to pass data between the vertex and fragment shaders except through a varying variable. And these variables are interpolated.

So can anyone confirm or deny any of these assertions?

jason
jgorsk2@uic.edu
Masters in Computer Science
Hi,

Firstly, these tutorials cover OpenGL ES 1.x and therefore glShadeModel is perfectly valid.

When stable ES 2.x implementations are released, this will still be easy to accomplish as you can just ensure that you are using a surface normal and that all vertices on the triangle are given the same color.

Regards,
Grant
That wouldn't work though, because what flat shading does is take the last vertex color and assign all fragments with that color right?

All vertices come normal information, if you use their normal to compute the light color, you want the fragments of a triangle to be assigned the light color value from only one of it's 3 vertices.

The problem with what you said is that triangles share vertices. So if you make them all the same color that might accomplish what you want for a single triangle, but what about that triangle's neighboring triangles?

jason
Hi,

1st paragraph:
Yes correct, flat shading takes the last vertex as the color for the polygon.

2nd paragraph:
If all vertices of a triangle are given the same normal and same color, you will get a flat-shaded triangle.

3rd paragraph:
As far as I know, you would have to duplicate some vertices so that they are not shared. This is same for the normals.

Regards,
Grant
There has to be a better way. I mean, if I have to duplicate my vertices that makes flat shading almost more expensive then smooth shading.

jason

Home > Forums > OpenGL ES > FLAT_SHADING in ES question Page :  1 

You need to be logged in to reply to this topic.


All Rights Reserved, © Zeus Communications, Multimedia & Development 2004-2005

Read the Disclaimer

Links