Archive for February, 2011

Steam shader effect

About a month ago we wrote about our shader-based heat shimmer effect. Another effect we developed for the Danfoss-experience project is illustrated in the video below. It tries to reproduce the effect of a window or mirror steaming up entirely as a shader.

Our method uses a gradient image G which dictates the overall "growth" of the steam. A variable t is animated over time from 0 to 2 and the amount of steam s for a given position \mathbf{x} is then defined by a clamped linear interpolation over some range r:

s = \mathrm{clamp}\left(\frac{t - G(\mathbf{x})}{r}, 0, 1\right)

To make the growth more interesting, we modify G with a noise texture. The color of the steam c_s is determined from a lookup into a texture-rendered version of the scene which has been blurred by a Gaussian filter. To this value, we add some white noise to give the steam some texture. Finally, we add a value which can be tweaked to give the steam the desired amount of lightness.
The pixel color is then given by the unmodified color c interpolated with the steam color:

\mathrm{lerp}(c, c_s, s)

The final touch to our effect, is the ability to interact with the steam by dragging the mouse around like a finger on the steamed up window. This is implemented by adding a mask texture and modifying the amount of steam by taking the minimum value of the mask and s. The mask texture is updated by blending black lines into it where the mouse has been when it is being dragged around. Furthermore, a dark grey color is constantly blended into the entire mask in order to make the older strokes steam up again.

"Particle Director" Unity Extension Released

Our first Unity extension - Particle Director - just went live on the Unity Asset Store today. It is a tool for specifying custom particle velocities for particle systems. With it you are able to specify motion of the particles by placing control vectors, solids, sources, sinks, etc.

Check it out here.

Unity Custom Particle System Demo

We have been working on a customizable, artist-friendly way of specifying particle velocities for particle systems in Unity. The built-in particle system animator only allows for a very limited range of motions, and it would be really hard to make the particles flow around obstacles or create vortices.

But before we dive into the details of our custom particle editor, why don't you have a look at the result in the demo below? (We also demonstrate a Unity implementation of the shimmer shader effect from the previous post as well as a shader which creates foggy mirrors)

The screenshot below shows our editor in action. You are able to specify motion of the particles in a 2D plane by placing control vectors, solids, sources, sinks, etc. Velocities are then computed for the entire plane by running a fluid solver for a certain amount of iterations using your inputs as boundary conditions. This only takes a few seconds and ensures that you get a nice and smooth velocity field in the entire plane. In the scene view, control vectors, solids, sources and sinks are displayed in order to help with aligning the motion with the scene geometry.



We have chosen to create a 2D editor instead of a full 3D editor since it greatly simplifies the user interface as well as reducing the computational load of the fluid solver. Our system still allows you to create 3D motions by extrapolating the 2D motion into space using a linear fall-off.

But more importantly, the system allows for using a linear combination of several velocity fields. Therefore, to specify a 3D motion you create several 2D motions and position them differently in your scene. The below screenshots show 5 planes combined to create a swirling, tornado-like motion. The highlighted plane in the left image specifies the horizontal motion, while the the highlighted plane in the right image and the 3 remaining planes contain sources and dictate an upwards motion.

The custom particle system fully integrates with the built-in particle emitter, animator and renderer meaning that all other aspects - save for the motion of the particles - are handled in the usual way. Other highlights include the ability to:

  • Emit particles from your custom sources rather than the single particle emitter
  • Add vortices to the velocity field
  • Change the weight of each velocity field separately at runtime, effectively turning on and off various motions

We plan on putting this custom particle system and editor on the Unity Asset Store in the near future.