浏览代码

Merged with master.

integrated decal group culling with HDRenderPipeline
/prototype-decals
Paul Melamed 7 年前
当前提交
50503a53
共有 3 个文件被更改,包括 18 次插入11 次删除
  1. 17
      ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalSystem.cs
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalProperties.hlsl

17
ScriptableRenderPipeline/HDRenderPipeline/Decal/DecalSystem.cs


Mesh m_DecalMesh;
CullingGroup m_CullingGroup;
private BoundingSphere[] m_BoundingSpheres;
private int[] m_ResultIndices;
private int m_NumResults = 0;
public DecalSystem()
{

void UpdateCulling()
{
m_BoundingSpheres = new BoundingSphere[m_Decals.Count];
m_ResultIndices = new int[m_Decals.Count];
int cullIndex = 0;
foreach (var decal in m_Decals)
{

m_CullingGroup.SetBoundingSpheres(m_BoundingSpheres);
}
public int QueryCullResults()
{
m_NumResults = m_CullingGroup.QueryIndices(true, m_ResultIndices, 0);
return m_NumResults;
}
int numResults = 0;
int[] resultIndices = new int[m_Decals.Count];
numResults = m_CullingGroup.QueryIndices(true, resultIndices, 0);
for (int resultIndex = 0; resultIndex < numResults; resultIndex++)
for (int resultIndex = 0; resultIndex < m_NumResults; resultIndex++)
int decalIndex = resultIndices[resultIndex];
int decalIndex = m_ResultIndices[resultIndex];
// If no decal material assigned, don't draw it
if (m_Decals[decalIndex].m_Material == null)

6
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


}
#endif
// decal system needs to be updated with current camera
DecalSystem.instance.Cull(camera);
if (m_FrameSettings.enableDBuffer)
DecalSystem.instance.Cull(camera);
using (new ProfilingSample(cmd, "CullResults.Cull", GetSampler(CustomSamplerId.CullResultsCull)))
{

InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
RenderDepthPrepass(m_CullResults, hdCamera, renderContext, cmd, true);
bool forcePrepassForDecals = m_FrameSettings.enableDBuffer && (DecalSystem.instance.QueryCullResults() > 0);
RenderDepthPrepass(m_CullResults, hdCamera, renderContext, cmd, forcePrepassForDecals);
RenderObjectsVelocity(m_CullResults, hdCamera, renderContext, cmd);

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Decal/DecalProperties.hlsl


TEXTURE2D(_BaseColorMap);
SAMPLER2D(sampler_BaseColorMap);
SAMPLER(sampler_BaseColorMap);
SAMPLER2D(sampler_NormalMap);
SAMPLER(sampler_NormalMap);
SAMPLER2D(sampler_MaskMap);
SAMPLER(sampler_MaskMap);
float _DecalBlend;

正在加载...
取消
保存