Fluid rendering

Obi supports two fluid rendering techniques: spherical impostors and screen-space splatting, implemented by ObiParticleRenderer and ObiFluidRenderer, respectively.

Left: fluid rendered as spherical impostors. Right: fluid rendered using screen-space splatting.

Obi Particle Renderer

Spherical impostors are a special type of billboards (camera-facing quads) which look like perfectly-lit, highly tesselated 3D spheres, at a fraction of the cost. The ObiParticleRenderer component can be used to render your fluid particles as tiny spheres using this technique.

In order to do this, just add the component to any actor (for instance an ObiEmitter, but it can also be used to draw cloth or ropes). You can also set the color of the particles, and scale the radius used when rendering them.

Obi Fluid Renderer

Screen-space splatting involves using the individual billboards generated by an ObiParticleRenderer to draw a smooth, continuous representation of the fluid.

In order to use a FluidRenderer, you need to have a ObiParticleRenderer set up. Then add an ObiFuidRenderer component to any camera you'd like the fluid to be visible from, and assign the ObiParticleRenderer to its "Particle Renderers" property.

How it works

There are many possible ways to render fluid. Obi uses a screen-space method that does not involve generating a precedural mesh each frame, thus reducing CPU workload and taking full advantage of the GPU for rendering. The rendering process has 4 steps that happen every frame:


From left to right:

  • First, all particles render their depth to an offscreen depth buffer.
  • Also, they render their thickness and color to a thickness/color buffer, using the Color material of the Obi Fluid Renderer.
  • The fluid depth buffer rendered in step 1 is used to generate a normals buffer.
  • All three buffers are composited into the final render, using the Fluid material of the Obi Fluid Renderer. The fluid depth buffer is used to discard fluid fragments that are obscured by other objects in the scene.

It is possible to use custom shaders to perform steps 2 (thickness/color rendering) and 4 (final render). Step 2 is performed using the "Color material" or the fluid renderer, and step 4 uses the material attached to the "Fluid material" property. There are two different color materials/shaders included by default: FluidColorBlend and FluidColorOpaque:

  • FluidColorBlend uses multiplicative blending to accumulate the color of each particle.
  • FluidColorOpaque uses alpha blending to accumulate the color of each particle.

Also, there are two default materials/shaders to perform the final rendering step:

  • DielectricFluid uses reflection, refraction and transmission to render the fluid. Use this for transparent or semi-transparent fluids like water, honey or blood.
  • OpaqueFluid uses simple surface shading to render the fluid, similar to Unity's Standard shader. Use this for opaque fluids like tar or paint.