NokiMo
Dare Looks
Dare Looks

patreon


Trees, Part 3: Tree Huggers Do Not Watch

There were no trees. Then there were trees. And now there can be no trees, once more.
Time to live out your wildest deforestation fantasies!


Respect the Rustle

This effect I'm particularly happy with: The wobbly rustling of the foliage!

It just adds a lot to the feel of tree-ishness and makes them a lot less static.

There's two things going on, here:

The shader trick works almost identical to the wind animation I have shown in the previous post, except this time I pass in a world position and falloff, to limit the effect to a certain part of the mesh: The part that the player has collided with.

On the tree is a simple script that keeps track of player collisions, and whenever the player collides with the foliage, the script animates the relevant shader parameters to make it rustle.

So, except for the collision detection, there isn't actually any physics calculations going on, to pull off this effect; all the magic happens in the shader!

My foliage shader has gotten a bit complex.


Lots of LODs

The trees have a bunch of geometry, and while they aren't the most complex models in the scene, they still add up. To help with this, I'm finally using LODs (from "level of detail") to cut down on polycounts for models that are further away from the camera.

I've generated these lower detail versions of the meshes using a third-party Unity plugin called PolyFew, which proved to work really well and save me a bunch of time!

Now, you may be wondering: "Hang on, if LODs help with performance, why don't you create low detail models for all the objects, in the city?"

What a fair, and sensible, question to ask! A lot of my geometry for the building and cars isn't exactly optimized all that much, but that's.... mostly by design.

Now there's a scene that could do with some optimization...

They need dense geometry to work well with the deformation effects. I could create LODs, but when a car's model deforms, all its LODs would need to deform as well, which would add a higher load on CPU's. Alternatively, I could not deform the LODs, but then you would see the damage undone, when you move away from a car or building, which would look jarring (and disappointing.)

The trees are the first objects in the city that don't get permanently deformed when damaged (it would be weird to see a bunch of foliage and wood bend like metal), which is why they were perfect candidates for LOD generation!

If polycounts turn out to be an actual problem for performance (so far that doesn't seem to be the case, luckily) there's a few tricks I can pull. But until then... let's be lazy.


Thanks for your support!

That's it for trees, I think! I may still do some minor work on the game this week, but I'm thinking about taking a 1~2 week break afterwards, before moving on to the next topic: Between larger topics is always a good point to take breaks, strategically, and I've started to feel slightly burnt out, lately. So hopefully I can take it slow for a little while and come back with plenty of energy!

Trees, Part 3: Tree Huggers Do Not Watch

Related Creators