BlackWindBooks.com | Newsletter! | risingthumb.xyz | achtung.risingthumb.xyz | github.com/RisingThumb | site map

risingthumb.xyz Lambs to the slaughter...

Snow Deformation

Introduction

Snow deformation is a cool effect where as you walk in snow, it deforms it in a trail along where you walk. There's a handful of different ways this can be done. Here I cover a way using particle effects, an orthogonal camera and a Shader on the deformed surface.

Implementation

We begin with a camera that is positioned below the surface we want snow deformation on. This camera is an orthogonal camera. This camera should only render particles we draw from our snow deformation particles. This camera will pass what it renders into a Shader. This texture will then get used in our Vertex Shader to deform the mesh where there is white in that texture. You can optionally also use this texture later in the Fragment Shader to apply a different texture where there is snow deformed.

The Shader(Godot Shader language) I made is as follows:

shader_type spatial; 
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;

uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
uniform sampler2D surface_noise: hint_default_white, filter_linear_mipmap, repeat_enable;
uniform sampler2D snow_displaced: hint_default_black, filter_linear_mipmap, repeat_disable;

uniform vec3 uv1_scale;
uniform vec3 uv1_offset;

void vertex() {
vec4 displacement = texture(surface_noise, UV);
vec4 snow_displacement = texture(snow_displaced, UV);
VERTEX.y = displacement.x*1.0 + displacement.y *1.0;
VERTEX.y*=0.5;
VERTEX.y -= snow_displacement.r*2.0;
COLOR.xyz = vec3(max(VERTEX.y*3.0, 0.2));
UV = UV * uv1_scale.xy + uv1_offset.xy;
}

void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo, base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb * COLOR.xyz;
}

With the above shader applied to your surface, and your camera correctly positioned below the surface rendering only the particles, you can get an effect similar to this. If your orthogonal camera isn't one to one in size as the surface, you may have to do some additional work to scale the UVs so the snow deformation applies to the correct parts of the mesh.

This is approach is fairly cheap. The main elements that will affect your performance with this approach is your particle system, so how many of them you have, and the size of your camera. The other benefit of this, is you can move the camera, which is very useful if you're doing clipmapped terrain. Because of this, it means the snow trail will persist as long as the particles persist.

Other benefits of this approach include how you can tweak the emitter for your particles to spawn in specific places, useful if you have a car or tank that only touches the snow at certain points. You can also tweak the texture and blend modes of your particles so they create patterns on the snow, perfect for footsteps or the lines of tank treads. By changing the blend mode you can make it so multiple steps in the same place make the snow deform more.

You can also take this approach further by looking into Tessellation.

Other implementations and approaches

I'll briefly cover the other ways I'm aware of. The simplest is just using decals that conform to the normal of their surface. This is also more effective if it is a parallax mapped decal.

Another approach is to directly deform the mesh itself. As you'll see, this is what we do in the Vertex Shader we use, however this mesh deformation is on the GPU side. Our deformation isn't on the CPU side so won't end up in deformed collisions. This would be something you'd need to do if you want snow that deforms your collision or navigation meshes.

Where else can this approach be used?

This approach could be used for some basic water ripple effects. As water ripples are just expanding concentric circles with additive blending, it shouldn't be hard to achieve this(though I think you would lose the reflective property of water). Considering water in videogames rarely achieves Baldur's Gate Dark Alliance's water, I think this concession is fine.

You can also use this effect for small craters from explosions, and for trails in sand dunes.

Games that do snow deformation

As a small showcase of the effect, I made a small non-exhaustive list of games that implement snow deformation

Red Dead Redemption 2

Helldivers 2

Deep Snow Delivery

Journey(Spoilers for ending)


=> This blog post featured as a guest post on goeshard.org

Articles from blogs I follow around the net

Access Control Syntax

I’m still tinkering on a scripting language for my hobby fantasy console project. I’m ashamed to admit this, but up to this point, the language had absolutely no notion of modules. Literally every source file is dumped into one big global namespace and compi…

via journal.stuffwithstuff.com May 26, 2025

The British Airways position on various border disputes

My spouse and I are on vacation in Japan, spending half our time seeing the sights and the other half working remotely and enjoying the experience of living in a different place for a while. To get here, we flew on British Airways from London to Tokyo, and I…

via Drew DeVault's blog May 5, 2025

...

pt. i pt. ii pt. iii

via I'm not really Stanley Lieber. April 17, 2025

Generated by openring