OpenGL Instancing in VR


, , , , , , , , , , , , ,

Arkwood was leafing through the pages in his big black Hubble book.

‘I want to stroll along the rocky ring in the Sombrero Galaxy, eating popcorn,’ he mused.

And so you shall!

I cranked open my C++ Microsoft Visual Studio application (with OpenGL graphics library and the Oculus SDK for Windows) and added every inch I’d learnt from Learn OpenGL tutorial Instancing.

‘Put on the Oculus Rift virtual reality headset and walk amongst the 10,000 rocks that wrap around a planet!’

Arkwood was gasping, as he fell to his knees in wonder. ‘Far out, maaaaaaaan!!!’

With OpenGL Instancing, you can send one rock to the graphics card and let it spawn thousands of rocks – each rock with its own position, rotation and scale. And because it is all happening on the graphics card there is no ugly performance hit. Indeed, I could add many more than 10,000 rocks, but that amount seemed about right for strolling amongst.

‘Can I do other galaxies?’ my buddy cried, ‘And particles around a black hole… and dark bands of gas… interstellar…’

Arkwood fainted, into nothing.