浏览代码

Update all shader with correct stencil write mask

/feature-ReflectionProbeFit
sebastienlagarde 7 年前
当前提交
d032f5a2
共有 6 个文件被更改,包括 84 次插入16 次删除
  1. 9
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/BaseLitUI.cs
  2. 27
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  3. 27
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  4. 15
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  5. 21
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  6. 1
      ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CameraMotionVectors.shader

9
ScriptableRenderPipeline/HDRenderPipeline/Editor/Material/Lit/BaseLitUI.cs


protected MaterialProperty materialID = null;
protected const string kMaterialID = "_MaterialID";
protected const string kStencilRef = "_StencilRef";
protected const string kStencilRef = "_StencilRef";
protected const string kStencilWriteMask = "_StencilWriteMask";
protected const string kStencilRefMV = "_StencilRefMV";
protected const string kStencilWriteMaskMV = "_StencilWriteMaskMV";
protected MaterialProperty displacementMode = null;
protected const string kDisplacementMode = "_DisplacementMode";

{
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(kStencilWriteMask, (int)HDRenderPipeline.StencilBitMask.Lighting);
material.SetInt(kStencilRefMV, (int)HDRenderPipeline.StencilBitMask.ObjectVelocity);
material.SetInt(kStencilWriteMaskMV, (int)HDRenderPipeline.StencilBitMask.ObjectVelocity);
bool enableDisplacement = (DisplacementMode)material.GetFloat(kDisplacementMode) != DisplacementMode.None;
bool enableVertexDisplacement = (DisplacementMode)material.GetFloat(kDisplacementMode) == DisplacementMode.Vertex;

27
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time)
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time)
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0

Stencil
{
Ref [_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref [_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref [_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
// If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity
Stencil
{
WriteMask [_StencilWriteMaskMV]
Ref [_StencilRefMV]
Comp Always
Pass Replace
}
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

27
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time)
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time)
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0

Stencil
{
Ref [_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref [_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref [_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
// If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity
Stencil
{
WriteMask [_StencilWriteMaskMV]
Ref [_StencilRefMV]
Comp Always
Pass Replace
}
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

15
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time)
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time)
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0

Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace

Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace

Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace

// If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity
Stencil
{
Ref 128 // StencilBitMask.ObjectVelocity
WriteMask [_StencilWriteMaskMV]
Ref [_StencilRefMV]
Comp Always
Pass Replace
}

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

21
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMask("_StencilWriteMask", Int) = 7 // StencilMask.Lighting (fixed at compile time)
[HideInInspector] _StencilRefMV("_StencilRefMV", Int) = 128 // StencilLightingUsage.RegularLighting (fixed at compile time)
[HideInInspector] _StencilWriteMaskMV("_StencilWriteMaskMV", Int) = 128 // StencilMask.ObjectsVelocity (fixed at compile time)
// Blending state
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0

Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace

Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace

Stencil
{
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace

Name "Motion Vectors"
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity)
// If velocity pass (motion vectors) is enabled we tag the stencil so it don't perform CameraMotionVelocity
Stencil
{
WriteMask [_StencilWriteMaskMV]
Ref [_StencilRefMV]
Comp Always
Pass Replace
}
Cull[_CullMode]
ZWrite Off // TODO: Test Z equal here.

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

Stencil
{
Ref[_StencilRef]
WriteMask [_StencilWriteMask]
Ref [_StencilRef]
Comp Always
Pass Replace
}

1
ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CameraMotionVectors.shader


// We will perform camera motion velocity only where there is no object velocity
Stencil
{
ReadMask 128
Ref 128 // StencilBitMask.ObjectVelocity
Comp NotEqual
Pass Keep

正在加载...
取消
保存