This article was adapted from a tutorial on our blog.
Transparency or Opacity describes if something is visible (opaque), invisible (transparent), or partially visible ("partially transparent", "see-through", "translucent", etc.)
How does transparency work?
Rendering transparent objects is done by blending colors. Objects are drawn one by one on top of each other, and depending on the blending mode and the order they are rendered, the result differs.
Transparency is often expensive in terms of processing power and rendering performance. Among the different blending methods, there are trade-offs between image quality and viewer performance. Choosing the appropriate mode will depend on your needs.
In addition to a blended opacity channel, an Alpha Mask can be applied to a material.
Alpha Mask
Sometimes called an "image mask" or "coverage mask", an alpha mask works by setting visibility in a binary (on / off) way.
It is usually defined using a grayscale (Luminance channel) or Alpha texture. You can use the slider to set an Alpha "threshold", and invert the texture if needed. Alpha mask requires a texture to be useful.
Masking is useful for materials that require a "cut-out" effect like leaves, text, and logos.
Masking is the fastest transparency method.
Masking can be combined with other opacity modes. This means that you can emulate Transmission effects such reflections on semi-transparent surfaces while also masking parts of the material.
Order
Here is a simple 2D example. On the left, the blue square is in front of the orange square, while on the right, the orange square is in front of the blue square. You can see why order matters:
Offline renderers like ray tracers and modeling tools favor quality over performance. They can afford to sort each individual triangle before rendering a frame, so blending order is not an issue.
When achieving real time performance, there is a limitation due to raster algorithms; polygons are drawn in 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 opaque polygons.
Blending Modes
There are many methods of rendering transparent objects in real time. They use different blending modes (or mixing modes) which determine how two layers of an image are blended into each other. Users of Photoshop and other image editing software will be familiar with blending modes in image layers. The same principle applies to 3D rendering.
Blending
Transparent objects are blended together.
It is usually defined using a grayscale (Luminance channel) or Alpha texture, or a solid gray value.
Blending mode is useful for translucent materials like glass, or materials with varying transparency.
Blending is a very slow transparency method. All visible objects in the scene must be rendered, sorted, and merged into the final image. This is an "expensive" calculation. Sorting each individual polygon in a model would be very slow, so the Sketchfab viewer sorts for transparency by meshes. This can cause "popping" or "flickering" in complex or intersecting shapes. If you experience this kind of problem, try splitting up the transparent object into more separate meshes.
Refraction
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, water, gemstones, and many other transparent materials.
Refraction is the slowest transparency method.
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:
- 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.
- A model's wireframe will not be visible behind refraction objects.
Tips:
- 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.
- Check lists online such as this one for accurate IOR values for different materials.
Additive
Additive transparency 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.
Additive mode is slightly faster than Blending. If only additive materials are used in a scene, objects do not need to be sorted, so there can be no flickering issues.
Dithered
Dithered mode is a faster method to achieve Blending, but it produces "noise" during navigation. The image quality improves when the camera is not moving.
It is usually defined using a grayscale (Luminance channel) or Alpha texture, or a solid gray value.
Dithered mode is useful for complex geometries with partial transparency, like fur and hair. Enable the thin layering dithering pattern option to use a noisier pattern, useful for models with lots of thin layers of hair, fur, etc.
Texture format
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).