Hi everyone.
I’m implementing a new mesh highlight system for my OpenGL application: it works by overlaying an outline drawing on top of the fully rendered scene.
The problem is that the worst-case scenario consists in drawing the same scene twice, the first with lighting shaders and post-processing effects, the second is only a false color drawing for outline extraction.
This means almost doubling the number of draw calls which slows down the rendering time considerably with complex scenes ( > 5.000 individual meshes, no batching, 1 or 2 draw calls per mesh for the scene, 1 draw call per mesh for outlines).
Is there a way to leverage OpenGL features to make this process cheaper?
I was thinking about MRT, with a color output for the fully lit scene and a second one only for later outline detection. However, if I need to outline only a subset of the scene I’d need separate depth testing relative to those color outputs (a mesh may be occluded in the scene but still highlighted with outlines as you can see in the image above).