Make a shader compatible with the Material Validator in the Built-In Render Pipeline
Add code to a custom shader so it appears in the Material Validator window.
읽는 시간 1분최근 업데이트: 한 달 전
The Material Validator works with any Materials that use Unity’s Standard shader or surface shaders. However, custom shaders require a pass named . Most custom shaders that support lightmapping already have this pass defined. See documentation on Lightmapping and shaders for more details.
“META”Carry out the following steps to make your custom shader compatible with the Material Validator:
- Add the following pragma to the meta pass:
#pragma shader_feature EDITOR_VISUALIZATION - In the structure, assign the specular color of the Material to the field called
UnityMetaInput, as shown in the code example below.SpecularColor
Here is an example of a custom meta pass:
Pass{ Name "META" Tags { "LightMode"="Meta" } Cull Off CGPROGRAM #pragma vertex vert_meta #pragma fragment frag_meta #pragma shader_feature _EMISSION #pragma shader_feature _METALLICGLOSSMAP #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A #pragma shader_feature ___ _DETAIL_MULX2 #pragma shader_feature EDITOR_VISUALIZATION float4 frag_meta(v2f_meta i) : SV_TARGET { UnityMetaInput input; UNITY_INITIALIZE_OUTPUT(UnityMetaInput, input); float4 materialSpecularColor = float4(1.0f, 0.0f, 0.0f, 1.0f); float4 materialAlbedo = float4(0.0f, 1.0f, 0.0f, 1.0f); input.SpecularColor = materialSpecularColor; input.Albedo = materialAlbedo; return UnityMetaFragment(input); } }