I'm tinkering with an open source project that uses OpenGL for rendering in 3D. In the construction of the materials I see code like this:
// set ambient material reflectance
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mAmbient);
In other examples, this is used:
glMaterialfv(GL_FRONT, GL_AMBIENT, mAmbient);
So my question is, what is the difference here? Under what circumstances would it look different and, if my volume is enclosed with all normals pointing outwards, is there any performance difference?
One sets the material for front and back faces, the other, just front faces. If you culling back faces, it's not going to really matter. If you're not culling back faces, well, you'll see the material on the front face only.
If you're enclosing a volume, you probably won't directly see the back faces - the only way you would is if the camera was inside the volume. If it's outside, then you'll never see the back faces, and there's little point to rendering them. (Which is why in many games, if you force the camera into an object, it'll look like all the polygons are 1 sided: that's back face culling) OpenGL just has the ability to set different properties for the front and the back faces of a triangle/quad/etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With