Ejemplo n.º 1
0
        public virtual void ReadAdditionalData(ref string[] nodeParams)
        {
            string textureName = GetCurrentParam(ref nodeParams);

            m_defaultValue        = AssetDatabase.LoadAssetAtPath <Texture>(textureName);
            m_isNormalMap         = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            m_defaultTextureValue = ( TexturePropertyValues )Enum.Parse(typeof(TexturePropertyValues), GetCurrentParam(ref nodeParams));
            m_autocastMode        = ( AutoCastType )Enum.Parse(typeof(AutoCastType), GetCurrentParam(ref nodeParams));

            ConfigFromObject(m_defaultValue);
            ConfigureInputPorts();
            ConfigureOutputPorts();
        }
Ejemplo n.º 2
0
        public virtual void CheckTextureImporter(bool additionalCheck)
        {
            m_requireMaterialUpdate = true;
            Texture         texture  = m_materialMode ? m_materialValue : m_defaultValue;
            TextureImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter;

            if (importer != null)
            {
#if UNITY_5_5_OR_NEWER
                m_isNormalMap = importer.textureType == TextureImporterType.NormalMap;
#else
                m_isNormalMap = importer.normalmap;
#endif

                if (m_defaultTextureValue == TexturePropertyValues.bump && !m_isNormalMap)
                {
                    m_defaultTextureValue = TexturePropertyValues.white;
                }
                else if (m_isNormalMap)
                {
                    m_defaultTextureValue = TexturePropertyValues.bump;
                }

                if (additionalCheck)
                {
                    AdditionalCheck();
                }
#if UNITY_5_5_OR_NEWER
                m_linearTexture = !importer.sRGBTexture;
#else
                m_linearTexture = importer.linearTexture;
#endif
            }

            if ((texture as Texture2D) != null)
            {
                ConfigTextureData(TextureType.Texture2D);
            }
            else if ((texture as Texture3D) != null)
            {
                ConfigTextureData(TextureType.Texture3D);
            }
            else if ((texture as Cubemap) != null)
            {
                ConfigTextureData(TextureType.Cube);
            }

            //ConfigureInputPorts();
            //ConfigureOutputPorts();
            //ResizeNodeToPreview();
        }
Ejemplo n.º 3
0
        void ShowDefaults()
        {
            m_defaultTextureValue = ( TexturePropertyValues )EditorGUILayout.EnumPopup(DefaultTextureStr, m_defaultTextureValue);
            AutoCastType newAutoCast = ( AutoCastType )EditorGUILayout.EnumPopup(AutoCastModeStr, m_autocastMode);

            if (newAutoCast != m_autocastMode)
            {
                m_autocastMode = newAutoCast;
                if (m_autocastMode != AutoCastType.Auto)
                {
                    ConfigTextureData(m_currentType);
                    ConfigureInputPorts();
                    ConfigureOutputPorts();
                    ResizeNodeToPreview();
                }
            }
        }
        public virtual void ReadAdditionalData(ref string[] nodeParams)
        {
            string defaultTextureGUID = GetCurrentParam(ref nodeParams);

            //m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( textureName );
            if (UIUtils.CurrentShaderVersion() > 14101)
            {
                m_defaultValue = AssetDatabase.LoadAssetAtPath <Texture>(AssetDatabase.GUIDToAssetPath(defaultTextureGUID));
                string materialTextureGUID = GetCurrentParam(ref nodeParams);
                m_materialValue = AssetDatabase.LoadAssetAtPath <Texture>(AssetDatabase.GUIDToAssetPath(materialTextureGUID));
            }
            else
            {
                m_defaultValue = AssetDatabase.LoadAssetAtPath <Texture>(defaultTextureGUID);
            }

            m_isNormalMap         = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            m_defaultTextureValue = (TexturePropertyValues)Enum.Parse(typeof(TexturePropertyValues), GetCurrentParam(ref nodeParams));
            m_autocastMode        = (AutoCastType)Enum.Parse(typeof(AutoCastType), GetCurrentParam(ref nodeParams));
            if (UIUtils.CurrentShaderVersion() > 15306)
            {
                m_currentType = (TextureType)Enum.Parse(typeof(TextureType), GetCurrentParam(ref nodeParams));
            }
            else
            {
                m_currentType = TextureType.Texture2D;
            }

            ConfigTextureData(m_currentType);

            //ConfigFromObject( m_defaultValue );
            if (m_materialValue == null)
            {
                ConfigFromObject(m_defaultValue);
            }
            else
            {
                CheckTextureImporter(true, true);
            }
            ConfigureInputPorts();
            ConfigureOutputPorts();
        }
Ejemplo n.º 5
0
 protected override void CommonInit(int uniqueId)
 {
     base.CommonInit(uniqueId);
     m_defaultTextureValue = TexturePropertyValues.white;
     m_fixedSize.x         = 170;
     m_fixedSize.y         = 10;
     AddInputPort(WirePortDataType.FLOAT2, false, "UV");
     AddInputPort(WirePortDataType.FLOAT, false, "Normal Scale");
     m_inputPorts[1].Visible           = m_autoUnpackNormals;
     m_inputPorts[1].FloatInternalData = 1.0f;
     AddOutputColorPorts(WirePortDataType.COLOR, "RGBA");
     m_currentParameterType = PropertyType.Property;
     m_useCustomPrefix      = true;
     m_customPrefix         = "Texture Sample ";
     m_referenceContent     = new GUIContent(string.Empty);
     m_freeType             = false;
     m_useSemantics         = true;
     m_textLabelWidth       = 100;
     ConfigTextureData(TextureType.Texture2D);
 }
Ejemplo n.º 6
0
 protected override void CommonInit(int uniqueId)
 {
     base.CommonInit(uniqueId);
     m_defaultTextureValue = TexturePropertyValues.white;
     m_insideSize.Set(PreviewSizeX, PreviewSizeY + 5);
     AddOutputPort(WirePortDataType.SAMPLER2D, "Tex");
     m_outputPorts[0].CreatePortRestrictions(WirePortDataType.SAMPLER1D, WirePortDataType.SAMPLER2D, WirePortDataType.SAMPLER3D, WirePortDataType.SAMPLERCUBE, WirePortDataType.OBJECT);
     m_currentParameterType = PropertyType.Property;
     m_customPrefix         = "Texture ";
     m_drawPrecisionUI      = false;
     m_freeType             = false;
     m_drawPicker           = true;
     m_textLabelWidth       = 115;
     m_availableAttribs.Add(new PropertyAttributes("No Scale Offset", "[NoScaleOffset]"));
     m_availableAttribs.Add(new PropertyAttributes("Normal", "[Normal]"));
     m_showPreview            = true;
     m_drawPreviewExpander    = false;
     m_drawPreview            = false;
     m_drawPreviewMaskButtons = false;
     m_previewShaderGUID      = "e53988745ec6e034694ee2640cd3d372";
 }
Ejemplo n.º 7
0
        //

        public override void DrawSubProperties()
        {
            m_textureCoordSet     = EditorGUILayout.IntPopup(Constants.AvailableUVSetsLabel, m_textureCoordSet, Constants.AvailableUVSetsStr, Constants.AvailableUVSets);
            m_defaultTextureValue = ( TexturePropertyValues )EditorGUILayout.EnumPopup(DefaultTextureStr, m_defaultTextureValue);
            AutoCastType newAutoCast = ( AutoCastType )EditorGUILayout.EnumPopup(AutoCastModeStr, m_autocastMode);

            if (newAutoCast != m_autocastMode)
            {
                m_autocastMode = newAutoCast;
                if (m_autocastMode != AutoCastType.Auto)
                {
                    ConfigTextureData(m_currentType);
                }
            }

            //if ( _isNormalMap )
            {
                bool autoUnpackNormals = EditorGUILayout.Toggle(AutoUnpackNormalsStr, m_autoUnpackNormals);
                if (m_autoUnpackNormals != autoUnpackNormals)
                {
                    AutoUnpackNormals = autoUnpackNormals;

                    ConfigurePorts();
                }
            }

            if (m_autoUnpackNormals && !m_inputPorts[1].IsConnected)
            {
                m_inputPorts[1].FloatInternalData = EditorGUILayout.FloatField(NormalScaleStr, m_inputPorts[1].FloatInternalData);
            }

            EditorGUI.BeginChangeCheck();
            m_defaultValue = ( Texture )EditorGUILayout.ObjectField(Constants.DefaultValueLabel, m_defaultValue, m_textureType, false);
            if (EditorGUI.EndChangeCheck())
            {
                CheckTextureImporter(true);
            }
        }
        public virtual void CheckTextureImporter(bool additionalCheck, bool writeDefault = true)
        {
            m_requireMaterialUpdate = true;
            Texture         texture  = m_materialMode ? m_materialValue : m_defaultValue;
            TextureImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter;

            if (importer != null)
            {
#if UNITY_5_5_OR_NEWER
                m_isNormalMap = importer.textureType == TextureImporterType.NormalMap;
#else
                m_isNormalMap = importer.normalmap;
#endif
                if (writeDefault && !UIUtils.IsLoading)
                {
                    if (m_defaultTextureValue == TexturePropertyValues.bump && !m_isNormalMap)
                    {
                        m_defaultTextureValue = TexturePropertyValues.white;
                    }
                    else if (m_isNormalMap)
                    {
                        m_defaultTextureValue = TexturePropertyValues.bump;
                    }
                }

                if (additionalCheck)
                {
                    AdditionalCheck();
                }
                m_linearTexture = !importer.sRGBTexture;
            }

            if ((texture as Texture2DArray) != null)
            {
                ConfigTextureData(TextureType.Texture2DArray);
            }
            else if ((texture as Texture2D) != null)
            {
                ConfigTextureData(TextureType.Texture2D);
            }
            else if ((texture as Texture3D) != null)
            {
                ConfigTextureData(TextureType.Texture3D);
            }
            else if ((texture as Cubemap) != null)
            {
                ConfigTextureData(TextureType.Cube);
            }
#if !UNITY_2018_1_OR_NEWER
            // Disabling Substance Deprecated warning
#pragma warning disable 0618
            else if ((texture as ProceduralTexture) != null)
            {
                ConfigTextureData(TextureType.ProceduralTexture);
            }
#pragma warning restore 0618
#endif

            ConfigureInputPorts();
            ConfigureOutputPorts();
        }