public override string GetPropertyValue()
        {
            Vector4 asset = Vector4.zero;

            if (m_defaultValue != null)
            {
                asset = HDUtilsEx.ConvertGUIDToVector4(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_defaultValue)));
            }
            string assetVec = RoundTrip.ToRoundTrip(asset.x) + ", " + RoundTrip.ToRoundTrip(asset.y) + ", " + RoundTrip.ToRoundTrip(asset.z) + ", " + RoundTrip.ToRoundTrip(asset.w);
            string lineOne  = string.Empty;
            string lineTwo  = string.Empty;

            if (m_defaultInspector)
            {
                lineOne = PropertyAttributes + "[HideInInspector]_DiffusionProfileAsset(\"" + m_propertyInspectorName + "\", Vector) = ( " + assetVec + " )";
                lineTwo = "\n[HideInInspector]_DiffusionProfileHash(\"" + m_propertyInspectorName + "\", Float) = " + RoundTrip.ToRoundTrip(HDShadowUtilsEx.Asfloat(DefaultHash));
            }
            else
            {
#if UNITY_2020_2_OR_NEWER
                lineOne = "\n[DiffusionProfile]" + m_propertyName + "(\"" + m_propertyInspectorName + "\", Float) = " + RoundTrip.ToRoundTrip(HDShadowUtilsEx.Asfloat(DefaultHash));
                lineTwo = PropertyAttributes + "[HideInInspector]" + m_propertyName + "_Asset(\"" + m_propertyInspectorName + "\", Vector) = ( " + assetVec + " )";
#else
                lineOne = PropertyAttributes + "[ASEDiffusionProfile(" + m_propertyName + ")]" + m_propertyName + "_asset(\"" + m_propertyInspectorName + "\", Vector) = ( " + assetVec + " )";
                lineTwo = "\n[HideInInspector]" + m_propertyName + "(\"" + m_propertyInspectorName + "\", Float) = " + RoundTrip.ToRoundTrip(HDShadowUtilsEx.Asfloat(DefaultHash));
#endif
            }

            return(lineOne + lineTwo);
        }
        public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor)
        {
            var guid    = HDUtilsEx.ConvertVector4ToGUID(prop.vectorValue);
            var profile = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), DiffusionProfileSettingsEx.Type);

            EditorGUI.BeginChangeCheck();
            profile = EditorGUI.ObjectField(position, new GUIContent(label), profile, DiffusionProfileSettingsEx.Type, false);
            if (EditorGUI.EndChangeCheck())
            {
                Vector4 newGuid = Vector4.zero;
                float   hash    = 0;
                if (profile != null)
                {
                    var guid2 = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(profile));
                    newGuid = HDUtilsEx.ConvertGUIDToVector4(guid2);
                    hash    = HDShadowUtilsEx.Asfloat(DiffusionProfileSettingsEx.Hash(profile));
                }
                prop.vectorValue = newGuid;

                var hashField = MaterialEditor.GetMaterialProperty(new UnityEngine.Object[] { editor.target }, m_hashField);
                if (hashField != null)
                {
                    hashField.floatValue = hash;
                }
            }

            if (profile == null)
            {
                prop.vectorValue = Vector4.zero;
            }

            DiffusionProfileMaterialUIEx.DrawDiffusionProfileWarning(profile);
        }
        public override void UpdateMaterial(Material mat)
        {
            base.UpdateMaterial(mat);

            if (UIUtils.IsProperty(m_currentParameterType) && !InsideShaderFunction)
            {
                if (m_materialValue != null)
                {
                    Vector4 asset = HDUtilsEx.ConvertGUIDToVector4(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_materialValue)));
                    if (m_defaultInspector)
                    {
                        mat.SetVector("_DiffusionProfileAsset", asset);
                        mat.SetFloat("_DiffusionProfileHash", HDShadowUtilsEx.Asfloat(MaterialHash));
                    }
                    else
                    {
                        mat.SetVector(m_propertyName + "_asset", asset);
                        mat.SetFloat(m_propertyName, HDShadowUtilsEx.Asfloat(MaterialHash));
                    }
                }
            }
        }