Obi supports two fluid rendering techniques: spherical impostors and screen-space splatting, implemented by ObiParticleRenderer and ObiFluidRenderer, respectively.
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.
You can provide any shader you wish to use for particle rendering, as long as it honors the particle data being passed to the vertex shader. Obi includes particle shaders for the built-in render pipeline, as well as shaders for URP (you can find these in Obi/Resources/ObiMaterials/URP).
Setting up fluid rendering is done in a slightly different way depending on which scriptable render pipeline you're using. Note the HDRP rendering pipeline is not currently supported:
Regardless of the pipeline you use, you will be presented with a similar interface:
Screen-space splatting involves using the individual billboards generated by an ObiParticleRenderer to draw a smooth, continuous representation of the fluid. So, setting up a particle renderer is a prerequisite for fluid rendering:
In order to use fluid rendering, you need to have a ObiParticleRenderer set up. Then assign the ObiParticleRenderer to the ObiFluidRenderer's "Particle Renderers" property.
Let's take a look at each individual section of the renderer interface:
This controls the fluid thickness buffer and how it is blended with the screen contents:
This controls depth/normals generation for the fluid surface. It is required for lightning/reflection/refraction.
This controls lighting.
Controls surface reflection.
Controls surface refraction.
If you're using particle advection, this controls how advected particles are integrated with the fluid.
There are many possible ways to render fluid. Obi uses a screen-space method that does not involve procedurally generating a mesh every frame, thus reducing CPU workload and taking full advantage of the GPU for rendering. The full rendering process has 5 steps that happen every frame:
From left to right:
This is similar to a traditional deferred renderer, and shares the same strengths and weaknesses: rendering cost is largely independent of the amount of particles on screen, but this also means there's a fixed cost associated to buffer generation even if there are no particles visible.
The built-in ObiFluidRenderer makes use of shader variants to generate an optimized shader for the combination of features you're using. For instance: if you're rendering opaque fluid with no refraction, step #1 will be skipped: no refraction buffer will be rendered at all, and the resulting shader won't include any refraction calculations.
For desktop platforms, you can get away with full-resolution rendering and all renderer features most of the time. Mobile devices however are typically more fillrate limited, so it can be beneficial to use aggresive downsampling, and skip surface reconstruction if possible. Using simple blending instead of refraction can also improve performance.