Wednesday, June 22, 2016

Day 38: Boarded Up

Time for the most difficult part of my programming career...rendering a quad!

Gasp! Nah, although I had quite a bit of trouble rendering the thing. Apparently I had forgotten to set the index buffer indices correctly. We got something on screen!


Oh wait, we should probably have it face the viewer at all times. If you imagine the x and z difference of the object position to the billboard as two sides of a right triangle (the smaller sides, not the hypotenuse), then voila! Taking the arc tangent of those and decoding it to radians leads to the rotation that the object must have at all times in order to face the camera!

Wait a second:


This tree doesn't look right. Perhaps we should enable alpha blending?


Ahh! A ghost! Wait wait, I forgot to use the alpha channel as a coverage mask:


There we go. Taking the tree and firmly placing it into the ground requires a bit of an offset, but it's slight compared to the rotation and alpha.

Next up: instanced rendering! When you don't want 6000 vertex buffers.

No comments:

Post a Comment