// Material ID
public static GUIContent materialIDText = new GUIContent ( "Material type" , "Select a material feature to enable on top of regular material" ) ;
public static GUIContent SSSAndTransmissionTyp eText = new GUIContent ( "SSS and Transmission type" , "Subsurface Scattering for translucent materials such as skin, vegetation, fruit, marble, wax and milk., Transmission for back lighting" ) ;
public static GUIContent transmissionEnabl eText = new GUIContent ( "Enable Transmission" , "Enable Transmission for getting back lighting" ) ;
// Per pixel displacement
public static GUIContent ppdMinSamplesText = new GUIContent ( "Minimum steps" , "Minimum steps (texture sample) to use with per pixel displacement mapping" ) ;
public enum MaterialId
{
LitSSSAndTransmission = 0 ,
LitSSS = 0 ,
LitSpecular = 4
} ;
public enum SSSAndTransmissionType
{
LitSSSAndTransmission = 0 ,
LitSSSOnly = 1 ,
LitTransmissionOnly = 2 ,
LitSpecular = 4 ,
LitTranslucent = 5
} ;
public enum HeightmapParametrization
// Material ID
protected MaterialProperty materialID = null ;
protected const string kMaterialID = "_MaterialID" ;
protected MaterialProperty sssAndTransmissionTyp e = null ;
protected const string kSSSAndTransmissionType = "_SSSAndTransmissionType" ;
protected MaterialProperty transmissionEnabl e = null ;
protected const string kTransmissionEnable = "_TransmissionEnable" ;
protected const string kStencilRef = "_StencilRef" ;
protected const string kStencilWriteMask = "_StencilWriteMask" ;
// MaterialID
materialID = FindProperty ( kMaterialID , props ) ;
sssAndTransmissionTyp e = FindProperty ( kSSSAndTransmissionTyp e , props ) ;
transmissionEnabl e = FindProperty ( kTransmissionEnabl e , props ) ;
displacementMode = FindProperty ( kDisplacementMode , props ) ;
displacementLockObjectScale = FindProperty ( kDisplacementLockObjectScale , props ) ;
}
m_MaterialEditor . ShaderProperty ( materialID , StylesBaseLit . materialIDText ) ;
if ( ( int ) materialID . floatValue = = ( int ) BaseLitGUI . MaterialId . LitSSSAndTransmission )
{
m_MaterialEditor . ShaderProperty ( sssAndTransmissionType , StylesBaseLit . SSSAndTransmissionTypeText ) ;
}
m_MaterialEditor . ShaderProperty ( supportDBuffer , StylesBaseLit . supportDBufferText ) ;
// Set the reference value for the stencil test.
int stencilRef = ( int ) StencilLightingUsage . RegularLighting ;
if ( ( int ) material . GetFloat ( kMaterialID ) = = ( int ) BaseLitGUI . MaterialId . LitSSSAndTransmission )
if ( ( int ) material . GetFloat ( kMaterialID ) = = ( int ) BaseLitGUI . MaterialId . LitSSS )
if ( ( int ) material . GetFloat ( kSSSAndTransmissionType ) = = ( int ) BaseLitGUI . SSSAndTransmissionType . LitSSSAndTransmission | |
( int ) material . GetFloat ( kSSSAndTransmissionType ) = = ( int ) BaseLitGUI . SSSAndTransmissionType . LitSSSOnly )
{
stencilRef = ( int ) StencilLightingUsage . SplitLighting ;
}
stencilRef = ( int ) StencilLightingUsage . SplitLighting ;
}
// As we tag both during velocity pass and Gbuffer pass we need a separate state and we need to use the write mask
material . SetInt ( kStencilRef , stencilRef ) ;