浏览代码

Address PR comments and fix player build

/main
Paul Melamed 6 年前
当前提交
376207de
共有 4 个文件被更改,包括 20 次插入14 次删除
  1. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs
  2. 12
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalNormalBuffer.shader
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalProjectorComponent.cs
  4. 16
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs


material.SetInt(kStencilWriteMaskMV, (int)HDRenderPipeline.StencilBitMask.ObjectVelocity);
// for depth only pass to be used in decal to normal buffer compositing
material.SetInt(kStencilDepthPrepassRef, (int)HDRenderPipeline.StencilBitMask.StackLit);
material.SetInt(kStencilDepthPrepassWriteMask, (int)HDRenderPipeline.StencilBitMask.StackLit);
material.SetInt(kStencilDepthPrepassRef, (int)HDRenderPipeline.StencilBitMask.DecalsForwardOutputNormalBuffer);
material.SetInt(kStencilDepthPrepassWriteMask, (int)HDRenderPipeline.StencilBitMask.DecalsForwardOutputNormalBuffer);
}
}
} // namespace UnityEditor

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


#include "../../ShaderVariables.hlsl"
#include "Decal.hlsl"
#include "../NormalBuffer.hlsl"
TEXTURE2D(_DBufferTexture1);
RW_TEXTURE2D(float4, _NormalBuffer);
struct Attributes

float2 texcoord : TEXCOORD0;
};
DECLARE_DBUFFER_TEXTURE(_DBufferTexture);
Varyings Vert(Attributes input)
{
Varyings output;

float4 FragNearest(Varyings input) : SV_Target
{
float4 DBufferNormal = LOAD_TEXTURE2D(_DBufferTexture1, input.texcoord * _ScreenSize.xy) * float4(2.0f, 2.0f, 2.0f, 1.0f) - float4(1.0f, 1.0f, 1.0f, 0.0f);
FETCH_DBUFFER(DBuffer, _DBufferTexture, input.texcoord * _ScreenSize.xy);
DecalSurfaceData decalSurfaceData;
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData);
normalData.normalWS.xyz = normalize(normalData.normalWS.xyz * DBufferNormal.w + DBufferNormal.xyz);
normalData.normalWS.xyz = normalize(normalData.normalWS.xyz * decalSurfaceData.normalWS.w + decalSurfaceData.normalWS.xyz);
EncodeIntoNormalBuffer(normalData, uint2(0, 0), GBufferNormal);
_NormalBuffer[input.texcoord * _ScreenSize.xy] = GBufferNormal;
return float4(0, 0, 0, 0); // normal buffer is written into as a RWTexture

2
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalProjectorComponent.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[ExecuteInEditMode]
#if UNITY_EDITOR
#endif
public class DecalProjectorComponent : MonoBehaviour
{
public Material m_Material = null;

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


[Flags]
public enum StencilBitMask
{
Clear = 0, // 0x0
LightingMask = 7, // 0x7 - 3 bit
Decals = 8, // 0x8 - 1 bit
StackLit = 16, // 0x10 - 1 bit
ObjectVelocity = 128, // 0x80 - 1 bit
All = 255 // 0xFF - 8 bit
Clear = 0, // 0x0
LightingMask = 7, // 0x7 - 3 bit
Decals = 8, // 0x8 - 1 bit
DecalsForwardOutputNormalBuffer = 16, // 0x10 - 1 bit
ObjectVelocity = 128, // 0x80 - 1 bit
All = 255 // 0xFF - 8 bit
}
RenderStateBlock m_DepthStateOpaque;

}
else // in deferred rendering only pixels affected by both forward materials and decals need to be composited
{
stencilMask = (int)StencilBitMask.Decals | (int)StencilBitMask.StackLit;
stencilRef = (int)StencilBitMask.Decals | (int)StencilBitMask.StackLit;
stencilMask = (int)StencilBitMask.Decals | (int)StencilBitMask.DecalsForwardOutputNormalBuffer;
stencilRef = (int)StencilBitMask.Decals | (int)StencilBitMask.DecalsForwardOutputNormalBuffer;
}
m_DecalNormalBufferMaterial.SetInt(HDShaderIDs._DecalNormalBufferStencilReadMask, stencilMask);

正在加载...
取消
保存