top of page
Writer's pictureDan Nirel

Trees and Snowpeople

Updated: Jul 21, 2019

Spawning the trees themselves was painless: I plugged them into the game's spawning system which randomizes how many instances to spawn in each chunk, and where to spawn them within the chunk.

They were, however, three dimensional:

which meant that some parts of the tree can get out of focus.


I wrote a vertex function for the trees' surface shader which flattens them after applying a random rotation, and adds wind effect to the treetops.


Then there's the matter of syncing the transform and scale over the network,

and voila! The final result:


Next up, using GPU instancing for repeating scenery objects like trees and snowpeople. This means sending the tree's mesh and texture to the graphics card only once, for up to 1023 trees at a time. This actually already works in single player and is far superior in performance to drawing each tree separately and even to batching, but once a tree doesn't have its own game object, syncing its parameters (position and scale) over the network required to synchronize a list over the network. This turned out, yet again, to be glitchy (sadly, Unity's synclists rarely actually work). I'll think of a stabler alternative.

42 views0 comments

Comments


bottom of page