Description
Show stencil settings of the shader.
Reference

- Stencil Reference – Edit the settings of the reference property.
- Stencil Read Mask – Edit the settings of the read mask property.
- Stencil Write Mask – Edit the settings of the write mask property.
- Stencil Compare Function – Edit the settings of the compare function property.
- Stencil Pass Operation – Edit the settings of the pass operation property.
- Stencil Fail Operation – Edit the settings of the fail operation property.
- Stencil ZFail Operation – Edit the settings of the zfail operation property.
- Show Stencil Mask – Show the stencil mask.
- Stencil Color Mask (RGBA) – Color of the stencil mask.
Use
public class CGFSampleMaterialEditor : CGFMaterialEditorClass
{
MaterialProperty _StencilReference;
MaterialProperty _StencilReadMask;
MaterialProperty _StencilWriteMask;
MaterialProperty _StencilCompareFunction;
MaterialProperty _StencilPassOperation;
MaterialProperty _StencilFailOperation;
MaterialProperty _StencilZFailOperation;
MaterialProperty _ShowStencilMask;
MaterialProperty _StencilColorMask;
public override void OnEnable()
{
base.OnEnable();
GetProperties();
}
private void GetProperties()
{
_Stencil = FindProperty("_StencilReference");
_Stencil = FindProperty("_StencilReadMask");
_Stencil = FindProperty("_StencilWriteMask");
_Stencil = FindProperty("_StencilCompareFunction");
_Stencil = FindProperty("_StencilPassOperation");
_Stencil = FindProperty("_StencilFailOperation");
_Stencil = FindProperty("_StencilZFailOperation");
_Stencil = FindProperty("_ShowStencilMask");
_Stencil = FindProperty("_StencilColorMask");
}
public override void InspectorGUI()
{
CGFMaterialEditorUtilitiesClass.BuildSliderRound("Stencil Reference", "The value to be compared against (if Comp is anything else than always) and/or the value to be written to the buffer (if either Pass, Fail or ZFail is set to replace). 0–255 integer.", _StencilReference);
CGFMaterialEditorUtilitiesClass.BuildSliderRound("Stencil Read Mask", "An 8 bit mask as an 0–255 integer, used when comparing the reference value with the contents of the buffer (referenceValue & readMask) comparisonFunction (stencilBufferValue & readMask). Default: 255.", _StencilReadMask);
CGFMaterialEditorUtilitiesClass.BuildSliderRound("Stencil Write Mask", "An 8 bit mask as an 0–255 integer, used when writing to the buffer. Note that, like other write masks, it specifies which bits of stencil buffer will be affected by write (i.e. WriteMask 0 means that no bits are affected and not that 0 will be written). Default: 255.", _StencilWriteMask);
CGFMaterialEditorUtilitiesClass.BuildStencilCompareFunction(_StencilComparisonFunction, this);
CGFMaterialEditorUtilitiesClass.BuildStencilPassOperation(_StencilPassOperation, this);
CGFMaterialEditorUtilitiesClass.BuildStencilFailOperation(_StencilFailOperation, this);
CGFMaterialEditorUtilitiesClass.BuildStencilZFailOperation(_StencilZFailOperation, this);
CGFMaterialEditorUtilitiesClass.BuildToggleFloat("Show Stencil Mask", "Should the mesh of the masking object be drawn with alpha? Set color channel writing mask. Writing ColorMask 0 turns off rendering to all color channels. Default mode is writing to all channels (RGBA), but for some special effects you might want to leave certain channels unmodified, or disable color writes completely.", _ShowStencilMask, 15.0f);
CGFMaterialEditorUtilitiesClass.BuildColor("Stencil Color Mask (RGBA)", "Stencil Color Mask.", _StencilColorMask, (_ShowStencilMask.floatValue > 0 ? 1 : 0));
}
}