According to the official documentation in Unity,
“Use the RenderType tag to overwrite the behaviour of a shader”.
What does the above statement mean? Basically, with this Tag, we can change from one state to another in the SubShader, adding an effect on any material that matches a given Type.
To carry out its function, we need at least two shaders:
- A replacement one (color or effect that we want to add at run time).
- And another to be replaced (shader assigned to the material).
Its syntax is as follows:
Tags { "RenderType"="type" }
Like the Queue Tags, RenderType has different configurable values that vary depending on the task we want to perform. Among them, we can find.
- Opaque. Default.
- Transparent.
- TransparentCutout.
- Background.
- Overlay.
- TreeOpaque.
- TreeTransparentCutout.
- TreeBillboard.
- Grass.
- GrassBillboard.
By default, the “Opaque” type is set every time we create a new shader. Likewise, most of the built-in shaders in Unity are assigned with this value since they do not have a configuration for transparencies. However, we can freely change this category; everything will depend on the effect we apply to a match.
To understand the concept thoroughly, we will do the following. In our project,
- We will make sure to create some 3D objects in the scene.
- We will create a C# script that we will call USBReplacementController.
- Then we will create a shader that we will call USB_replacement_shader.
- Finally, we will create a material that we will call USB_replaced_mat.
We will assign a shader over the material USB_replaced_mat dynamically using the Camera.SetReplacementShader. The material shader must have a Tag RenderType equal to the replacement shader to perform the function.
To exemplify, we will assign the Mobile/Unlit shader to USB_replaced_mat. This built-in shader has a Tag of type “RenderType” equal to “Opaque”. Therefore the shader USB_replacement_shader must match the same RenderType for the operation to be carried out.

The USBReplacementController script must be assigned directly to the camera as a component. This controller will be in charge of replacing a shader with a replacement one, as long as they have the same configuration in the RenderType.
using System.Collection;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class USBReplacementController : MonoBehaviour
{
// replacement shader
public Shader m_replacementShader;
private void OnEnable()
{
if(m_replacementShader != null)
{
// the camera will replace all the shaders in the scene
// whit the replacement one
// the "RenderType" configuration must match in both
// shader
GetComponent<Camera>().SetReplacementShader. (m_replacementShader,"RenderType");
}
}
private void OnDisable()
{
// let's reset the default shader
GetComponent<Camera>().ResetReplacementShader()
}
}
It is worth mentioning that we have defined the [ExecuteInEditMode] function over the class. This property will allow us to preview changes in edit mode.
We will use USB_replacement_shader as a replacement shader.
As we already know, every time we create a new shader, it configures its RenderType equal to “Opaque”. Consequently, USB_replacement_shader may replace the Unlit shader we previously assigned to the material.
To preview the changes clearly, we will go to the fragment shader stage of USB_replacement_shader and add a red color, which we will multiply by the output color.
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
// add a red color
fixed4 red = fixed4(1, 0, 0, 1);
return col * red;
}
We must make sure to include USB_replacement_shader in the Shader type replacement variable found in the USBReplacementController script.

And in addition, those objects that we added previously in the scene must have the material USB_replaced_mat.

Since the USBReplacementController class has included the OnEnable and OnDisable functions, if we activate or deactivate the script, we can see how the built-in shader Unlit is replaced by USB_replacement_shader in edit mode, applying a red color in the rendering.
