Пример #1
0
 public void Awake()
 {
     if (isGlobal)
     {
         globalVolume = this;
         SetGlobalParams();
     }
 }
Пример #2
0
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                BlendModePopup();

                // Primary properties
                GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
                DoAlbedoArea(material);
                DoSpecularMetallicArea();
                m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
                DoEmissionArea(material);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
                EditorGUI.BeginChangeCheck();
                m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
                }

                EditorGUILayout.Space();

                // Secondary properties
                GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale);
                m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap);
                m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text);

                // Third properties
                GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel);
                if (highlights != null)
                {
                    m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText);
                }
                if (reflections != null)
                {
                    m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText);
                }

                GUILayout.Label(Styles.bakeryText, EditorStyles.boldLabel);

                m_MaterialEditor.ShaderProperty(enableDoubleSidedOn, Styles.doubleSidedLabel);
                enableDoubleSided.floatValue = enableDoubleSidedOn.floatValue > 0 ? 0 : 2;

                m_MaterialEditor.ShaderProperty(enableVertexLM, Styles.vertexLMLabel);
                if (enableVertexLM.floatValue > 0)
                {
                    m_MaterialEditor.ShaderProperty(enableVertexLMdir, Styles.vertexLMdirLabel);
                    //if (enableVertexLMdir.floatValue > 0) enableVertexLMSH.floatValue = 0;
                }
                if (enableVertexLM.floatValue > 0)
                {
                    m_MaterialEditor.ShaderProperty(enableVertexLMSH, Styles.vertexLMSHLabel);
                    //if (enableVertexLMSH.floatValue > 0) enableVertexLMdir.floatValue = 0;
                }
                if (enableVertexLM.floatValue > 0)
                {
                    m_MaterialEditor.ShaderProperty(enableVertexLMmask, Styles.vertexLMMaskLabel);
                }
                m_MaterialEditor.ShaderProperty(enableRNM, Styles.rnmLabel);
                m_MaterialEditor.ShaderProperty(enableSH, Styles.shLabel);
                if (enableSH.floatValue > 0 || enableVertexLMSH.floatValue > 0)
                {
                    m_MaterialEditor.ShaderProperty(enableSHN, Styles.shnLabel);
                }
                m_MaterialEditor.ShaderProperty(enableSpec, Styles.specLabel);
                m_MaterialEditor.ShaderProperty(enableBicubic, Styles.bicubicLabel);
                m_MaterialEditor.ShaderProperty(enablePSHN, Styles.pshnLabel);

                m_MaterialEditor.ShaderProperty(enableVolumes, Styles.volLabel);
                if (enableVolumes.floatValue > 0)
                {
                    var prevAssignedVolume = assignedVolume;
                    assignedVolume = EditorGUILayout.ObjectField(volume0.textureValue == null ? "Assign volume" : "Assign different volume", assignedVolume, typeof(BakeryVolume), true) as BakeryVolume;
                    if (prevAssignedVolume != assignedVolume)
                    {
                        volume0.textureValue    = assignedVolume.bakedTexture0;
                        volume1.textureValue    = assignedVolume.bakedTexture1;
                        volume2.textureValue    = assignedVolume.bakedTexture2;
                        volumeMask.textureValue = assignedVolume.bakedMask;
                        var b = assignedVolume.bounds;
                        volumeMin.vectorValue     = b.min;
                        volumeInvSize.vectorValue = new Vector3(1.0f / b.size.x, 1.0f / b.size.y, 1.0f / b.size.z);
                        assignedVolume            = null;
                    }
                    if (volume0.textureValue != null)
                    {
                        if (GUILayout.Button("Unset volume"))
                        {
                            volume0.textureValue      = null;
                            volume1.textureValue      = null;
                            volume2.textureValue      = null;
                            volumeMask.textureValue   = null;
                            volumeMin.vectorValue     = Vector3.zero;
                            volumeInvSize.vectorValue = Vector3.one * 1000001;
                        }
                    }
                    EditorGUILayout.LabelField("Current Volume: " + (volume0.textureValue == null ? "<none or global>" : volume0.textureValue.name.Substring(0, volume0.textureValue.name.Length - 1)));
                    EditorGUI.BeginDisabledGroup(true);
                    m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel0, volume0);
                    m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel1, volume1);
                    m_MaterialEditor.TexturePropertySingleLine(Styles.volLabel2, volume2);
                    m_MaterialEditor.TexturePropertySingleLine(Styles.volLabelMask, volumeMask);
                    var bmin4   = volumeMin.vectorValue;
                    var bmin    = new Vector3(bmin4.x, bmin4.y, bmin4.z);
                    var invSize = volumeInvSize.vectorValue;
                    var bmax    = new Vector3(1.0f / invSize.x + bmin.x, 1.0f / invSize.y + bmin.y, 1.0f / invSize.z + bmin.z);
                    EditorGUILayout.LabelField("Min: " + bmin);
                    EditorGUILayout.LabelField("Max: " + bmax);
                    EditorGUI.EndDisabledGroup();
                }

                EditorGUILayout.Space();
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in blendMode.targets)
                {
                    MaterialChanged((Material)obj, m_WorkflowMode);
                }
            }
        }