Interactive Snow w/ Tesselation

Hi everyone! Today I'm sharing one of the environment shaders I'm using in Astro Kat!

It uses the same technique as the Interactive Water tutorial.

The difference is in the shader that's reading the RenderTexture.

Let's get started:

RenderTextures again

The setup for this is the same as the Interactive Water Tutorial , so for a more in-depth walkthrough , please look at that post :)

Quickly going over the setup again:

  • You need an orthographic camera pointing down. Size 15-ish
  • Add this script  to it to feed the position and rendertexture to the shader
  • Create a new RenderTexture and drag it in the RT slot, add your player to the Interactor slot
  • Make a new Layer for the orthgraphic camera to look at, where your particles will live


 The Shader 

Here are the most important parts of the shader :)

Tesselation

Subdivision is only happening on the snow parts

There is distance-based and Vertex Color based tesselation. so it only subdivides when you're close, and on the places where you've added red vertex colors.

A better explanation than I could give on Tesselation is HERE 

Here you can see that in addition to sending through the distance, the Vertex Color is also send into the tesselation calculation, so we can specify where the tesselation should be.

Vertex deformation

Changing the Snow Height and Snow Depth values

To give the layer of snow impression, the vertices need to be pushed up, and where the particles are, they need to be pushed down.

Push up using the normals, only where the Vertex Color Red (v.color.r) is, with an extra noise.

Pushing down using the normals, only where the Green path from the Rendertexture (RTeffect.g) is, and only where Vertex Color red is.

Sparkles

I added a very rough sparkle effect, probably better ways to do this, but it works well enough if you keep it subtle(r than the gif :D)

A noise texture gets projected normally at a large scale, then multiplied by the uv * the screenposition. Then with a step function only the brightest parts are shown, and only on the Snow using the Vertex Color Red (vertexColoredPrimary)

Masking the RenderTexture

The base setup can lead to weird lines when you move your camera away from particles, this is can be avoided by setting a mask on the RenderTexture. Add this PNG Texture, set to transparent, and CLAMPED to the Material


Here is the final shader with Comments: Pastebin Link 


Note about Vertex Color Painting: In this tutorial I used Polybrush again to paint the vertex colors. With no vertex color, a model is colored white by default, this means that the material will show up fully covered in snow. Flood it black, then paint red where you want the snow for multiple textures.

Also Polybrush is about to get an update which makes it more stable, might be out by the time you read this, it'll show up in the Package Manager and is worth a look!

The Particles

The additive green particles over the snow trail

Compared to the water ripple, the interaction particles for this effect are very simple

As a child of your interacting meshes, set a new particle system with Start Speed 0.

Start Lifetime is how long you want to snow to stay, I've set it to between 10 and 15.

Set the Start Size to be about as wide as the mesh thats deforming the snow. with a slight random variation in it

In Emission, the particles need to spawn 10 Over Distance, and to make sure there is always an indent, also set Rate over Time to between 1 and 2

Shape is simply set to a tiny 0.1 Edge

Set the Color over Lifetime to fade to alpha 0 in a green gradient (Make sure it's pure green to avoid mixing with other particle effects!)

Finally in the Renderer;

Set the Render Mode to Horizontal Billboard

Set the Material to a standard white circle, with the Legacy Shaders/Particles/Additive (Soft) shader (or equivalent of the soft additive mode) I'm using a simple soft circle

Link to full image of particle system 

It should look similar to this now, like a blobby trail. The variation in size makes it a little more natural looking

Snowfall

A little extra: quick setup for some snow particles falling down

  • General: Start size between 0.5 & 0.7, Increase max particle to 2000-ish
  • Emission: Rate of Time 200 
  • Shape: Box , Emit from Volume, scale of x-50 y-50
  • Velocity over Lifetime: Worldspace, Orbital X/z between 0.1 & -0.1
  • Renderer: Billboard Standard Particle shader
  • Optionally turn on Collision

Link to full image of Particle System 


That's it! I've had a lot of fun just moving around in this little tutorial setup. Hope you will have fun with it too!

Become a patron to

147
Unlock 147 exclusive posts
Be part of the community
Connect via private message