After a long absence, trees have made it back into Playform!
Development
One of the big requirements was the voxel material system, because I didn't just want to have tree-shaped dirt. The leaves are still shaded using the grass shader though, because I was too lazy to work on a better texture.
On that note, you might notice that the terrain has a more textured look! I put some time into making passable-looking procedural texture shaders, instead of the embarrassing sine-wave-based mixing between plain green and plain brown. The grassiness of the terrain is controlled by a noise function (huge thanks to ashima/webgl-noise!), and also the slope of the terrain - the steeper the terrain, the less grass it has, on average.
All this texturing is done in the shaders right now. I do want to eventually move these into real textures, and let the user "paint" the terrain.
The trees themselves are defined through the same code that defines the terrain and the sphere brushes, although this that code's changed a little with the material system. You map every point in space to a material. Since the trees are placed with a brush, it's also valid to say "I don't touch this point". This code isn't the nicest to write: even with the trees as simple as they are right now, there's a fair amount of "wait am I in this part of the tree? Oh I'm not? Alright, how about THIS ONE?" I plan to put some work into composing shapes like trees out of smaller shapes like spheres and columns.
TODOs
The trees don't spawn naturally right now; the user can place them with a left click.
They also all look exactly the same. Branches and better leaves are a must-have. Different kinds of trees would also be nice.
No comments:
Post a Comment