There are many methods of rendering transparent objects in real time. Transparency is often expensive in terms of processing and rendering performance. Among the different methods, there are trade-offs between image quality and viewer performance. This article describes the transparency modes on Sketchfab and suggests when each option is most suitable.
Why order matters
Rendering transparent objects is done by blending colors. Objects are drawn one by one on top of each other and depending on the blend mode and the order they are rendered, the result differs.
- Left: Blue square is in front of the orange one.
- Right: Orange square is in front of the blue one.
Offline renderers like raytracers and modeling tools favor quality over performance. They can afford to sort each triangle before rendering a frame, so blending is not an issue.
When achieving realtime performance level there is a limitation due to raster algorithms; polygons are drawn by batches, and per batch the order in which polygons are drawn can't always be predicted.
Sketchfab makes a compromise between transparency quality and speed by sorting transparent objects and not transparent polygons.
Blending is the slowest method of rendering transparency. All visible objects in the scene must be rendered, sorted, and merged into the final image. This is an "expensive" calculation. It is usually a grayscale (Luminance channel) or Alpha texture, or a solid gray value. Blending mode is useful for translucent materials like glass.
Refraction is the phenomenon that makes light bend when passing through different transparent materials due to the velocity of light changing in different media. It makes objects behind the refractive material look distorted. Refraction is useful for simulating glass, gemstones, and many other transparent materials.
You can use a texture with an alpha channel or simply a value between 0 (transparent) and 100 (opaque).
- Invert texture will reverse the alpha channel.
- Tint adds a color to the transparency.
- Use diffuse will use the colors of the material's Diffuse / Albedo / Base Color.
- Index of Refraction (IoR) controls how the material refracts light. The IoR of air is 1.0.
- Use normal offset uses the material's normal map / bump map to define IoR instead of a physical model of light. This is useful for large planes such as water.
- Refraction Roughness controls the blurriness of the refraction.
- Use Roughness/Glossiness texture applies your PBR Roughness/Glossiness texture for as the Refraction Roughness.
There are some limitations to Sketchfab's implementation of Refraction:
- Refraction works best in PBR rendering. In Classic rendering, roughness does nothing.
- A refractive object can not refract itself.
- A refractive object can not refract other refractive objects.
- There can be sorting issues when mixing refractive and transparent objects.
- There can be artifacts when the camera moves.
- Objects outside of the field of view are not refracted.
- Only opaque parts of a refractive object will cast shadows.
- Disable the emissive channel; it can have a bad effect on refraction.
- If you use a color in albedo/base color, set it to white instead of black.
- Using a normal map can help add details and variation to the refraction effect.
- The IOR should be just small enough to take into account the normal map.
Additive mode is almost as slow as Blending. It works by adding the transparent colors of objects together, so order does not matter in this case. Black will be rendered as transparent. It is similar to the Linear Dodge (Add) blend mode in Photoshop. Additive transparency is useful for special effects and emissive materials like fire, sparkles, and holograms.
Dithered mode is a faster method to achieve Blending, but it produces "noise" during navigation. The image quality improves when the camera is static. It is usually a grayscale (Luminance channel) or Alpha texture, or a solid gray value. The Dithered mode is useful for complex geometries with partial transparency, like fur and hair. Enable the dithering pattern option to use a noisier pattern, useful for models with lots of thin layers of hair, fur, etc.
Alpha Masking is the fastest transparency method. It works by setting visibility in a binary (on / off) way. It is usually a grayscale (Luminance channel) or Alpha texture. You can use the slider to set an Alpha "Threshold". Masking is useful for materials that require a "cutout" effect like leaves and logos.
The texture format option enables you to set how colors are encoded. For the opacity channel you can choose between Alpha (A) and Luminance (R).