Tags

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

‘I am a simple man,’ Arkwood said. I was silent.

‘I carry simple pleasures. A garden, perhaps. A smallholding on which to plant my veg-i-ta-bles.’ He leaned forward and frowned. I wanted him to stop being a poet.

But on he went. ‘Cry me to sleep, if not for the soil that runs not through my wanton fingers.’

I told him he said Not twice. Cancelled his shit out. His face turned red. Anyhow…

‘Here is your land!’ I booted up my C++ Microsoft Visual Studio application (with the Oculus SDK for Windows and OpenGL). He put on the Oculus Rift virtual reality headset and saw a small piece of land – soil – on which to grow his spuds:

The grass is a simple texture on a 2D quad. But by making use of the Learn OpenGL tutorial Blending I am able to discard all the fragments of the quad that do not display the shoots of grass. Easy transparency, allowing the soil between the shoots to render.

Here’s the fragment shader code with the GLSL discard command:

"#version 330 core\n"
"uniform sampler2D GrassTexture;\n"
"in      vec2      oTexCoord;\n"
"out     vec4      FragColor;\n"
"void main()\n"
"{\n"
"   vec4 texColor = texture2D(GrassTexture, oTexCoord);\n"
"   if(texColor.a < 0.1)\n"
"		discard;\n"
"   FragColor = texColor;\n"
"}\n";

We can inspect the alpha channel of the grassy texture, determining for each fragment whether it should be discarded or not. Not.

Arkwood held his crotch and cried. ‘But I wanted a banana tree too!’

The white van came.

Ciao!

Advertisements