two different colors for in and out sides


Thanks to forums like this one, I managed (I am not a programmer, but someone who needs to display data) to write a nice OpenGL program that draws a complex hollow object, for which I have the vertex data. I got it to work nicely with shade, lighting and all that, but now I need to display different colors for the inside and the outside of my object.

I read that this can be achieved with backface culling and drawing my polygons twice, once CCW and the other CW. However, I am finding some mutually contradicting advise. Thus, before I jump into modifying my code, I wondered whether anyone could share some words of wisdom on this, ideally showing me an example code, which is the way I learned to code myself :wink:

Thanks a million,


If you use materials (not just color) then you can simply define different materials for front and back faces.

Rendering polygons twice is not a bad idea, too. If you don’t have a lot of vertices it will be as fast as single pass.

Use two sided lighting where you specify a backface material and the winding flips the normal and changes the material… OR do it yourself, flipping the normals (use duplicate attributes) and apply pposite face culling.

Some drivers will handle this very simply and elegantly with optimization, others will pretty much do in the driver what you would do in your application.

Two sided lighting tended to be one of those premium features manufacturers reserved for high end cards so they can charge a premium for Quadro DCC class hardware. It MAY be really slow on a gaming card for no reason other than marketing & product differentiation.

So, in conclusion it can pay to implement BOTH systems because on the high end two sided lighting can be fast especially on modern hardware and Quadro class DCC platforms, but may be unacceptably slow on very capable gamers class hardware.

There is a third way involving shaders & doing your own lighting but that’s probably advanced for you. It is attractive because it basically implements two sided hardware lighting in a simple shader for all platforms.