浏览代码

Rename EnableDBuffer to EnableDecals + Fix issue with MAOS

/main
Sebastien Lagarde 7 年前
当前提交
09ca5ea6
共有 7 个文件被更改,包括 20 次插入12 次删除
  1. 7
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/Decal/DecalUI.cs
  2. 6
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DBufferManager.cs
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.hlsl
  4. 5
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalUtilities.hlsl
  5. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/ShaderVariablesDecal.hlsl
  6. 8
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  7. 2
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs

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


if ((maskmapMetal.floatValue == 0.0f) && (maskmapAO.floatValue == 0.0f) && (maskmapSmoothness.floatValue == 0.0f))
maskmapSmoothness.floatValue = 1.0f;
maskBlendFlags = 0; // Re-init the mask
if (maskmapMetal.floatValue == 1.0f)
maskBlendFlags |= Decal.MaskBlendFlags.Metal;
if (maskmapAO.floatValue == 1.0f)

}
else // if perChannelMask is not enabled, force to have smoothness
{
maskBlendFlags = Decal.MaskBlendFlags.Smoothness;
}
m_MaterialEditor.ShaderProperty(decalBlend, Styles.decalBlendText);
m_MaterialEditor.ShaderProperty(decalMeshDepthBias, Styles.MeshDecalDepthBiasText);
EditorGUI.indentLevel--;

6
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DBufferManager.cs


{
public class DBufferManager : MRTBufferManager
{
public bool enableDBuffer { get; set; }
public bool enableDecals { get; set; }
RTHandleSystem.RTHandle m_HTile;

{
if (hdCamera.frameSettings.enableDecals)
{
cmd.SetGlobalInt(HDShaderIDs._EnableDBuffer, enableDBuffer ? 1 : 0);
cmd.SetGlobalInt(HDShaderIDs._EnableDecals, enableDecals ? 1 : 0);
cmd.SetGlobalInt(HDShaderIDs._EnableDBuffer, 0);
cmd.SetGlobalInt(HDShaderIDs._EnableDecals, 0);
// We still bind black textures to make sure that something is bound (can be a problem on some platforms)
for (int i = 0; i < m_BufferCount; ++i)
{

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


{
ZERO_INITIALIZE(DecalSurfaceData, surfaceData);
surfaceData.baseColor = inDBuffer0;
surfaceData.normalWS.xyz = inDBuffer1.xyz * 2.0f - 1.0f;
surfaceData.normalWS.xyz = inDBuffer1.xyz * 2.0 - 1.0;
surfaceData.normalWS.w = inDBuffer1.w;
surfaceData.mask = inDBuffer2;
#ifdef _DECALS_4RT

5
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalUtilities.hlsl


void AddDecalContribution(PositionInputs posInput, inout SurfaceData surfaceData, inout float alpha)
{
if (_EnableDBuffer)
if (_EnableDecals)
DecalSurfaceData decalSurfaceData;
int mask = 0;
// the code in the macros, gets moved inside the conditionals by the compiler
FETCH_DBUFFER(DBuffer, _DBufferTexture, posInput.positionSS);

#else
mask = UnpackByte(LOAD_TEXTURE2D(_DecalHTileTexture, posInput.positionSS / 8).r);
#endif
DecalSurfaceData decalSurfaceData;
DECODE_FROM_DBUFFER(DBuffer, decalSurfaceData);
// using alpha compositing https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch23.html
if (mask & DBUFFERHTILEBIT_DIFFUSE)

{
surfaceData.normalWS.xyz = normalize(surfaceData.normalWS.xyz * decalSurfaceData.normalWS.w + decalSurfaceData.normalWS.xyz);
}
if (mask & DBUFFERHTILEBIT_MASK)
{
#ifdef _DECALS_4RT // only smoothness in 3RT mode

2
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/ShaderVariablesDecal.hlsl


#ifdef SHADER_VARIABLES_INCLUDE_CB
uint _EnableDBuffer;
uint _EnableDecals;
float2 _DecalAtlasResolution;
#else
#endif

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


m_ReflectionProbeCullResults.Cull();
m_DbufferManager.enableDBuffer = false;
m_DbufferManager.enableDecals = false;
m_DbufferManager.enableDBuffer = true; // mesh decals are renderers managed by c++ runtime and we have no way to query if any are visible, so set to true
m_DbufferManager.enableDecals = true; // mesh decals are renderers managed by c++ runtime and we have no way to query if any are visible, so set to true
DecalSystem.instance.UpdateCachedMaterialData(); // textures, alpha or fade distances could've changed
DecalSystem.instance.CreateDrawData(); // prepare data is separate from draw
DecalSystem.instance.UpdateTextureAtlas(cmd); // as this is only used for transparent pass, would've been nice not to have to do this if no transparent renderers are visible, needs to happen after CreateDrawData

}
}
// If we enable DBuffer, we need a full depth prepass
else if (hdCamera.frameSettings.enableDepthPrepassWithDeferredRendering || m_DbufferManager.enableDBuffer)
else if (hdCamera.frameSettings.enableDepthPrepassWithDeferredRendering || m_DbufferManager.enableDecals)
using (new ProfilingSample(cmd, m_DbufferManager.enableDBuffer ? "Depth Prepass (deferred) force by DBuffer" : "Depth Prepass (deferred)", CustomSamplerId.DepthPrepass.GetSampler()))
using (new ProfilingSample(cmd, m_DbufferManager.enableDecals ? "Depth Prepass (deferred) force by Decals" : "Depth Prepass (deferred)", CustomSamplerId.DepthPrepass.GetSampler()))
{
cmd.DisableShaderKeyword("WRITE_NORMAL_BUFFER"); // Note: This only disable the output of normal buffer for Lit shader, not the other shader that don't use multicompile

2
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs


public static readonly int _CameraFilteringBuffer = Shader.PropertyToID("_CameraFilteringTexture");
public static readonly int _IrradianceSource = Shader.PropertyToID("_IrradianceSource");
public static readonly int _EnableDBuffer = Shader.PropertyToID("_EnableDBuffer");
public static readonly int _EnableDecals = Shader.PropertyToID("_EnableDecals");
public static readonly int _DecalAtlasResolution = Shader.PropertyToID("_DecalAtlasResolution");
public static readonly int[] _GBufferTexture =

正在加载...
取消
保存