Hello. Is it possible to create a custom ShaderGUI and, in doing so, redraw the Diffusion Profile slot? Despite my efforts, I’ve been unable to find an answer. I came across a thread that might have touched on a similar question, but it’s outdated now:
Hello and thank you. Your tip provided me with the push I needed in the right direction. I am just starting to dive into Graph Shader, so sometimes I really get lost…
So, I will explain the final solution in case somebody else needs it:
First, yes, as a newbie in creating Custom Shader GUIs, I didn’t think to check the HDRP package itself for clues to most of the things I need. Now, it makes total sense.
Secondly, I managed to draw the slot like this:
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering.HighDefinition;
using System.Linq;
public class CustomShaderGUI : ShaderGUI
{
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
// Find diffusion profile properties by name
MaterialProperty diffusionProfileAsset = FindProperty("_DiffusionProfileAsset", properties);
MaterialProperty diffusionProfileHash = FindProperty("_DiffusionProfileHash", properties);
// Make DiffusionProfileMaterialUI accessible
DiffusionProfileMaterialUI.OnGUI(materialEditor, diffusionProfileAsset, diffusionProfileHash, 0);
}
}
So, in the end, it is as easy as borrowing Unity’s class. However, as my second note states, we need to make said class accessible. So, I had to dive into the HDRP package of my project, find the DiffusionProfileMaterialUI.cs, and make the static class public: