Instanced-based VR rendering in OpenGL

967 Views Asked by At

I'm trying to use instancing to do VR rendering in OpenGL with 1 draw call, 2 instances (one for left eye, one for right eye). The vertex shader then translates the vertices left for instanceID 0 and right for instanceID 1. The only thing I need more is per-instance viewport for automatic hardware culling/clipping. This is doable in directX but is it in OpenGL?

1

There are 1 best solutions below

0
On

Recently I was actually implementing instanced stereo rendering for VR and had the same problem. I had the choice of using geometry shader for instanced viewports but I didn't want the overhead it'd introduce. So, in the end I ended up shifting the perspective for each view and using a clip plane.

So that's probably what you're looking for, a clip plane. It's really simple to implement in a vertex shader too, you just pass the 'x' coord into gl_ClipDistance. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_ClipDistance.xhtml

Good luck