I told Arkwood that I had added a point light to my virtual room.
‘Put on the Oculus Rift virtual reality headset,’ I said, ‘and see how the wooden containers closer to the light are much brighter.’
My C++ Microsoft Visual Studio application uses OpenGL graphics library and the Oculus SDK for Windows to render the virtual room to the Rift. But how does the point light work?
Learn OpenGL article Light casters has detail on adding a point light. I configured the attenuation using a constant of 1.0, linear of 0.7 and quadratic of 1.8, granting a distance of 7. The light fades quick and then slowly dies. You might be able to make out a fourth container in the background, doused in a deathly blackness.
Arkwood gobbled up his frankfurter, keen for a shot. Here’s the video of how he got on:
The fragment shader calculates the attenuation, applying it to the ambient, diffuse and specular components of the Phong lighting model.
Arkwood munched some Monster Munch and said, ‘Spooky. Real spooky.’
It is rather.
‘When I wander into the dark corners of the room, I wet myself.’
Hmm. His jeans had suffered around the crotch.
Fingers full of chips, he continued, ‘Yet when I wander into the light, I am reborn.’
‘And when I am but betwixt I am neither euphoric nor in fear.’ Arkwood unwrapped a banana.
‘And now,’ my chum announced, ‘I am to be sick.’
The bastard threw up into the headset. He blames VR motion sickness. I blame the food.