top of page
Writer's pictureDan Nirel

Snow Effect

Updated: Jan 22, 2019

Initially I thought about adding snow as a particle system, whereas each particle is a sheet of multiple snowflakes. When the sheets move across eachother, it's difficult to see that some of the flakes actually move together.

This proved problematic: the snow could not move with the camera (it has to be anchored to the world), so it required spawning new snow in advance in redundant areas. Too far ahead, this quickly became far too expensive in FPS. Too short a distance, and a reasonable velocity would have brought the player to a place where snow has just started spawning and hasn't fallen yet (the particle system had to spawn snow above the camera). Furthermore, a quick movement above also resulted in seeing unsnowed areas. Finally, whichever way you look at it, this was expensive.


Once I decided to implement depth-of-field myself as a postprocessing, I thought I'd also hook the snow to the same shader, instead of a particle system.

Gluing the snow-sheet to the camera was easy enough:

Making it "fall" was also simple (using the shader's builtin _Time variable):

Glued to the camera, it didn't change scale when the camera moved in and out, so that was the next step. I sent the camera's Z position to the shader and did some arithmetics.

It still moved with the camera though. I sent the whole camera's position to the shader, and after a lot of trial and error managed to match the texture's UV coords with real-world coords. Once the camera moves in one direction, the texture moves in the other (both axes):

Adding sinusoidal movement in the X axis:

And finally, I added more layers of snow using the same code:

And voila:

The snowflakes are not too fancy, and there's no mechanism in place yet to control snow intensity, but it's good enough for now because when I close my eyes I see uniform snow falling.

131 views0 comments

Recent Posts

See All

Comments


bottom of page