浏览代码

Fixed transparent sorting issues between lit and unlit shaders.

/RenderPassXR_Sandbox
Felipe Lira 7 年前
当前提交
aa904253
共有 1 个文件被更改,包括 41 次插入29 次删除
  1. 70
      ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs

70
ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs


lightData.shadowLightIndex, m_ShadowCasterCascadesCount);
SetShaderKeywords(ref lightData, ref context);
RendererConfiguration configuration = RendererConfiguration.PerObjectReflectionProbes | RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe;
if (!lightData.isSingleLight)
configuration |= RendererConfiguration.PerObjectLightIndices8;
RendererConfiguration rendererSettings = GetRendererSettings(ref lightData);
var litDrawSettings = new DrawRendererSettings(m_CurrCamera, m_LitPassName);
litDrawSettings.sorting.flags = SortFlags.CommonOpaque;
litDrawSettings.rendererConfiguration = configuration;
var unlitDrawSettings = new DrawRendererSettings(m_CurrCamera, m_UnlitPassName);
unlitDrawSettings.sorting.flags = SortFlags.CommonTransparent;
// Render Opaques
var opaqueFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.opaque
};
context.DrawRenderers(m_CullResults.visibleRenderers, ref litDrawSettings, opaqueFilterSettings);
// TODO: Check skybox shader
RenderOpaques(ref context, rendererSettings);
// Render Alpha blended
var transparentFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.transparent
};
litDrawSettings.sorting.flags = SortFlags.CommonTransparent;
context.DrawRenderers(m_CullResults.visibleRenderers, ref litDrawSettings, transparentFilterSettings);
context.DrawRenderers(m_CullResults.visibleRenderers, ref unlitDrawSettings, transparentFilterSettings);
RenderTransparents(ref context, rendererSettings);
if (postProcessEnabled)
RenderPostProcess(ref context, postProcessLayer, false);

context.Submit();
}
}
private void RenderOpaques(ref ScriptableRenderContext context, RendererConfiguration settings)
{
var opaqueDrawSettings = new DrawRendererSettings(m_CurrCamera, m_LitPassName);
opaqueDrawSettings.sorting.flags = SortFlags.CommonOpaque;
opaqueDrawSettings.rendererConfiguration = settings;
var opaqueFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.opaque
};
context.DrawRenderers(m_CullResults.visibleRenderers, ref opaqueDrawSettings, opaqueFilterSettings);
}
private void RenderTransparents(ref ScriptableRenderContext context, RendererConfiguration settings)
{
var transparentSettings = new DrawRendererSettings(m_CurrCamera, m_LitPassName);
transparentSettings.SetShaderPassName(1, m_UnlitPassName);
transparentSettings.sorting.flags = SortFlags.CommonTransparent;
transparentSettings.rendererConfiguration = settings;
var transparentFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.transparent
};
context.DrawRenderers(m_CullResults.visibleRenderers, ref transparentSettings, transparentFilterSettings);
}
private void BuildShadowSettings()

context.StopMultiEye(m_CurrCamera);
context.StereoEndRender(m_CurrCamera);
}
}
RendererConfiguration GetRendererSettings(ref LightData lightData)
{
RendererConfiguration settings = RendererConfiguration.PerObjectReflectionProbes | RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe;
if (!lightData.isSingleLight)
settings |= RendererConfiguration.PerObjectLightIndices8;
return settings;
}
private void SetupRenderTargets(CommandBuffer cmd, RenderTargetIdentifier colorRT, RenderTargetIdentifier depthRT)

正在加载...
取消
保存