public readonly GUIContent inheritBaseNormalText = new GUIContent ( "Normal influence" , "Inherit the normal from the base layer." ) ;
public readonly GUIContent inheritBaseHeightText = new GUIContent ( "Heightmap influence" , "Inherit the height from the base layer." ) ;
public readonly GUIContent inheritBaseColorText = new GUIContent ( "BaseColor influence" , "Inherit the base color from the base layer." ) ;
public readonly GUIContent heightOffset = new GUIContent ( "Height Offset" , "Offset applied to the height before layering." ) ;
public readonly GUIContent heightTransition = new GUIContent ( "Height Transition" , "Size in world units of the smooth transition between layers." ) ;
public readonly GUIContent perPixelDisplacementLayersWarning = new GUIContent ( "For pixel displacement to work correctly, all layers with a heightmap must use the same UV mapping" ) ;
const string kInheritBaseColor = "_InheritBaseColor" ;
// Height blend
MaterialProperty [ ] heightBlendOffset = new MaterialProperty [ kMaxLayerCount ] ;
const string kHeightBlendOffset = "_HeightOffset" ;
MaterialProperty heightTransition = null ;
const string kHeightTransition = "_HeightTransition" ;
{
// Density/opacity mode
opacityAsDensity [ i ] = FindProperty ( string . Format ( "{0}{1}" , kOpacityAsDensity , i ) , props ) ;
heightBlendOffset [ i ] = FindProperty ( string . Format ( "{0}{1}" , kHeightBlendOffset , i ) , props ) ;
showLayer [ i ] = FindProperty ( string . Format ( "{0}{1}" , kShowLayer , i ) , props ) ;
if ( i ! = 0 )
Material material = m_MaterialEditor . target as Material ;
bool mainLayerInfluenceEnable = useMainLayerInfluence . floatValue > 0.0f ;
bool heightBasedBlend = useHeightBasedBlend . floatValue > 0.0f ;
EditorGUILayout . LabelField ( styles . layeringOptionText , EditorStyles . boldLabel ) ;
EditorGUI . indentLevel + + ;
// Main layer does not have any options but height base blend.
if ( layerIndex > 0 )
if ( mainLayerInfluenceEnable ) // This is the only case where we need this sub category.
int paramIndex = layerIndex - 1 ;
EditorGUILayout . LabelField ( styles . layeringOptionText , EditorStyles . boldLabel ) ;
EditorGUI . indentLevel + + ;
m_MaterialEditor . ShaderProperty ( opacityAsDensity [ layerIndex ] , styles . opacityAsDensityText ) ;
// Main layer does not have any options but height base blend.
if ( layerIndex > 0 )
{
int paramIndex = layerIndex - 1 ;
if ( mainLayerInfluenceEnable )
{
m_MaterialEditor . ShaderProperty ( inheritBaseColor [ paramIndex ] , styles . inheritBaseColorText ) ;
m_MaterialEditor . ShaderProperty ( inheritBaseNormal [ paramIndex ] , styles . inheritBaseNormalText ) ;
// Main height influence is only available if the shader use the heightmap for displacement (per vertex or per level)
// We always display it as it can be tricky to know when per pixel displacement is enabled or not
m_MaterialEditor . ShaderProperty ( inheritBaseHeight [ paramIndex ] , styles . inheritBaseHeightText ) ;
m_MaterialEditor . ShaderProperty ( opacityAsDensity [ layerIndex ] , styles . opacityAsDensityText ) ;
if ( mainLayerInfluenceEnable )
{
m_MaterialEditor . ShaderProperty ( inheritBaseColor [ paramIndex ] , styles . inheritBaseColorText ) ;
m_MaterialEditor . ShaderProperty ( inheritBaseNormal [ paramIndex ] , styles . inheritBaseNormalText ) ;
// Main height influence is only available if the shader use the heightmap for displacement (per vertex or per level)
// We always display it as it can be tricky to know when per pixel displacement is enabled or not
m_MaterialEditor . ShaderProperty ( inheritBaseHeight [ paramIndex ] , styles . inheritBaseHeightText ) ;
}
}
else
{
if ( ! useMainLayerInfluence . hasMixedValue & & useMainLayerInfluence . floatValue ! = 0.0f )
else
m_MaterialEditor . TexturePropertySingleLine ( styles . layerInfluenceMapMaskText , layerInfluenceMaskMap ) ;
if ( ! useMainLayerInfluence . hasMixedValue & & useMainLayerInfluence . floatValue ! = 0.0f )
{
m_MaterialEditor . TexturePropertySingleLine ( styles . layerInfluenceMapMaskText , layerInfluenceMaskMap ) ;
}
}
if ( heightBasedBlend )
{
m_MaterialEditor . ShaderProperty ( heightBlendOffset [ layerIndex ] , styles . heightOffset ) ;
EditorGUI . indentLevel - - ;
EditorGUILayout . Space ( ) ;
EditorGUI . indentLevel - - ;
EditorGUILayout . Space ( ) ;
DoLayerGUI ( material , layerIndex , true ) ;