Transparent/See-through Objects In Unity
You often come across things that are transparent or see-through in real life. In a game, sometimes you want objects to become transparent, or you want to put glass panes on a window. Unity has made it quite easy to achieve the result.
To make an object transparent, set the rendering mode of the material of that object to “Transparent” or “Fade” and reduce the alpha value of albedo if you’re using the default build pipeline, or set surface type to “Transparent” if you’re using URP or HDRP and reduce the alpha value of the base map.
Each render pipeline has a different way to make an object transparent or see-through, but the general idea is to set the surface type of a material to “Transparent” and reduce the alpha value. There will be some examples for each render pipeline below.
How To Make An Object Transparent In Unity
To make an object transparent in Unity in a project that doesn’t use URP or HDRP, simply set the Rendering Mode of a material of the object.
To get the material attached to an object, select the object and look in the Materials section under the Mesh Renderer component.
You can then double-click on the material’s name to edit it, or select the material directly in the Project window.
Note: The default material that comes with a 3D object cannot be edited. You need to create a new material by right-clicking on the Project window and selecting Create > Material, and then drag and drop the newly created material on top of the default material in the list.
Once you’ve selected the material, you should be able to see something similar to this image below in the inspector window:
In order to make an object transparent, set the Rendering Mode to either “Transparent” or “Fade“.
But that will not turn the object transparent right away, you also need to reduce the alpha value of Albedo:
Setting the alpha value to anything below 255 will make the object see-through.
A Material can be applied to multiple objects to grant the same properties. For example, windows come in many shapes and designs but the transparent glass panes on all of them may work the same way.
To apply one Material to multiple objects, simply add the material to the material list in the Mesh Renderer component of your desired objects.
Rendering Mode: Transparent VS Fade
You’re probably wondering why there are 2 options for transparency: Transparent and Fade.
These 2 types of transparency mode behave differently from each other:
- Transparent: Behaves like what real-world transparent object. Think of a glass. This mode makes an objects transparent while retaining the ability to reflect light off of it.
- Fade: Only makes objects see-through without reflecting light. This is generally used for making something fade away from the scene.
How To Make An Object Transparent In URP In Unity
Transparency in URP projects is similar to the default render pipeline with slightly different options.
To modify these values and apply them to an object, create a Material and then add it to the material list in the Mesh Renderer component of an object.
Instead of Rendering Mode, URP has the Surface Type option that determines how an object’s surface will behave.
You may have noticed that URP’s Surface Type doesn’t have the Fade option.
So how do we make an object see-through without reflecting light?
This can be done by unchecking Receive Shadows. It will make light pass through without casting shadows onto the object.
Play around with other properties to get a better understanding of the Material.
How To Make An Object Transparent In HDRP In Unity
As with the default render pipeline and the URP, HDRP also has its own material shader.
HDRP’s Material shader is much more complex and I will not be covering everything as they’re outside of the scope of this article.
To make an object transparent in HDRP projects, just like URP, setting the Surface Type of a Material and then reducing the alpha of the Material will do the trick.
This will make the object this material is attached to turn transparent.