Fur Shader Passes

From Warren's Fast Fur Shader
Revision as of 14:44, 31 December 2023 by Warren (talk | contribs)
Jump to navigation Jump to search

Rendering Passes

Fast Fur is a 3-pass shader. Each pass runs from start to finish before the next pass starts.

Pass 1 - The Skin

Many lighting effects, such as proper specular lighting and normal maps, are simply too slow to calculate for every layer of fur. As a compromise, my shader only renders the skin "expensively".

However, an unexpected benefit of rendering the skin in a separate pass is that it actually renders faster than doing everything in 1 pass. As far as I can tell (and this really is just a guess!), rending the opaque skin at the same time as the mostly see-through fur results in the GPU caches missing a lot.

The speed increase is so great, in fact, that it more than offsets the speed decrease of rending the skin "expensively".

Pass 2 - The Fur

Almost nothing is rendered "correctly" by the fur layers. They take every short-cut possible, resulting in all sorts of lighting errors and glitches (if you know what to look for).

However, speed is absolutely essential, because these layers make up the vast majority of the render time. Also, more speed means more layers can be rendered per frame, allowing the brute-force tactic of throwing more resolution at the screen to make the fur look better.

The shader also has a couple of tricks up its sleeve:

Sneaky trick #1: it can turn the fur off by having the Hull shader ask the Tessellator to multiply the number of triangles by 0, which throws them out. Any off-screen, far-away, or backwards-facing triangles are thus discarded before the expensive Geometry shader stage runs, which results in a massive speed boost. Otherwise, it tells the Tessellator to multiply the number of trianges by 1, which does nothing. The triangle is simply passed to the Geometry shader and thus the fur is rendered normally.

Sneaky trick #2: it can have the Hull shader ask the Tessellator split each triangle into 4 when taking a photo. However, the Domain shader then ignores the Tessellator, and instead just makes 4 copies of the original, un-tessellated triangle. The fur can thus be rendered at up to 4x resolution, but only when needed.

Pass 3 - The Overcoat

Added in v5.0, the overcoat is a translucent layer of fur that acts as a cheap visual stand-in for actual fur when the avatar is far away. It allows the shader to turn the "real" fur layers off completely, which results in a very large speed boost.

At close range the overcoat is not visible, but as distance increases the overcoat fades in and expands outwards to about 2/3rds the thickness of the fur.