Top
particlefeature

Underwater Particle Shader

When we were working on Shark Escape one thing we really wanted to capture was the underwater atmosphere. I always had this shader in mind for how the particular matter would appear.

When it actually came to writing the shader I was really pleased, it actually worked like I expected! The shader uses a specially generated mesh which has each particle being made of 4 vertices in the exact same position, normal and color, the shader then moves each vertex in screen space based on its uv coord, which I think is fairly standard billboard behaviour. The normal direction is the direction the particle will travel in plus the magnitude providing some variation in speed and slight variations in vertex color provide further variation.

The shader then takes the vertex position and the world position of the transform to move the particles in world space but re wrap them within a range of the transform. The result is up to 16250 particles all moving in a single drawcall, when this is parented to the camera you get back endless field of particles that seem to have an infinite lifespan, you can pick a particle and follow it and it’ll never die!

In my stress test this system was tested against a 16250 particle system and was around 7 times faster!

Check out the demo below (use up, down, left and right to move)

Comments are closed.

//