What are the key names of the textures on the HD ScriptableRenderPipeline in code.
I have started messing around with some of the new 2018 rendering, and I'm trying to build a tool that will associate textures to some of the texture chanels on the HD pipeline. I've been digging around for some information in the source code and the documentation but have been unable to find what I'm looking for.
What I'd like to do is change the chanels that are labeled in the GUI as "Base Color + Opacity", "Mask Map," and "Normal Map", but have been unable to find their names. My code is something like this:
Texture albedo = AssetDatabase.LoadAssetAtPath<Texture> (ALBD_LOCATION);
Texture metalic = AssetDatabase.LoadAssetAtPath<Texture> (METL_LOCATION);
Texture normal = AssetDatabase.LoadAssetAtPath<Texture> (NRML_LOCATION);
MeshRenderer rend = obj.GetComponentInChildren<MeshRenderer> ();
Material mat = rend.material;
mat.shader = Shader.Find ("HDRenderPipeline/Lit");
//I need to figure out what these names should be.
mat.SetTexture ("_MainTex", albedo);
mat.SetTexture ("_MaskMap", metalic);
mat.SetTexture ("_BumpMap", normal);
Does anyone know what those textures names should be, and better still, does anyone know a good reliable way of finding what those names should be so in the future I can look them up somewhere or be able to make a good guess?
Answer by Remy_Unity · May 04, 2018 at 06:59 AM
To know how the channels are used, you can look in the following sources:
List Shader GUI : https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/master/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/LitUI.cs
In the last one you will see a list of GUIContent that are the label and tooltips of the different textures.
For example : _MaskMap = "Mask Map - M(R), AO(G), D(B), S(A)"
You can deduce from it that for this texture the channel mapping is:
Red : Metallic
Green : Ambiant Occlusion
Blue : Detail mask (ok, I know, this one isn't so obvious)
Alpha : Smoothness
Answer by ModLunar · Jan 29, 2020 at 06:17 PM
You can take a look at the debug mode Inspector on a Material asset, and it will show you the list of texture properties, float properties, and color properties. It'll also give you the names of each of the properties. To see the debug mode Inspector, you should be able to click the 3 dots at the top right of your Inspector, and change it from "Normal" to "Debug".
You can confirm these names as well by editing the Material file in a text editor, since it is serialized in text form as YAML like most of Unity's other assets (assuming text serialization is used). It should look something like the screenshot below, and resemble what you see in the debug mode Inspector.
Also note you can hold "Alt" when in debug mode Inspector to see the "behind-the-scenes" names of variables, if that helps you as well.
Answer by Elecman · Oct 20, 2018 at 04:48 AM
I also made a texture assign script which you can find here: https://forum.unity.com/threads/automatically-assign-all-textures-to-all-materials.497154/#post-3800845
Here are some shader keywords of interest:
//This is to set the textures of the material using material.SetTexture()
//The source of this is in UnityStandardInput.cginc which is in the Unity build in shaders (separate download).
//The HD version can be found in Lit.shader
string albedoTextureID = "_MainTex";
string baseColorTextureID = "_BaseColorMap"; //HD SRP Lit shader.
string metallicTextureID = "_MetallicGlossMap";
string specularTextureID = "_SpecGlossMap";
string maskTextureID = "_MaskMap"; //HD SRP Lit shader.
string bumpTextureID = "_BumpMap";
string normalTextureID = "_NormalMap"; //HD SRP Lit shader.
string parallaxTextureID = "_ParallaxMap";
string heightTextureID = "_HeightMap"; //HD SRP Lit shader.
string occlusionTextureID = "_OcclusionMap";
string emissionTextureID = "_EmissionMap";
string emissiveTextureID = "_EmissiveColorMap"; //HD SRP Lit shader.
//These are the single color parameters of the material.
string albedoColorID = "_Color";
string baseColorID = "_BaseColor"; //HD SRP Lit shader.
string specularColorID = "_SpecColor";
string emissionColorID = "_EmissionColor";
string emissiveColorID = "_EmissiveColor"; //HD SRP Lit shader.
//These are the material sliders.
string metallicSliderID = "_Metallic";
string glossinessSliderID = "_Glossiness";
string smoothnessSliderID = "_Smoothness"; //HD SRP Lit shader.
Your answer
Follow this Question
Related Questions
Change alpha on material with custom shader 0 Answers
Check if emission is enabled in URP Lit Shader from C# script 0 Answers
How to know whether material's emission is enabled or not by C# script? 0 Answers
Highlighting Multiple Objects with an Outline Shader 0 Answers
Changing material type in a URP Lit material does not take effect until material is viewed in editor 0 Answers