Arkwood plucked a dead slug from his pocket.
‘Why is there a dead slug in your pocket?’ I asked him.
He looked at me, baffled, and then replied, ‘Why, to remind me that tonight I must cut my toenails.’
Of course. Anyway, I told him, take a peek first at my OpenGL spotlight:
A spotlight is a light source that only shoots light rays in a particular direction. Everything within a certain radius of the spotlight’s direction is lit, otherwise it be darker. Learn OpenGL article Light casters has the lowdown.
I informed my chum that the type of spotlight I had coded was a flashlight, a light source that shoots its rays straight ahead from the players position and orientation.
We pass to the fragment shader the position and direction of the flashlight, as well as an inner and outer radius cutoff, so that the flashlight fades around the edges. The attenuation from the previous post, OpenGL point light, ensures that objects further from the flashlight are darker also.
Not only that, but the steel borders of our wooden containers shine and sparkle due to the specular component of our Phong lighting model (the Phong lighting model has ambient, diffuse and specular components).
Akrwood was excited. He grabbed the Oculus Rift virtual reality headset, eager to explore the virtual room with a flashlight helmet upon his head.
Wait, wait! I screamed. I ran my C++ Microsoft Visual Studio application – which makes use of the Oculus SDK for Windows – and his adventures began.
Here’s a video of Arkwood with the flashlight:
‘Wow, that’s great!’ he said, extracting a dead squirrel from his crotch.
‘What the hell is a rodent doing in your pants!’ I cried.
Arkwood shook his head in disbelief. ‘Why, everyone knows that a dead squirrel in one’s undergarment is an aide-mémoire.’
‘To what exactly!’
He sniffed. ‘That there is a dead slug in my pocket.’