initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
|
@ -0,0 +1,100 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine.Rendering.Universal.Internal;
|
||||
|
||||
namespace UnityEngine.Rendering.Universal
|
||||
{
|
||||
internal class DecalDrawGBufferSystem : DecalDrawSystem
|
||||
{
|
||||
public DecalDrawGBufferSystem(DecalEntityManager entityManager) : base("DecalDrawGBufferSystem.Execute", entityManager) { }
|
||||
protected override int GetPassIndex(DecalCachedChunk decalCachedChunk) => decalCachedChunk.passIndexGBuffer;
|
||||
}
|
||||
|
||||
internal class DecalGBufferRenderPass : ScriptableRenderPass
|
||||
{
|
||||
private FilteringSettings m_FilteringSettings;
|
||||
private ProfilingSampler m_ProfilingSampler;
|
||||
private List<ShaderTagId> m_ShaderTagIdList;
|
||||
private DecalDrawGBufferSystem m_DrawSystem;
|
||||
private DecalScreenSpaceSettings m_Settings;
|
||||
private DeferredLights m_DeferredLights;
|
||||
private RenderTargetIdentifier[] m_GbufferAttachments;
|
||||
|
||||
public DecalGBufferRenderPass(DecalScreenSpaceSettings settings, DecalDrawGBufferSystem drawSystem)
|
||||
{
|
||||
renderPassEvent = RenderPassEvent.AfterRenderingGbuffer;
|
||||
|
||||
m_DrawSystem = drawSystem;
|
||||
m_Settings = settings;
|
||||
m_ProfilingSampler = new ProfilingSampler("Decal GBuffer Render");
|
||||
m_FilteringSettings = new FilteringSettings(RenderQueueRange.opaque, -1);
|
||||
|
||||
m_ShaderTagIdList = new List<ShaderTagId>();
|
||||
if (drawSystem == null)
|
||||
m_ShaderTagIdList.Add(new ShaderTagId(DecalShaderPassNames.DecalGBufferProjector));
|
||||
else
|
||||
m_ShaderTagIdList.Add(new ShaderTagId(DecalShaderPassNames.DecalGBufferMesh));
|
||||
}
|
||||
|
||||
internal void Setup(DeferredLights deferredLights)
|
||||
{
|
||||
m_DeferredLights = deferredLights;
|
||||
}
|
||||
|
||||
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
|
||||
{
|
||||
if (m_DeferredLights != null && m_DeferredLights.UseRenderPass)
|
||||
{
|
||||
if (m_GbufferAttachments == null)
|
||||
m_GbufferAttachments = new RenderTargetIdentifier[]
|
||||
{
|
||||
m_DeferredLights.GbufferAttachmentIdentifiers[0], m_DeferredLights.GbufferAttachmentIdentifiers[1],
|
||||
m_DeferredLights.GbufferAttachmentIdentifiers[2], m_DeferredLights.GbufferAttachmentIdentifiers[3]
|
||||
};
|
||||
}
|
||||
else
|
||||
m_GbufferAttachments = m_DeferredLights.GbufferAttachmentIdentifiers;
|
||||
|
||||
ConfigureTarget(m_GbufferAttachments, m_DeferredLights.DepthAttachmentIdentifier);
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
SortingCriteria sortingCriteria = renderingData.cameraData.defaultOpaqueSortFlags;
|
||||
DrawingSettings drawingSettings = CreateDrawingSettings(m_ShaderTagIdList, ref renderingData, sortingCriteria);
|
||||
|
||||
CommandBuffer cmd = CommandBufferPool.Get();
|
||||
using (new ProfilingScope(cmd, m_ProfilingSampler))
|
||||
{
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
|
||||
NormalReconstruction.SetupProperties(cmd, renderingData.cameraData);
|
||||
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendLow, m_Settings.normalBlend == DecalNormalBlend.Low);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendMedium, m_Settings.normalBlend == DecalNormalBlend.Medium);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendHigh, m_Settings.normalBlend == DecalNormalBlend.High);
|
||||
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
|
||||
m_DrawSystem?.Execute(cmd);
|
||||
|
||||
context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref m_FilteringSettings);
|
||||
}
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
CommandBufferPool.Release(cmd);
|
||||
}
|
||||
|
||||
public override void OnCameraCleanup(CommandBuffer cmd)
|
||||
{
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new System.ArgumentNullException("cmd");
|
||||
}
|
||||
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendLow, false);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendMedium, false);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendHigh, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4fc75fc0db61f674ab4e788dd0b34295
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine.Rendering.Universal.Internal;
|
||||
|
||||
namespace UnityEngine.Rendering.Universal
|
||||
{
|
||||
internal class DecalDrawScreenSpaceSystem : DecalDrawSystem
|
||||
{
|
||||
public DecalDrawScreenSpaceSystem(DecalEntityManager entityManager) : base("DecalDrawScreenSpaceSystem.Execute", entityManager) { }
|
||||
protected override int GetPassIndex(DecalCachedChunk decalCachedChunk) => decalCachedChunk.passIndexScreenSpace;
|
||||
}
|
||||
|
||||
internal class DecalScreenSpaceRenderPass : ScriptableRenderPass
|
||||
{
|
||||
private FilteringSettings m_FilteringSettings;
|
||||
private ProfilingSampler m_ProfilingSampler;
|
||||
private List<ShaderTagId> m_ShaderTagIdList;
|
||||
private DecalDrawScreenSpaceSystem m_DrawSystem;
|
||||
private DecalScreenSpaceSettings m_Settings;
|
||||
|
||||
public DecalScreenSpaceRenderPass(DecalScreenSpaceSettings settings, DecalDrawScreenSpaceSystem drawSystem)
|
||||
{
|
||||
renderPassEvent = RenderPassEvent.AfterRenderingSkybox;
|
||||
ConfigureInput(ScriptableRenderPassInput.Depth); // Require depth
|
||||
|
||||
m_DrawSystem = drawSystem;
|
||||
m_Settings = settings;
|
||||
m_ProfilingSampler = new ProfilingSampler("Decal Screen Space Render");
|
||||
m_FilteringSettings = new FilteringSettings(RenderQueueRange.opaque, -1);
|
||||
|
||||
m_ShaderTagIdList = new List<ShaderTagId>();
|
||||
|
||||
if (m_DrawSystem == null)
|
||||
m_ShaderTagIdList.Add(new ShaderTagId(DecalShaderPassNames.DecalScreenSpaceProjector));
|
||||
else
|
||||
m_ShaderTagIdList.Add(new ShaderTagId(DecalShaderPassNames.DecalScreenSpaceMesh));
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
SortingCriteria sortingCriteria = SortingCriteria.CommonTransparent;
|
||||
DrawingSettings drawingSettings = CreateDrawingSettings(m_ShaderTagIdList, ref renderingData, sortingCriteria);
|
||||
|
||||
CommandBuffer cmd = CommandBufferPool.Get();
|
||||
using (new ProfilingScope(cmd, m_ProfilingSampler))
|
||||
{
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
|
||||
NormalReconstruction.SetupProperties(cmd, renderingData.cameraData);
|
||||
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendLow, m_Settings.normalBlend == DecalNormalBlend.Low);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendMedium, m_Settings.normalBlend == DecalNormalBlend.Medium);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendHigh, m_Settings.normalBlend == DecalNormalBlend.High);
|
||||
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
|
||||
m_DrawSystem?.Execute(cmd);
|
||||
|
||||
context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref m_FilteringSettings);
|
||||
}
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
CommandBufferPool.Release(cmd);
|
||||
}
|
||||
|
||||
public override void OnCameraCleanup(CommandBuffer cmd)
|
||||
{
|
||||
if (cmd == null)
|
||||
{
|
||||
throw new System.ArgumentNullException("cmd");
|
||||
}
|
||||
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendLow, false);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendMedium, false);
|
||||
CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DecalNormalBlendHigh, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 689773a2623777f4980186bdb52e4df5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue