I Made Fog (and an Infinite Grid, too)12 Jan 2016
While my next post was destined to be about the voxely thingies Payback Time's world consists of, I got derailed into fixing a small issue that's been on my TODO for a while now.
So, my map editor has a grid that should work as visual aid to the user. The grid has traditionally been a static mesh with known proportions: vertices, indices, lines and all that jazz - very inflexible and tedious to manage, to say the least. Also, so far the background of the scene has been completely void of color.
Enter new backdrop, with an infinite grid and a subtle, low-frequency textured skydome:
A couple of words about the implementation. While rendering a casual grid on the screen seems very trivial, there's a little more (or less) going on here, actually.
The backdrop as a whole is done by per-pixel raycasting with a single quad. In simple terms:
- Render a quad covering the screen.
- For each pixel, find the intersection of the view ray with the ground plane and with an infinitely far-away sphere surrounding the scene.
- Use a periodic function, such as sin, for generating grid colors per-pixel.
- Use a function or a texture for the skysphere color.
In case you're interested in some more details on the above approach, have a peeky here:
The shader comments/docs are scarce, so drop me a line in case you'd want to try it out yourself!
Next time it'll be about voxels and meshes. And about how UV-mapping can warp one's mind in ways unexpected.