public static GUIContent smoothnessMapChannelText = new GUIContent ( "Smoothness Source" , "Smoothness texture and channel" ) ;
public static GUIContent metallicText = new GUIContent ( "Metallic" , "Metallic scale factor" ) ;
public static GUIContent smoothnessText = new GUIContent ( "Smoothness" , "Smoothness scale factor" ) ;
public static GUIContent maskMapESText = new GUIContent ( "Mask Map - M(R), AO(G), E(B), S(A)" , "Mask map" ) ;
public static GUIContent maskMapSText = new GUIContent ( "Mask Map - M(R), AO(G), S(A)" , "Mask map" ) ;
public static GUIContent maskMapSText = new GUIContent ( "Mask Map - M(R), AO(G), D(B), S(A)" , "Mask map" ) ;
public static GUIContent normalMapSpaceText = new GUIContent ( "Normal Map space" , "" ) ;
public static GUIContent normalMapText = new GUIContent ( "Normal Map" , "Normal Map (BC7/BC5/DXT5(nm))" ) ;
public static string detailText = "Detail Inputs" ;
public static GUIContent UVDetailMappingText = new GUIContent ( "Detail UV mapping" , "" ) ;
public static GUIContent detailMapNormalText = new GUIContent ( "Detail Map A(R) Ny(G) S(B) Nx(A)" , "Detail Map" ) ;
public static GUIContent detailMaskText = new GUIContent ( "Detail Mask (G)" , "Mask for detailMap" ) ;
public static GUIContent detailAlbedoScaleText = new GUIContent ( "Detail AlbedoScale" , "Detail Albedo Scale factor" ) ;
public static GUIContent detailNormalScaleText = new GUIContent ( "Detail NormalScale" , "Normal Scale factor" ) ;
public static GUIContent detailSmoothnessScaleText = new GUIContent ( "Detail SmoothnessScale" , "Smoothness Scale factor" ) ;
public static string lightingText = "Lighting Inputs" ;
public static GUIContent emissiveText = new GUIContent ( "Emissive Color" , "Emissive" ) ;
public static GUIContent emissiveIntensityText = new GUIContent ( "Emissive Intensity" , "Emissive" ) ;
public static GUIContent emissiveColorMod eText = new GUIContent ( "Emissive Color Usag e" , "Use emissive color or emissive mask " ) ;
public static GUIContent alb edoAffectE missiveText = new GUIContent ( "Albedo Affect Emissive" , "Specifies whether or not the emissive color is multiplied by the albedo. " ) ;
public static GUIContent normalMapSpaceWarning = new GUIContent ( "Object space normal can't be use with triplanar mapping." ) ;
}
UV3
}
public enum EmissiveColorMode
{
UseEmissiveColor ,
UseEmissiveMask ,
}
protected MaterialProperty [ ] UVBase = new MaterialProperty [ kMaxLayerCount ] ;
protected const string kUVBase = "_UVBase" ;
protected MaterialProperty [ ] TexWorldScale = new MaterialProperty [ kMaxLayerCount ] ;
protected const string kUVDetailsMappingMask = "_UVDetailsMappingMask" ;
protected MaterialProperty [ ] detailMap = new MaterialProperty [ kMaxLayerCount ] ;
protected const string kDetailMap = "_DetailMap" ;
protected MaterialProperty [ ] detailMask = new MaterialProperty [ kMaxLayerCount ] ;
protected const string kDetailMask = "_DetailMask" ;
protected MaterialProperty [ ] detailAlbedoScale = new MaterialProperty [ kMaxLayerCount ] ;
protected const string kDetailAlbedoScale = "_DetailAlbedoScale" ;
protected MaterialProperty [ ] detailNormalScale = new MaterialProperty [ kMaxLayerCount ] ;
protected const string kEmissiveColorMap = "_EmissiveColorMap" ;
protected MaterialProperty emissiveIntensity = null ;
protected const string kEmissiveIntensity = "_EmissiveIntensity" ;
protected MaterialProperty albedoAffectEmissive = null ;
protected const string kAlbedoAffectEmissive = "_AlbedoAffectEmissive" ;
protected void FindMaterialLayerProperties ( MaterialProperty [ ] props )
{
UVDetail [ i ] = FindProperty ( string . Format ( "{0}{1}" , kUVDetail , m_PropertySuffixes [ i ] ) , props ) ;
UVDetailsMappingMask [ i ] = FindProperty ( string . Format ( "{0}{1}" , kUVDetailsMappingMask , m_PropertySuffixes [ i ] ) , props ) ;
detailMap [ i ] = FindProperty ( string . Format ( "{0}{1}" , kDetailMap , m_PropertySuffixes [ i ] ) , props ) ;
detailMask [ i ] = FindProperty ( string . Format ( "{0}{1}" , kDetailMask , m_PropertySuffixes [ i ] ) , props ) ;
detailAlbedoScale [ i ] = FindProperty ( string . Format ( "{0}{1}" , kDetailAlbedoScale , m_PropertySuffixes [ i ] ) , props ) ;
detailNormalScale [ i ] = FindProperty ( string . Format ( "{0}{1}" , kDetailNormalScale , m_PropertySuffixes [ i ] ) , props ) ;
detailSmoothnessScale [ i ] = FindProperty ( string . Format ( "{0}{1}" , kDetailSmoothnessScale , m_PropertySuffixes [ i ] ) , props ) ;
emissiveColor = FindProperty ( kEmissiveColor , props ) ;
emissiveColorMap = FindProperty ( kEmissiveColorMap , props ) ;
emissiveIntensity = FindProperty ( kEmissiveIntensity , props ) ;
albedoAffectEmissive = FindProperty ( kAlbedoAffectEmissive , props ) ;
}
protected override void FindMaterialProperties ( MaterialProperty [ ] props )
m_MaterialEditor . TexturePropertySingleLine ( Styles . anisotropyMapText , anisotropyMap ) ;
}
protected void DoLayerGUI ( Material material , bool useEmissiveMask , int layerIndex )
protected void DoLayerGUI ( Material material , int layerIndex )
{
EditorGUILayout . LabelField ( Styles . InputsText , EditorStyles . boldLabel ) ;
m_MaterialEditor . ShaderProperty ( smoothness [ layerIndex ] , Styles . smoothnessText ) ;
if ( useEmissiveMask )
m_MaterialEditor . TexturePropertySingleLine ( Styles . maskMapESText , maskMap [ layerIndex ] ) ;
else
m_MaterialEditor . TexturePropertySingleLine ( Styles . maskMapSText , maskMap [ layerIndex ] ) ;
m_MaterialEditor . TexturePropertySingleLine ( Styles . maskMapSText , maskMap [ layerIndex ] ) ;
m_MaterialEditor . TexturePropertySingleLine ( Styles . specularOcclusionMapText , specularOcclusionMap [ layerIndex ] ) ;
EditorGUILayout . LabelField ( Styles . detailText , EditorStyles . boldLabel ) ;
EditorGUI . indentLevel + + ;
m_MaterialEditor . TexturePropertySingleLine ( Styles . detailMaskText , detailMask [ layerIndex ] ) ;
m_MaterialEditor . TexturePropertySingleLine ( Styles . detailMapNormalText , detailMap [ layerIndex ] ) ;
// When Planar or Triplanar is enable the UVDetail use the same mode, so we disable the choice on UVDetail
EditorGUI . indentLevel - - ;
}
protected override void MaterialPropertiesGUI ( Material material )
protected void DoEmissiveGUI ( )
bool useEmissiveMask = ( EmissiveColorMode ) emissiveColorMode . floatValue = = EmissiveColorMode . UseEmissiveMask ;
DoLayerGUI ( material , useEmissiveMask , 0 ) ;
m_MaterialEditor . ShaderProperty ( emissiveColorMode , Styles . emissiveColorModeText ) ;
if ( ! useEmissiveMask )
{
m_MaterialEditor . TexturePropertySingleLine ( Styles . emissiveText , emissiveColorMap , emissiveColor ) ;
}
m_MaterialEditor . TexturePropertySingleLine ( Styles . emissiveText , emissiveColorMap , emissiveColor ) ;
m_MaterialEditor . ShaderProperty ( albedoAffectEmissive , Styles . albedoAffectEmissiveText ) ;
EditorGUI . indentLevel - - ;
}
EditorGUI . indentLevel - - ;
protected override void MaterialPropertiesGUI ( Material material )
{
DoLayerGUI ( material , 0 ) ;
DoEmissiveGUI ( ) ;
// The parent Base.ShaderPropertiesGUI will call DoEmissionArea
}
SetKeyword ( material , "_MAPPING_PLANAR" , ( ( UVBaseMapping ) material . GetFloat ( kUVBase ) ) = = UVBaseMapping . Planar ) ;
SetKeyword ( material , "_MAPPING_TRIPLANAR" , ( ( UVBaseMapping ) material . GetFloat ( kUVBase ) ) = = UVBaseMapping . Triplanar ) ;
SetKeyword ( material , "_NORMALMAP_TANGENT_SPACE" , ( normalMapSpace = = NormalMapSpace . TangentSpace ) ) ;
SetKeyword ( material , "_EMISSIVE_COLOR" , ( ( EmissiveColorMode ) material . GetFloat ( kEmissiveColorMode ) ) = = EmissiveColorMode . UseEmissiveColor ) ;
if ( normalMapSpace = = NormalMapSpace . TangentSpace )
{