浏览代码

Caching common filter settings. Created method to provide DrawRendererSettings.

/main
Felipe Lira 7 年前
当前提交
5b75c36e
共有 4 个文件被更改,包括 36 次插入42 次删除
  1. 17
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightForwardRenderer.cs
  2. 15
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/DepthOnlyPass.cs
  3. 36
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ForwardLitPass.cs
  4. 10
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ScriptableRenderPass.cs

17
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightForwardRenderer.cs


public ComputeBuffer perObjectLightIndices { get; private set; }
public FilterRenderersSettings opaqueFilterSettings { get; private set; }
public FilterRenderersSettings transparentFilterSettings { get; private set; }
//RenderGraphNode m_RenderGraph;
List<ScriptableRenderPass> m_ShadowPassList = new List<ScriptableRenderPass>();
List<ScriptableRenderPass> m_RenderPassList = new List<ScriptableRenderPass>();

forwardLitPass = new ForwardLitPass(this);
postProcessRenderContext = new PostProcessRenderContext();
opaqueFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.opaque,
};
transparentFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.transparent,
};
}
public void Dispose()

for (int i = 0; i < m_RenderPassList.Count; ++i)
m_RenderPassList[i].Execute(ref context, ref cullResults, ref cameraData, ref lightData);
#if UNITY_EDITOR
#if UNITY_EDITOR
#endif
#endif
DisposePasses(ref context);
}

15
ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/DepthOnlyPass.cs


const string kCommandBufferTag = "Depth Prepass";
int kDepthBufferBits = 32;
FilterRenderersSettings m_FilterSettings;
m_FilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.opaque
};
}
public override void Setup(CommandBuffer cmd, RenderTextureDescriptor baseDescriptor, int samples)

context.ExecuteCommandBuffer(cmd);
cmd.Clear();
var opaqueDrawSettings = new DrawRendererSettings(cameraData.camera, m_ShaderPassNames[0]);
opaqueDrawSettings.sorting.flags = SortFlags.CommonOpaque;
opaqueDrawSettings.rendererConfiguration = RendererConfiguration.None;
var drawSettings = CreateDrawRendererSettings(cameraData.camera, SortFlags.CommonOpaque, RendererConfiguration.None);
context.DrawRenderers(cullResults.visibleRenderers, ref opaqueDrawSettings, m_FilterSettings);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.opaqueFilterSettings);
context.DrawRenderers(cullResults.visibleRenderers, ref opaqueDrawSettings, m_FilterSettings);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.opaqueFilterSettings);
}
//cmd.SetGlobalTexture(depthTextureID, depthTexture);
context.ExecuteCommandBuffer(cmd);

36
ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ForwardLitPass.cs


}
}
void RenderOpaques(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, RendererConfiguration settings)
void RenderOpaques(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, RendererConfiguration rendererConfiguration)
{
CommandBuffer cmd = CommandBufferPool.Get("Render Opaques");
Camera camera = cameraData.camera;

if (colorHandles[0] == -1 && cameraData.isDefaultViewport)
cmd.SetViewport(camera.pixelRect);
var opaqueDrawSettings = new DrawRendererSettings(camera, m_ShaderPassNames[0]);
for (int i = 1; i < m_ShaderPassNames.Count; ++i)
opaqueDrawSettings.SetShaderPassName(1, m_ShaderPassNames[1]);
opaqueDrawSettings.sorting.flags = SortFlags.CommonOpaque;
opaqueDrawSettings.rendererConfiguration = settings;
var opaqueFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.opaque
};
context.DrawRenderers(cullResults.visibleRenderers, ref opaqueDrawSettings, opaqueFilterSettings);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonOpaque, rendererConfiguration);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.opaqueFilterSettings);
RenderObjectsWithError(ref context, ref cullResults, camera, opaqueFilterSettings, SortFlags.None);
RenderObjectsWithError(ref context, ref cullResults, camera, renderer.opaqueFilterSettings, SortFlags.None);
void RenderTransparents(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, RendererConfiguration config)
void RenderTransparents(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, RendererConfiguration rendererConfiguration)
{
CommandBuffer cmd = CommandBufferPool.Get("Render Opaques");
Camera camera = cameraData.camera;

var transparentSettings = new DrawRendererSettings(camera, m_ShaderPassNames[0]);
for (int i = 1; i < m_ShaderPassNames.Count; ++i)
transparentSettings.SetShaderPassName(1, m_ShaderPassNames[1]);
transparentSettings.sorting.flags = SortFlags.CommonTransparent;
transparentSettings.rendererConfiguration = config;
var transparentFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.transparent
};
context.DrawRenderers(cullResults.visibleRenderers, ref transparentSettings, transparentFilterSettings);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonTransparent, rendererConfiguration);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.transparentFilterSettings);
RenderObjectsWithError(ref context, ref cullResults, camera, transparentFilterSettings, SortFlags.None);
RenderObjectsWithError(ref context, ref cullResults, camera, renderer.transparentFilterSettings, SortFlags.None);
}
void FinalBlitPass(ref ScriptableRenderContext context, ref CameraData cameraData)

10
ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ScriptableRenderPass.cs


{
m_ShaderPassNames.Add(new ShaderPassName(passName));
}
public DrawRendererSettings CreateDrawRendererSettings(Camera camera, SortFlags sortFlags, RendererConfiguration rendererConfiguration)
{
DrawRendererSettings settings = new DrawRendererSettings(camera, m_ShaderPassNames[0]);
for (int i = 1; i < m_ShaderPassNames.Count; ++i)
settings.SetShaderPassName(i, m_ShaderPassNames[i]);
settings.sorting.flags = sortFlags;
settings.rendererConfiguration = rendererConfiguration;
return settings;
}
}
}
正在加载...
取消
保存