This page contains information about how to make shadersA program that runs on the GPU. More info
See in Glossary compatible with Unity’s lightmappersA tool in Unity that bakes lightmaps according to the arrangement of lights and geometry in your scene. More info
See in Glossary.
A Meta Pass is a Shader pass that provides albedo and emission values to the Global IlluminationA group of techniques that model both direct and indirect lighting to provide realistic lighting results.
See in Glossary system. These values are separate from those used in real-time rendering, meaning that you can use the Meta Pass to control how a GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary looks from the point of view of the lighting baking system without affecting its appearance at runtime.
An example of when this would be useful is if you wanted the green moss on a cliff to generate exaggerated green indirect light in your lightmapsA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary, but you didn’t want to recolor the terrainThe landscape in your scene. A Terrain GameObject adds a large flat plane to your scene and you can use the Terrain’s Inspector window to create a detailed landscape. More info
See in Glossary in the real-time pass of shader.
All of Unity’s built-in Materials have a Meta Pass, and the Standard Shader contains a Meta pass. If you are using these, you do not need to do anything to enable the Meta Pass. If you are using a custom Shader, you can add your own Meta Pass.
The Shader below allows you to specify an albedo color and albedo Texture that are used only by the lighting baking system, without affecting the appearance of the Material at runtime. In this example, emission is taken from the UVs; but any value could be used to control it.
Shader "Custom/metaPassShader"{ Properties { _Color ("Color", Color)=(1,1,1,1) _MainTex ("Albedo (RGB)",2D)="white"{} _Glossiness ("Smoothness", Range(0,1))=0.5 _Metallic ("Metallic", Range(0,1))=0.0 _GIAlbedoColor ("Color Albedo (GI)", Color)=(1,1,1,1) _GIAlbedoTex ("Albedo (GI)",2D)="white"{} } SubShader { // ------------------------------------------------------------------ // Extracts information for lightmapping, GI (emission, albedo, ...) // This pass is not used during regular rendering. Pass { Name "META" Tags {"LightMode"="Meta"} Cull Off CGPROGRAM #include"UnityStandardMeta.cginc" sampler2D _GIAlbedoTex; fixed4 _GIAlbedoColor; float4 frag_meta2 (v2f_meta i): SV_Target { // We're interested in diffuse & specular colors // and surface roughness to produce final albedo. FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv); UnityMetaInput o; UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o); fixed4 c = tex2D (_GIAlbedoTex, i.uv); o.Albedo = fixed3(c.rgb * _GIAlbedoColor.rgb); o.Emission = Emission(i.uv.xy); return UnityMetaFragment(o); } #pragma vertex vert_meta #pragma fragment frag_meta2 #pragma shader_feature _EMISSION #pragma shader_feature _METALLICGLOSSMAP #pragma shader_feature ___ _DETAIL_MULX2 ENDCG } Tags {"RenderType"="Opaque"} LOD 200 CGPROGRAM // Physically-based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows nometa // Use Shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; fixed4 _Color; void surf (Input IN,inout SurfaceOutputStandard o){ // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex)* _Color; o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }
Enlighten Realtime Global Illumination and lightmapping use Unity’s Meta Pass to extract albedo values from surfaces and handle diffuse transport themselves by using surface albedo on each bounce.
Metallic surfaces with a black (or almost black) albedo bounce very little light diffusely. Because the lightmappers handle only diffuse light transport, this means that you may see very little bounced light from these types of surfaces. Unity’s built-in Meta Passes account for this by providing a boosted version of the metal hue color instead of a physically correct albedo. This means that you get some bounce even from metallic materials. If you want a different behaviour, you can create a custom meta pass.
The built-in Meta Passes do not handle spectral specular reflectance.
Note: If you are using EnlightenA lighting system by Geomerics used in Unity for Enlighten Realtime Global Illumination. More info
See in Glossary Realtime Global Illumination, the Meta pass in the Player is not as fast as DynamicGI.SetEmissive, but it is more flexible because you are not limited to a single color.
By default, shaders in Unity use monochrome transparency. This means that Unity uses the alpha channel of the material color or albedo texture to evaluate light transmission through the material.
During lightmapping, you can use custom RGB transparency instead. This means that Unity uses the values of a given texture to evaluate light transmission through the material. This is useful when you want color-based transparency that is independent of the material color or albedo texture; for example, if you want to bake lighting that simulates the behavior of a light shining through a stained glass window.
To use custom RGB transparency during lightmapping, add the following line to your ShaderLabUnity’s language for defining the structure of Shader objects. More info
See in Glossary code:
_TransparencyLM ("Transmissive Texture", 2D) = "white" {}
This creates a material property that appears in the Material InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary with the name “Transmissive Texture”. Assign the desired texture to this field.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.