I’m a developer of CAD software. A customer has requested that texture mapping be restricted to the front faces of polygons. I can’t find that OpenGL supports an easy way to achieve that, like it does for lighting.
The solution I’ve thought of is: turn texturing on, cull back faces, render; turn texturing off, cull front faces, render again; swap. I really wish there were a simpler, faster approach. If you know of one, let me know. The answer has proved to be google-resistant, at least with the search terms I’ve thought of.
Also, if anyone can comment on whether my customer’s request seems like a common one (that is, consistent with what is available in other software), I’d appreciate it.
Me too. Go for two passes. If you don’t already, use VBOs for uploading vertex data. The two passes won’t be slower than a single pass method (if it existed). About the simplicity: managing frontface texturing in one pass and backface lighting in another seems much simpler than mixing both things up in one pass, don’t you agree?
That depends on where your bottleneck is. If you have an enormous amount of geometry yet use a simple fragment shader (as is quite common for CAD), it may well be possible that the cost of processing geometry twice is higher than adding a simple conditional to the fragment shader. It also depends on the hardware used.
As for simplicity, if you’re using just a single fragment shader adding “if(gl_FrontFacing) {…} else {…}” to it is probably as simple as it gets. Certainly worth a try.