|
|
|
|
|
|
Subtractive, |
|
|
|
}; |
|
|
|
|
|
|
|
public static class AdvancedFeatureIDs |
|
|
|
{ |
|
|
|
|
|
|
|
//SSAO
|
|
|
|
//############################################
|
|
|
|
public static readonly int _AmbientOcclusionTexture = Shader.PropertyToID("_AmbientOcclusionTexture"); |
|
|
|
public static readonly int _AmbientOcclusionParam = Shader.PropertyToID("_AmbientOcclusionParam"); |
|
|
|
//############################################
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static class CameraRenderTargetID |
|
|
|
{ |
|
|
|
// Camera color target. Not used when camera is rendering to backbuffer or camera
|
|
|
|
|
|
|
private int m_ShadowCasterCascadesCount; |
|
|
|
private int m_ShadowMapRTID; |
|
|
|
private int m_ScreenSpaceShadowMapRTID; |
|
|
|
private int m_DebugViewRTID; |
|
|
|
private RenderTargetIdentifier m_DebugViewRT; |
|
|
|
private RenderTargetIdentifier m_ColorRT; |
|
|
|
private RenderTargetIdentifier m_CopyColorRT; |
|
|
|
private RenderTargetIdentifier m_DepthRT; |
|
|
|
|
|
|
|
|
|
|
m_ShadowMapRTID = Shader.PropertyToID("_ShadowMap"); |
|
|
|
m_ScreenSpaceShadowMapRTID = Shader.PropertyToID("_ScreenSpaceShadowMap"); |
|
|
|
|
|
|
|
m_DebugViewRTID = Shader.PropertyToID("_DebugViewRT"); |
|
|
|
CameraRenderTargetID.color = Shader.PropertyToID("_CameraColorRT"); |
|
|
|
CameraRenderTargetID.copyColor = Shader.PropertyToID("_CameraCopyColorRT"); |
|
|
|
CameraRenderTargetID.depth = Shader.PropertyToID("_CameraDepthTexture"); |
|
|
|
|
|
|
m_ScreenSpaceShadowMapRT = new RenderTargetIdentifier(m_ScreenSpaceShadowMapRTID); |
|
|
|
|
|
|
|
m_DebugViewRT = new RenderTargetIdentifier(m_DebugViewRTID); |
|
|
|
m_ColorRT = new RenderTargetIdentifier(CameraRenderTargetID.color); |
|
|
|
m_CopyColorRT = new RenderTargetIdentifier(CameraRenderTargetID.copyColor); |
|
|
|
m_DepthRT = new RenderTargetIdentifier(CameraRenderTargetID.depth); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//TODO: Editor only?
|
|
|
|
if(m_Asset.DebugView == DebugViewMode.None) |
|
|
|
if(!LightweightUtils.HasFlag(frameRenderingConfiguration, FrameRenderingConfiguration.DebugView)) |
|
|
|
ForwardPass(visibleLights, frameRenderingConfiguration, ref context, ref lightData, stereoEnabled); |
|
|
|
else |
|
|
|
DebugViewPass(frameRenderingConfiguration, ref context, stereoEnabled); |
|
|
|
|
|
|
private void DebugViewPass(FrameRenderingConfiguration frameRenderingConfiguration, ref ScriptableRenderContext context, bool stereoEnabled) |
|
|
|
{ |
|
|
|
//Set up buffers.
|
|
|
|
|
|
|
|
|
|
|
|
//CommandBuffer cmd = CommandBufferPool.Get("Debug View");
|
|
|
|
//cmd.GetTemporaryRT(m_DebugViewRTID, m_CurrCamera.pixelWidth, m_CurrCamera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB32);
|
|
|
|
//SetRenderTarget(cmd, m_DebugViewRT, ClearFlag.Color);
|
|
|
|
//context.ExecuteCommandBuffer(cmd);
|
|
|
|
BeginForwardRendering(ref context, frameRenderingConfiguration); |
|
|
|
|
|
|
|
|
|
|
|
CommandBuffer cmd = CommandBufferPool.Get("Debug View Mode"); |
|
|
|
LightweightShaderUtils.ResetDebugModes(cmd); |
|
|
|
switch(m_Asset.DebugView) |
|
|
|
{ |
|
|
|
case DebugViewMode.Albedo: |
|
|
|
LightweightShaderUtils.SetDebugMode(cmd, DebugViewKeyword.ALBEDO); |
|
|
|
break; |
|
|
|
case DebugViewMode.Metallness: |
|
|
|
LightweightShaderUtils.SetDebugMode(cmd, DebugViewKeyword.METALNESS); |
|
|
|
break; |
|
|
|
case DebugViewMode.Normals: |
|
|
|
LightweightShaderUtils.SetDebugMode(cmd, DebugViewKeyword.NORMALS); |
|
|
|
break; |
|
|
|
case DebugViewMode.Roughness: |
|
|
|
LightweightShaderUtils.SetDebugMode(cmd, DebugViewKeyword.ROUGHNESS); |
|
|
|
break; |
|
|
|
} |
|
|
|
context.ExecuteCommandBuffer(cmd); |
|
|
|
CommandBufferPool.Release(cmd); |
|
|
|
|
|
|
|
//Draw
|
|
|
|
var debugViewDrawSettings = new DrawRendererSettings(m_CurrCamera, m_DebugViewPass); |
|
|
|
debugViewDrawSettings.sorting.flags = SortFlags.CommonOpaque; |
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
context.DrawRenderers(m_CullResults.visibleRenderers, ref debugViewDrawSettings, debugViewFilterSettings); |
|
|
|
|
|
|
|
|
|
|
|
EndForwardRendering(ref context, frameRenderingConfiguration); |
|
|
|
} |
|
|
|
|
|
|
|
private void ForwardPass(List<VisibleLight> visibleLights, FrameRenderingConfiguration frameRenderingConfiguration, ref ScriptableRenderContext context, ref LightData lightData, bool stereoEnabled) |
|
|
|
|
|
|
|
|
|
|
if (intermediateTexture) |
|
|
|
configuration |= FrameRenderingConfiguration.IntermediateTexture; |
|
|
|
|
|
|
|
if(m_Asset.DebugView != DebugViewMode.None) |
|
|
|
configuration |= FrameRenderingConfiguration.DebugView; |
|
|
|
} |
|
|
|
|
|
|
|
private void SetupIntermediateResources(FrameRenderingConfiguration renderingConfig, ref ScriptableRenderContext context) |
|
|
|
|
|
|
blitMaterial = null; |
|
|
|
|
|
|
|
// If PostProcessing is enabled, it is already blit to CameraTarget.
|
|
|
|
if (!LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.PostProcess)) |
|
|
|
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DebugView) || !LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.PostProcess)) |
|
|
|
Blit(cmd, renderingConfig, m_CurrCameraColorRT, BuiltinRenderTextureType.CameraTarget, blitMaterial); |
|
|
|
} |
|
|
|
|
|
|
|