• Register
Post news RSS Snow deformation (November 28, 2019)

So far I’d been focusing on rain effects, but now its time to move on to snow. It’s almost December and the weatherman says it’ll snow tomorrow where I live, so I’ll have plenty of real-life references for this effect

Posted by on

23

Snow deformation
Imgur.com

"So far I’d been focusing on rain effects, but now its time to move on to snow. It’s almost December and the weatherman says it’ll snow tomorrow where I live, so I’ll have plenty of real-life references for this effect. Rain, flood, and snow are the key 3 weather effects I have planned for this game at the moment. Rain and flood are looking good now, so snow is next! Snow deformation is something I’ve been wanting to try for a long time. So many AAA games this generation have been doing amazing snow deformation and I was always curious how it was done. Well, many may web searches and video tutorials on different approaches for this, I settled on one approach to try. Compute shader + vertex shader + tessellation.I already use compute shader for blood painting and rain particles, so I have a good idea of how to use it. Vertex shader is pretty basic. But tessellation? That was a fancy word I kept hearing in Digital Foundry reviews, but I didn’t know how it worked. Fortunately, it’s really easy to implement. Essentially it adds more vertices into meshes for higher quality vertex displacements.

Imgur.com

I currently have it set so the snow surface closet to the player will be more tessellated. It was pretty easy to set in my snow shader. Just one method before the vertex shader and some simple shader pragma modifications.

So how does this whole thing work? There’s a camera above the player with clip planes above the character’s knee and below the character’s feet. This camera draws to a render texture which gets blitted onto a part of a large texture. This large texture is the deformation map for the entire level. You can think of it as moving characters drawing on to a large texture with brushes attached to their feet. Since 2k resolution for the entire level is low, I apply a low-cost blur on the texture in the compute shader.

Then this large texture is fed to the snow terrain, which uses this texture in the vertex shader for deformation. Vertex shader translates its world position into the UV position of the large deformation map and determines whether a vertex should be depressed or not. Tessellation subdivides areas near the player, so this vertex shader runs with more detail near the player.

And that’s basically it. Add some more stuff in the fragment shader for detail and you get a pretty convincing snow terrain that deforms and stays deformed when the player and other characters walk on it. I’ve only seen this effect in AAA games like Rise of the Tomb Raider, Red Dead Redemption, and Death Stranding, so I thought it might be super graphically intensive, but it has a fairly low impact on the GPU. It took a few days to figure out but I’m really happy with how it looks!" (c) Sean, the Wonhon: A Vengeful Spirit developer.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.