|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using UnityEngine.Rendering; |
|
|
|
|
|
|
|
namespace UnityEngine.Experimental.Rendering.LowendMobile |
|
|
|
namespace UnityEngine.Experimental.Rendering.LightweightPipeline |
|
|
|
{ |
|
|
|
[Serializable] |
|
|
|
public class ShadowSettings |
|
|
|
|
|
|
public int shadowResolution; |
|
|
|
} |
|
|
|
|
|
|
|
public class LowEndMobilePipeline : RenderPipeline, IComparer<VisibleLight> |
|
|
|
public class LightweightPipeline : RenderPipeline, IComparer<VisibleLight> |
|
|
|
private readonly LowEndMobilePipelineAsset m_Asset; |
|
|
|
private readonly LightweightPipelineAsset m_Asset; |
|
|
|
|
|
|
|
private static readonly int kMaxCascades = 4; |
|
|
|
private static readonly int kMaxLights = 8; |
|
|
|
|
|
|
private int m_DepthBufferBits = 24; |
|
|
|
private Vector4[] m_DirectionalShadowSplitDistances = new Vector4[kMaxCascades]; |
|
|
|
|
|
|
|
private static readonly ShaderPassName m_ForwardBasePassName = new ShaderPassName("LowEndMobileForward"); |
|
|
|
private static readonly ShaderPassName m_ForwardBasePassName = new ShaderPassName("LightweightForward"); |
|
|
|
|
|
|
|
private Vector4[] m_LightPositions = new Vector4[kMaxLights]; |
|
|
|
private Vector4[] m_LightColors = new Vector4[kMaxLights]; |
|
|
|
|
|
|
private ShadowSettings m_ShadowSettings = ShadowSettings.Default; |
|
|
|
private ShadowSliceData[] m_ShadowSlices = new ShadowSliceData[kMaxCascades]; |
|
|
|
|
|
|
|
public LowEndMobilePipeline(LowEndMobilePipelineAsset asset) |
|
|
|
public LightweightPipeline(LightweightPipelineAsset asset) |
|
|
|
{ |
|
|
|
m_Asset = asset; |
|
|
|
|
|
|
|
|
|
|
public override void Render(ScriptableRenderContext context, Camera[] cameras) |
|
|
|
{ |
|
|
|
var prevPipe = Shader.globalRenderPipeline; |
|
|
|
Shader.globalRenderPipeline = "LowEndMobilePipeline"; |
|
|
|
Shader.globalRenderPipeline = "LightweightPipeline"; |
|
|
|
base.Render(context, cameras); |
|
|
|
|
|
|
|
foreach (Camera camera in cameras) |
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Debug.LogWarning("Only spot and directional shadow casters are supported in lowend mobile pipeline"); |
|
|
|
Debug.LogWarning("Only spot and directional shadow casters are supported in lightweight pipeline"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|