浏览代码

Added support to DynamicBatching. It's enabled by default and can be changed in the pipeline asset. Created RenderingData to hold all other data containers.

/main
Felipe Lira 7 年前
当前提交
a55f3bfe
共有 11 个文件被更改,包括 141 次插入114 次删除
  1. 3
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
  2. 5
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightAssetEditor.cs
  3. 35
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightForwardRenderer.cs
  4. 64
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  5. 9
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineCore.cs
  6. 11
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/DepthOnlyPass.cs
  7. 24
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/DirectionalShadowsPass.cs
  8. 61
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ForwardLitPass.cs
  9. 21
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/LocalShadowsPass.cs
  10. 15
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ScreenSpaceShadowResolvePass.cs
  11. 7
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ScriptableRenderPass.cs

3
ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs


[SerializeField] private bool m_SupportsHDR = false;
[SerializeField] private MSAAQuality m_MSAA = MSAAQuality._4x;
[SerializeField] private float m_RenderScale = 1.0f;
[SerializeField] private bool m_SupportsDynamicBatching = true;
[SerializeField] private bool m_DirectionalShadowsSupported = true;
[SerializeField] private ShadowResolution m_ShadowAtlasResolution = ShadowResolution._2048;

get { return m_RenderScale; }
set { m_RenderScale = value; }
}
public bool SupportsDynamicBatching { get { return m_SupportsDynamicBatching; } }
public bool SupportsDirectionalShadows
{

5
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightAssetEditor.cs


public static GUIContent opaqueDownsampling = new GUIContent("Opaque Downsampling", "The downsampling method that is used for the opaque texture");
public static GUIContent hdrContent = new GUIContent("HDR", "Controls the global HDR settings.");
public static GUIContent msaaContent = new GUIContent("Anti Aliasing (MSAA)", "Controls the global anti aliasing settings.");
public static GUIContent dynamicBatching = new GUIContent("Dynamic Batching", "If enabled the pipeline will batch drawcalls with few triangles together by copying their vertex buffers into a shared buffer on a per-frame basis.");
public static GUIContent supportsSoftShadows = new GUIContent("Soft Shadows", "If enabled pipeline will perform shadow filtering. Otherwise all lights that cast shadows will fallback to perform a single shadow sample.");
public static GUIContent supportsDirectionalShadows = new GUIContent("Directional Shadows", "If enabled shadows will be supported for directional lights.");

private SerializedProperty m_OpaqueDownsamplingProp;
private SerializedProperty m_HDR;
private SerializedProperty m_MSAA;
private SerializedProperty m_SupportsDynamicBatching;
private SerializedProperty m_SoftShadowsSupportedProp;
private SerializedProperty m_DirectionalShadowsSupportedProp;

m_OpaqueDownsamplingProp = serializedObject.FindProperty("m_OpaqueDownsampling");
m_HDR = serializedObject.FindProperty("m_SupportsHDR");
m_MSAA = serializedObject.FindProperty("m_MSAA");
m_SupportsDynamicBatching = serializedObject.FindProperty("m_SupportsDynamicBatching");
m_DirectionalShadowsSupportedProp = serializedObject.FindProperty("m_DirectionalShadowsSupported");
m_ShadowDistanceProp = serializedObject.FindProperty("m_ShadowDistance");

DrawAnimatedPopup(m_OpaqueDownsamplingProp, Styles.opaqueDownsampling, Styles.opaqueDownsamplingOptions, m_ShowOpaqueTextureScale);
EditorGUILayout.PropertyField(m_HDR, Styles.hdrContent);
EditorGUILayout.PropertyField(m_MSAA, Styles.msaaContent);
EditorGUILayout.PropertyField(m_SupportsDynamicBatching, Styles.dynamicBatching);
EditorGUI.indentLevel--;
EditorGUILayout.Space();

35
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightForwardRenderer.cs


return desc;
}
public void Setup(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, ref LightData lightData)
public void Setup(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
SetupPerObjectLightIndices(ref cullResults, ref lightData);
RenderTextureDescriptor baseDescriptor = CreateRTDesc(ref cameraData);
bool requiresCameraDepth = cameraData.requiresDepthTexture;
SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = CreateRTDesc(ref renderingData.cameraData);
ShadowData shadowData = lightData.shadowData;
bool requiresDepthPrepass = shadowData.requiresScreenSpaceShadowResolve || cameraData.isSceneViewCamera || (requiresCameraDepth && !CanCopyDepth(ref cameraData));
bool requiresCameraDepth = renderingData.cameraData.requiresDepthTexture;
bool requiresDepthPrepass = renderingData.shadowData.requiresScreenSpaceShadowResolve ||
renderingData.cameraData.isSceneViewCamera || (requiresCameraDepth && !CanCopyDepth(ref renderingData.cameraData));
if (shadowData.renderDirectionalShadows)
if (renderingData.shadowData.renderDirectionalShadows)
if (shadowData.requiresScreenSpaceShadowResolve)
if (renderingData.shadowData.requiresScreenSpaceShadowResolve)
if (shadowData.renderLocalShadows)
if (renderingData.shadowData.renderLocalShadows)
bool requiresColorAttachment = RequiresColorAttachment(ref cameraData, baseDescriptor) || requiresDepthAttachment;
bool requiresColorAttachment = RequiresColorAttachment(ref renderingData.cameraData, baseDescriptor) || requiresDepthAttachment;
EnqueuePass(cmd, RenderPassHandles.ForwardLit, baseDescriptor, colorHandles, depthHandle, cameraData.msaaSamples);
EnqueuePass(cmd, RenderPassHandles.ForwardLit, baseDescriptor, colorHandles, depthHandle, renderingData.cameraData.msaaSamples);
public void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData,
ref LightData lightData)
public void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
m_ActiveShadowQueue[i].Execute(ref context, ref cullResults, ref cameraData, ref lightData);
m_ActiveShadowQueue[i].Execute(ref context, ref cullResults, ref renderingData);
// SetupCameraProperties does the following:
// Setup Camera RenderTarget and Viewport

// Setup camera world clip planes props
// setup HDR keyword
// Setup global time properties (_Time, _SinTime, _CosTime)
context.SetupCameraProperties(cameraData.camera, cameraData.isStereoEnabled);
context.SetupCameraProperties(renderingData.cameraData.camera, renderingData.cameraData.isStereoEnabled);
m_ActiveRenderPassQueue[i].Execute(ref context, ref cullResults, ref cameraData, ref lightData);
m_ActiveRenderPassQueue[i].Execute(ref context, ref cullResults, ref renderingData);
if (cameraData.isSceneViewCamera)
if (renderingData.cameraData.isSceneViewCamera)
{
// Restore Render target for additional editor rendering.
// Note: Scene view camera always perform depth prepass

64
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


CullResults.Cull(ref cullingParameters, context, ref m_CullResults);
List<VisibleLight> visibleLights = m_CullResults.visibleLights;
LightData lightData;
InitializeLightData(ref cameraData, visibleLights, m_Renderer.maxSupportedLocalLightsPerPass, m_Renderer.maxSupportedVertexLights, out lightData);
m_Renderer.Setup(ref context, ref m_CullResults, ref cameraData, ref lightData);
m_Renderer.Execute(ref context, ref m_CullResults, ref cameraData, ref lightData);
RenderingData renderingData;
InitializeRenderingData(ref cameraData, visibleLights, m_Renderer.maxSupportedLocalLightsPerPass, m_Renderer.maxSupportedVertexLights, out renderingData);
m_Renderer.Setup(ref context, ref m_CullResults, ref renderingData);
m_Renderer.Execute(ref context, ref m_CullResults, ref renderingData);
context.Submit();
}
}

cameraData.maxShadowDistance = (anyShadowsEnabled) ? pipelineAsset.ShadowDistance : 0.0f;
}
void InitializeRenderingData(ref CameraData cameraData, List<VisibleLight> visibleLights, int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights, out RenderingData renderingData)
{
m_LocalLightIndices.Clear();
bool hasDirectionalShadowCastingLight = false;
bool hasLocalShadowCastingLight = false;
if (cameraData.maxShadowDistance > 0.0f)
{
for (int i = 0; i < visibleLights.Count; ++i)
{
bool castShadows = visibleLights[i].light.shadows != LightShadows.None;
if (visibleLights[i].lightType == LightType.Directional)
{
hasDirectionalShadowCastingLight |= castShadows;
}
else
{
hasLocalShadowCastingLight |= castShadows;
m_LocalLightIndices.Add(i);
}
}
}
renderingData.cameraData = cameraData;
InitializeLightData(visibleLights, maxSupportedLocalLightsPerPass, maxSupportedVertexLights, out renderingData.lightData);
InitializeShadowData(hasDirectionalShadowCastingLight, hasLocalShadowCastingLight, out renderingData.shadowData);
renderingData.supportsDynamicBatching = pipelineAsset.SupportsDynamicBatching;
}
void InitializeShadowData(bool hasDirectionalShadowCastingLight, bool hasLocalShadowCastingLight, out ShadowData shadowData)
{
// Until we can have keyword stripping forcing single cascade hard shadows on gles2

shadowData.renderedLocalShadowQuality = LightShadows.None;
}
void InitializeLightData(ref CameraData cameraData, List<VisibleLight> visibleLights, int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights, out LightData lightData)
void InitializeLightData(List<VisibleLight> visibleLights, int maxSupportedLocalLightsPerPass, int maxSupportedVertexLights, out LightData lightData)
m_LocalLightIndices.Clear();
bool hasDirectionalShadowCastingLight = false;
bool hasLocalShadowCastingLight = false;
if (cameraData.maxShadowDistance > 0.0f)
{
for (int i = 0; i < visibleLights.Count; ++i)
{
bool castShadows = visibleLights[i].light.shadows != LightShadows.None;
if (visibleLights[i].lightType == LightType.Directional)
{
hasDirectionalShadowCastingLight |= castShadows;
}
else
{
hasLocalShadowCastingLight |= castShadows;
m_LocalLightIndices.Add(i);
}
}
}
int visibleLightsCount = Math.Min(visibleLights.Count, pipelineAsset.MaxPixelLights);
lightData.mainLightIndex = GetMainLight(visibleLights);

lightData.totalAdditionalLightsCount = additionalPixelLightsCount + vertexLightCount;
lightData.visibleLights = visibleLights;
lightData.visibleLocalLightIndices = m_LocalLightIndices;
InitializeShadowData(hasDirectionalShadowCastingLight, hasLocalShadowCastingLight, out lightData.shadowData);
}
// Main Light is always a directional light

9
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineCore.cs


Subtractive,
};
public struct RenderingData
{
public CameraData cameraData;
public LightData lightData;
public ShadowData shadowData;
public bool supportsDynamicBatching;
}
public struct LightData
{
public int pixelAdditionalLightsCount;

public List<int> visibleLocalLightIndices;
public ShadowData shadowData;
}
public struct CameraData

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


cmd.GetTemporaryRT(depthAttachmentHandle, baseDescriptor, FilterMode.Point);
}
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, ref LightData lightData)
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
{
CommandBuffer cmd = CommandBufferPool.Get(kCommandBufferTag);
using (new ProfilingSample(cmd, kProfilerTag))

context.ExecuteCommandBuffer(cmd);
cmd.Clear();
var drawSettings = CreateDrawRendererSettings(cameraData.camera, SortFlags.CommonOpaque, RendererConfiguration.None);
if (cameraData.isStereoEnabled)
var drawSettings = CreateDrawRendererSettings(renderingData.cameraData.camera, SortFlags.CommonOpaque, RendererConfiguration.None, renderingData.supportsDynamicBatching);
if (renderingData.cameraData.isStereoEnabled)
context.StartMultiEye(cameraData.camera);
Camera camera = renderingData.cameraData.camera;
context.StartMultiEye(camera);
context.StopMultiEye(cameraData.camera);
context.StopMultiEye(camera);
}
else
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.opaqueFilterSettings);

24
ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/DirectionalShadowsPass.cs


: RenderTextureFormat.Depth;
}
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, ref LightData lightData)
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
Clear();
ShadowData shadowData = lightData.shadowData;
if (shadowData.renderDirectionalShadows)
lightData.shadowData.renderedDirectionalShadowQuality = RenderDirectionalCascadeShadowmap(ref context, ref cullResults, ref lightData, ref shadowData);
if (renderingData.shadowData.renderDirectionalShadows)
{
Clear();
RenderDirectionalCascadeShadowmap(ref context, ref cullResults, ref renderingData.lightData, ref renderingData.shadowData);
}
}
public override void Dispose(CommandBuffer cmd)

m_CascadeSlices[i].Clear();
}
LightShadows RenderDirectionalCascadeShadowmap(ref ScriptableRenderContext context, ref CullResults cullResults, ref LightData lightData, ref ShadowData shadowData)
void RenderDirectionalCascadeShadowmap(ref ScriptableRenderContext context, ref CullResults cullResults, ref LightData lightData, ref ShadowData shadowData)
return shadowQuality;
return;
VisibleLight shadowLight = lightData.visibleLights[shadowLightIndex];
Light light = shadowLight.light;

return shadowQuality;
return;
return shadowQuality;
return;
CommandBuffer cmd = CommandBufferPool.Get("Prepare Directional Shadowmap");
m_ShadowCasterCascadesCount = shadowData.directionalLightCascadeCount;

context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
return shadowQuality;
// TODO: We should have RenderingData as a readonly but currently we need this to pass shadow rendering to litpass
shadowData.renderedDirectionalShadowQuality = shadowQuality;
}
void SetupDirectionalShadowReceiverConstants(ref ScriptableRenderContext context, CommandBuffer cmd, ref ShadowData shadowData, VisibleLight shadowLight)

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


}
}
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, ref LightData lightData)
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
Camera camera = cameraData.camera;
SetupShaderConstants(ref context, ref cameraData, ref lightData);
RendererConfiguration rendererConfiguration = GetRendererConfiguration(lightData.totalAdditionalLightsCount);
Camera camera = renderingData.cameraData.camera;
bool dynamicBatching = renderingData.supportsDynamicBatching;
SetupShaderConstants(ref context, ref renderingData.cameraData, ref renderingData.lightData, ref renderingData.shadowData);
RendererConfiguration rendererConfiguration = GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
if (cameraData.isStereoEnabled)
if (renderingData.cameraData.isStereoEnabled)
RenderOpaques(ref context, ref cullResults, ref cameraData, rendererConfiguration);
RenderOpaques(ref context, ref cullResults, ref renderingData.cameraData, rendererConfiguration, dynamicBatching);
if (cameraData.postProcessEnabled &&
cameraData.postProcessLayer.HasOpaqueOnlyEffects(renderer.postProcessRenderContext))
OpaquePostProcessSubPass(ref context, ref cameraData);
if (renderingData.cameraData.postProcessEnabled &&
renderingData.cameraData.postProcessLayer.HasOpaqueOnlyEffects(renderer.postProcessRenderContext))
OpaquePostProcessSubPass(ref context, ref renderingData.cameraData);
CopyDepthSubPass(ref context, ref cameraData);
CopyDepthSubPass(ref context, ref renderingData.cameraData);
if (cameraData.requiresOpaqueTexture)
CopyColorSubpass(ref context, ref cameraData);
if (renderingData.cameraData.requiresOpaqueTexture)
CopyColorSubpass(ref context, ref renderingData.cameraData);
RenderTransparents(ref context, ref cullResults, ref cameraData, rendererConfiguration);
RenderTransparents(ref context, ref cullResults, ref renderingData.cameraData, rendererConfiguration, dynamicBatching);
if (cameraData.postProcessEnabled)
PostProcessPass(ref context, ref cameraData);
else if (!cameraData.isOffscreenRender && colorAttachmentHandle != -1)
FinalBlitPass(ref context, ref cameraData);
if (renderingData.cameraData.postProcessEnabled)
PostProcessPass(ref context, ref renderingData.cameraData);
else if (!renderingData.cameraData.isOffscreenRender && colorAttachmentHandle != -1)
FinalBlitPass(ref context, ref renderingData.cameraData);
if (cameraData.isStereoEnabled)
if (renderingData.cameraData.isStereoEnabled)
context.StopMultiEye(cameraData.camera);
context.StereoEndRender(cameraData.camera);
context.StopMultiEye(camera);
context.StereoEndRender(camera);
}
}

return configuration;
}
void SetupShaderConstants(ref ScriptableRenderContext context, ref CameraData cameraData, ref LightData lightData)
void SetupShaderConstants(ref ScriptableRenderContext context, ref CameraData cameraData, ref LightData lightData, ref ShadowData shadowData)
SetShaderKeywords(cmd, ref cameraData, ref lightData);
SetShaderKeywords(cmd, ref cameraData, ref lightData, ref shadowData);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}

return clearFlag;
}
void SetShaderKeywords(CommandBuffer cmd, ref CameraData cameraData, ref LightData lightData)
void SetShaderKeywords(CommandBuffer cmd, ref CameraData cameraData, ref LightData lightData, ref ShadowData shadowData)
{
int vertexLightsCount = lightData.totalAdditionalLightsCount - lightData.pixelAdditionalLightsCount;

// TODO: We have to discuss cookie approach on LWRP.
// CoreUtils.SetKeyword(cmd, LightweightKeywords.MainLightCookieText, mainLightIndex != -1 && LightweightUtils.IsSupportedCookieType(visibleLights[mainLightIndex].lightType) && visibleLights[mainLightIndex].light.cookie != null);
LightShadows directionalShadowQuality = lightData.shadowData.renderedDirectionalShadowQuality;
LightShadows localShadowQuality = lightData.shadowData.renderedLocalShadowQuality;
LightShadows directionalShadowQuality = shadowData.renderedDirectionalShadowQuality;
LightShadows localShadowQuality = shadowData.renderedLocalShadowQuality;
lightData.shadowData.supportsSoftShadows;
shadowData.supportsSoftShadows;
CoreUtils.SetKeyword(cmd, LightweightKeywords.DirectionalShadowsText, directionalShadowQuality != LightShadows.None);
CoreUtils.SetKeyword(cmd, LightweightKeywords.LocalShadowsText, localShadowQuality != LightShadows.None);

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

if (colorAttachmentHandle == -1 && cameraData.isDefaultViewport)
cmd.SetViewport(camera.pixelRect);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonOpaque, rendererConfiguration);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonOpaque, rendererConfiguration, dynamicBatching);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.opaqueFilterSettings);
// Render objects that did not match any shader pass with error shader

context.DrawSkybox(camera);
}
void RenderTransparents(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, RendererConfiguration rendererConfiguration)
void RenderTransparents(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, RendererConfiguration rendererConfiguration, bool dynamicBatching)
{
CommandBuffer cmd = CommandBufferPool.Get("Render Transparents");
Camera camera = cameraData.camera;

var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonTransparent, rendererConfiguration);
var drawSettings = CreateDrawRendererSettings(camera, SortFlags.CommonTransparent, rendererConfiguration, dynamicBatching);
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.transparentFilterSettings);
// Render objects that did not match any shader pass with error shader

21
ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/LocalShadowsPass.cs


: RenderTextureFormat.Depth;
}
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, ref LightData lightData)
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
Clear();
ShadowData shadowData = lightData.shadowData;
if (shadowData.renderLocalShadows)
lightData.shadowData.renderedLocalShadowQuality = RenderLocalShadowmapAtlas(ref context, ref cullResults, ref lightData, ref shadowData);
if (renderingData.shadowData.renderLocalShadows)
{
Clear();
RenderLocalShadowmapAtlas(ref context, ref cullResults, ref renderingData.lightData, ref renderingData.shadowData);
}
}
public override void Dispose(CommandBuffer cmd)

m_LocalShadowStrength[i] = 0.0f;
}
LightShadows RenderLocalShadowmapAtlas(ref ScriptableRenderContext context, ref CullResults cullResults, ref LightData lightData, ref ShadowData shadowData)
void RenderLocalShadowmapAtlas(ref ScriptableRenderContext context, ref CullResults cullResults, ref LightData lightData, ref ShadowData shadowData)
LightShadows shadowQuality = LightShadows.None;
List<int> localLightIndices = lightData.visibleLocalLightIndices;
List<VisibleLight> visibleLights = lightData.visibleLights;

}
if (shadowCastingLightsCount == 0)
return shadowQuality;
return;
CommandBuffer cmd = CommandBufferPool.Get("Prepare Local Lights Shadowmap");
Matrix4x4 view, proj;

}
SetupLocalLightsShadowReceiverConstants(ref context, cmd, ref shadowData);
shadowQuality = (shadowData.supportsSoftShadows) ? (LightShadows)shadowSampling : LightShadows.Hard;
return shadowQuality;
// TODO: We should have RenderingData as a readonly but currently we need this to pass shadow rendering to litpass
shadowData.renderedLocalShadowQuality = (shadowData.supportsSoftShadows) ? (LightShadows)shadowSampling : LightShadows.Hard; ;
}
void SetupLocalLightsShadowReceiverConstants(ref ScriptableRenderContext context, CommandBuffer cmd, ref ShadowData shadowData)

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


cmd.GetTemporaryRT(colorAttachmentHandle, baseDescriptor, FilterMode.Bilinear);
}
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, ref LightData lightData)
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
if (lightData.shadowData.renderedDirectionalShadowQuality == LightShadows.None)
if (renderingData.shadowData.renderedDirectionalShadowQuality == LightShadows.None)
SetShadowCollectPassKeywords(cmd, lightData.shadowData.directionalLightCascadeCount);
SetShadowCollectPassKeywords(cmd, renderingData.shadowData.directionalLightCascadeCount);
// Note: The source isn't actually 'used', but there's an engine peculiarity (bug) that
// doesn't like null sources when trying to determine a stereo-ized blit. So for proper

ClearFlag.Color | ClearFlag.Depth, Color.white);
cmd.Blit(screenSpaceOcclusionTexture, screenSpaceOcclusionTexture, m_ScreenSpaceShadowsMaterial);
if (cameraData.isStereoEnabled)
{
context.StartMultiEye(cameraData.camera);
if (renderingData.cameraData.isStereoEnabled)
{
Camera camera = renderingData.cameraData.camera;
context.StartMultiEye(camera);
context.StopMultiEye(cameraData.camera);
context.StopMultiEye(camera);
}
else
context.ExecuteCommandBuffer(cmd);

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


cmd.ReleaseTemporaryRT(depthAttachmentHandle);
}
public abstract void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref CameraData cameraData, ref LightData lightData);
public abstract void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData);
public RenderTargetIdentifier GetSurface(int handle)
{

m_ShaderPassNames.Add(new ShaderPassName(passName));
}
public DrawRendererSettings CreateDrawRendererSettings(Camera camera, SortFlags sortFlags, RendererConfiguration rendererConfiguration)
public DrawRendererSettings CreateDrawRendererSettings(Camera camera, SortFlags sortFlags, RendererConfiguration rendererConfiguration, bool supportsDynamicBatching)
{
DrawRendererSettings settings = new DrawRendererSettings(camera, m_ShaderPassNames[0]);
for (int i = 1; i < m_ShaderPassNames.Count; ++i)

settings.flags = DrawRendererFlags.EnableInstancing;
if (supportsDynamicBatching)
settings.flags |= DrawRendererFlags.EnableDynamicBatching;
return settings;
}

正在加载...
取消
保存