浏览代码

Somre cleanup and refactoring of adding textures to decal atlas

/main
Paul Melamed 7 年前
当前提交
ae602283
共有 2 个文件被更改,包括 24 次插入29 次删除
  1. 48
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs
  2. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

48
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs


private class DecalSet
{
private void InitializeMaterialValues()
public void InitializeMaterialValues()
{
m_Diffuse.m_Texture = m_Material.GetTexture("_BaseColorMap");
m_Normal.m_Texture = m_Material.GetTexture("_NormalMap");

return m_NumResults;
}
private void GetDecalVolumeDataAndBound(Matrix4x4 decalToWorld, Matrix4x4 worldToView)
{
var influenceX = decalToWorld.GetColumn(0) * 0.5f;

}
}
void UpdateTextureCache(CommandBuffer cmd)
{
instance.AddTexture(cmd, m_Diffuse);
instance.AddTexture(cmd, m_Normal);
instance.AddTexture(cmd, m_Mask);
}
public void AddToTextureList(ref List<TextureScaleBias> textureList)
{
if(m_Diffuse.m_Texture != null)

}
}
public void UpdateCachedMaterialData(CommandBuffer cmd)
{
InitializeMaterialValues(); // refresh in case they changed in the UI
UpdateTextureCache(cmd);
}
public void RenderIntoDBuffer(CommandBuffer cmd)
{

}
// updates textures, texture atlas indices and blend value
public void UpdateCachedMaterialData(CommandBuffer cmd)
public void UpdateCachedMaterialData()
instance.m_AllocationSuccess = true;
//instance.m_AllocationSuccess = true;
m_TextureList.Clear();
pair.Value.UpdateCachedMaterialData(cmd);
pair.Value.InitializeMaterialValues();
pair.Value.AddToTextureList(ref m_TextureList);
}
if (!instance.m_AllocationSuccess) // texture failed to find space in the atlas
public void UpdateTextureAtlas(CommandBuffer cmd)
{
m_AllocationSuccess = true;
foreach (TextureScaleBias textureScaleBias in m_TextureList)
instance.m_AllocationSuccess = true;
AddTexture(cmd, textureScaleBias);
}
if (!m_AllocationSuccess) // texture failed to find space in the atlas
{
m_TextureList.Sort(); // sort the texture list largest to smallest for better packing
m_TextureList.Clear();
foreach (var pair in m_DecalSets)
{
pair.Value.AddToTextureList(ref m_TextureList);
}
m_TextureList.Sort();
// texture list now contains all decal textures sorted from largest to smallest for optimal packing
// try again
if(!instance.m_AllocationSuccess) // still failed to allocate, decal atlas size needs to increase
if(!m_AllocationSuccess) // still failed to allocate, decal atlas size needs to increase
{
Debug.LogWarning("Decal texture atlas out of space, decals on transparent geometry might not render correctly, atlas size can be changed in HDRenderPipelineAsset");
}

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


{
DecalSystem.instance.EndCull();
m_DbufferManager.vsibleDecalCount = DecalSystem.m_DecalsVisibleThisFrame;
DecalSystem.instance.UpdateCachedMaterialData(cmd); // textures, alpha or fade distances could've changed
DecalSystem.instance.CreateDrawData(); // prepare data is separate from draw
DecalSystem.instance.UpdateCachedMaterialData(); // textures, alpha or fade distances could've changed
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
DecalSystem.instance.CreateDrawData(); // prepare data is separate from draw
}
}
renderContext.SetupCameraProperties(camera, m_FrameSettings.enableStereo);

正在加载...
取消
保存