July 18th 2016 by SDGNelson
This weekend I started putting together a few shaders for consistent rain/wind across all objects.
While I like the appearance of the current rain in Unturned, I can't argue with some extra detail!
The particles are essentially the same, but the real new element is in the wet surfaces which consist of puddles/ripples on top and streaks along the sides. The ripples were especially interesting to animate and after many hours of crazy tests I came to this solution:
I decided on the red channel representing the ripple shape, the green channel as ripple progress and blue as a frame in the animation. For example if the difference between each blue shade is 0.1 and the input is 3.42 then the circles between 0.4 and 0.5 will use the green area close to 0.2. Depending on the rain strength up to 6 samples are taken, although this can get a bit repetitive even with different UVs/timescales so I hope to work out something for that.
The streaks are another simple (diplanar?) mapping, and while the gentle slopes look okay it would be nice to improve them a bit. I tried moving the up-facing UVs along cross(cross(up, normal), normal) - a vector in the direction to slide (used for character movement on steep surfaces in Unturned), but that didn't work very well so far.
Unfortunately I doubt this will make its way into 3.0 because it would require making a new "weather" mask for each mesh indicating which surfaces are inside/outside, but I do think it's worth continuing for future projects so that the kinks can be worked out from the start.
Looking at a time lapse of any game I like to see all the motion around the environment, and adding windy effects is probably the easiest first step.
Alongside the dynamic environment it's very satisfying when objects like the grass and leaves react to your actions, so I'm interested to see what other details I can make responsive. Having my own wind system rather than relying on Unity's will be very handy for making it consistent across all objects because they can share the same equation/algorithm. Going forward I'd like to better animate solid objects like branches, and while the XZ animation works well for grass I'd like to improve it for leaves on trees.
Ropes will be useful for many details like power lines I expect, and I separated the mesh generator from the rope itself so that it can be reused for other effects like bullet trails. The mesh cross section is customizable so that you could for example use a vertically aligned rope for christmas lights. The amount of slack isn't currently physically accurate, so ideally I can figure out an equation for that in the future.