浏览代码

address PR comments

/main
Paul Melamed 6 年前
当前提交
0533e490
共有 5 个文件被更改,包括 55 次插入29 次删除
  1. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs
  2. 60
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader
  3. 10
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalNormalBuffer.shader
  4. 7
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader
  5. 3
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs


CoreUtils.SetKeyword(material, "_ALBEDOCONTRIBUTION", material.GetFloat(kAlbedoMode) == 1.0f);
CoreUtils.SetKeyword(material, "_COLORMAP", material.GetTexture(kBaseColorMap));
CoreUtils.SetKeyword(material, "_NORMALMAP", material.GetTexture(kNormalMap));
CoreUtils.SetKeyword(material, "_MASKMAP", material.GetTexture(kMaskMap));
CoreUtils.SetKeyword(material, "_MASKMAP", material.GetTexture(kMaskMap));
material.SetInt(HDShaderIDs._StencilRef, (int)HDRenderPipeline.StencilBitMask.Decals);
material.SetInt(HDShaderIDs._StencilMask, (int)HDRenderPipeline.StencilBitMask.Decals);
material.SetShaderPassEnabled(HDShaderPassNames.s_MeshDecalsMStr, false);
material.SetShaderPassEnabled(HDShaderPassNames.s_MeshDecalsAOStr, false);
material.SetShaderPassEnabled(HDShaderPassNames.s_MeshDecalsMAOStr, false);

60
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader


Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
// back faces with zfail, for cases when camera is inside the decal volume

// back faces with zfail, for cases when camera is inside the decal volume
Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
Cull Front

// back faces with zfail, for cases when camera is inside the decal volume
Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
Cull Front

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
// back faces with zfail, for cases when camera is inside the decal volume

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
// back faces with zfail, for cases when camera is inside the decal volume

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
// back faces with zfail, for cases when camera is inside the decal volume

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
// back faces with zfail, for cases when camera is inside the decal volume

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

Stencil
{
WriteMask[_StencilMask]
Ref[_StencilRef]
Pass IncrSat
Pass Replace
}
ZWrite Off

10
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalNormalBuffer.shader


normalData.normalWS.xyz = normalize(normalData.normalWS.xyz * DBufferNormal.w + DBufferNormal.xyz);
EncodeIntoNormalBuffer(normalData, uint2(0, 0), GBufferNormal);
_NormalBuffer[input.texcoord * _ScreenSize.xy] = GBufferNormal;
return GBufferNormal;
return float4(0, 0, 0, 0); // normal buffer is written into as a RWTexture
}
ENDHLSL

Blend Off
Cull Off
// depth prepass increments stencil to 1
// dbuffer increments it to 2
// not optimal because we also process pixels that might not have any normals
Ref 2
ReadMask[_StencilMask]
Ref[_StencilRef]
Pass Zero
Pass Zero // doesn't really matter, but clear to 0 for debugging
}
HLSLPROGRAM

7
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader


ZWrite On
// decals rely on this to mask out the pixels that need to be updated in the normal buffer (forward)
Stencil
{
Comp Always
Pass IncrSat
}
HLSLPROGRAM
// In deferred, depth only pass don't output anything.

3
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


{
Clear = 0, // 0x0
LightingMask = 7, // 0x7 - 3 bit
Decals = 8, // 0x8 - 1 bit
ObjectVelocity = 128, // 0x80 - 1 bit
All = 255 // 0xFF - 8 bit
}

m_CopyStencilForNoLighting.SetInt(HDShaderIDs._StencilMask, (int)StencilBitMask.LightingMask);
m_CameraMotionVectorsMaterial = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.cameraMotionVectors);
m_DecalNormalBufferMaterial = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.decalNormalBuffer);
m_DecalNormalBufferMaterial.SetInt(HDShaderIDs._StencilRef, (int)StencilBitMask.Decals);
m_DecalNormalBufferMaterial.SetInt(HDShaderIDs._StencilMask, (int)StencilBitMask.Decals);
m_CopyDepth = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.copyDepthBuffer);

正在加载...
取消
保存