using System ;
using UnityEngine ;
using UnityEngine ;
using System.Collections.Generic ;
#if UNITY_EDITOR
using UnityEditor ;
#endif
private readonly LowEndRenderPipeline m_Owner ;
public LowEndRenderPipelineInstance ( LowEndRenderPipeline owner )
{
m_Owner = owner ;
if ( m_Owner ! = null )
m_Owner . Build ( ) ;
}
public override void Dispose ( )
{
base . Dispose ( ) ;
if ( m_Owner ! = null )
m_Owner . Cleanup ( ) ;
}
public override void Render ( ScriptableRenderContext renderContext , Camera [ ] cameras )
{
base . Render ( renderContext , cameras ) ;
if ( m_Owner ! = null )
m_Owner . Render ( renderContext , cameras ) ;
}
}
#endregion
private readonly LowEndRenderPipeline m_Asset ;
public class LowEndRenderPipeline : RenderPipelineAsset
{
#region AssetAndPipelineCreation
#if UNITY_EDITOR
[UnityEditor.MenuItem("Renderloop/Create Low End Pipeline")]
static void CreateLowEndPipeline ( )
{
var instance = ScriptableObject . CreateInstance < LowEndRenderPipeline > ( ) ;
AssetDatabase . CreateAsset ( instance , "Assets/LowEndRenderLoop/LowEndPipeline.asset" ) ;
}
#endif
ShadowRenderPass m_ShadowPass ;
ShadowSettings m_ShadowSettings = ShadowSettings . Default ;
protected override IRenderPipeline InternalCreatePipeline ( )
public LowEndRenderPipelineInstance ( LowEndRenderPipeline asset )
return new LowEndRenderPipelineInstance ( this ) ;
}
#endregion
#region Storage
public bool m_SupportsVertexLight = true ;
m_Asset = asset ;
[SerializeField]
ShadowSettings m_ShadowSettings = ShadowSettings . Default ;
ShadowRenderPass m_ShadowPass ;
#endregion
#region RenderPipelineAssetImplementation
public void Build ( )
{
public void Cleanup ( )
public override void Render ( ScriptableRenderContext context , Camera [ ] cameras )
}
base . Render ( context , cameras ) ;
public void Render ( ScriptableRenderContext context , IEnumerable < Camera > cameras )
{
foreach ( Camera camera in cameras )
{
CullingParameters cullingParameters ;
context . Submit ( ) ;
}
#endregion
#region HelperMethods
m_ShadowSettings . directionalLightCascadeCount = QualitySettings . shadowCascades ; ;
m_ShadowSettings . shadowAtlasWidth = 1 0 2 4 ;
m_ShadowSettings . shadowAtlasHeight = 1 0 2 4 ;
m_ShadowSettings . directionalLightCascadeCount = QualitySettings . shadowCascades ;
m_ShadowSettings . shadowAtlasWidth = m_Asset . ShadowAtlasWidth ;
m_ShadowSettings . shadowAtlasHeight = m_Asset . ShadowAtlasHeight ;
m_ShadowSettings . maxShadowDistance = QualitySettings . shadowDistance ;
m_ShadowSettings . maxShadowLightsSupported = 1 ;
m_ShadowSettings . shadowType = ShadowSettings . ShadowType . LIGHTSPACE ;
}
}
#region HelperMethods
private void SetupLightShaderVariables ( VisibleLight [ ] lights , ScriptableRenderContext context )
{
if ( lights . Length < = 0 )
// TODO: Sort Lighting Importance
int pixelLightCount = Mathf . Min ( lights . Length , QualitySettings . pixelLightCount ) ;
int vertexLightCount = Mathf . Min ( lights . Length - pixelLightCount , kMaxLights ) ;
int vertexLightCount = ( m_Asset . SupportsVertexLight ) ? Mathf . Min ( lights . Length - pixelLightCount , kMaxLights ) : 0 ;
int totalLightCount = pixelLightCount + vertexLightCount ;
for ( int i = 0 ; i < totalLightCount ; + + i )
cmd . Dispose ( ) ;
}
private void RenderShadowPass ( CullResults results , ScriptableRenderContext context , out ShadowOutput shadow )
{
m_ShadowPass . Render ( context , results , out shadow ) ;
}
void SetupShadowShaderVariables ( ShadowOutput shadowOutput , ScriptableRenderContext context , float shadowNear , float shadowFar )
{
// PSSM distance settings
outCoefficients [ 6 ] . z = ambientProbe [ 2 , 8 ] ;
outCoefficients [ 6 ] . w = 1.0f ;
}
#endregion
}
#endregion
public class LowEndRenderPipeline : RenderPipelineAsset
{
#region AssetAndPipelineCreation
#if UNITY_EDITOR
[UnityEditor.MenuItem("Renderloop/Create Low End Pipeline")]
static void CreateLowEndPipeline ( )
{
var instance = ScriptableObject . CreateInstance < LowEndRenderPipeline > ( ) ;
UnityEditor . AssetDatabase . CreateAsset ( instance , "Assets/LowEndRenderLoop/LowEndPipeline.asset" ) ;
}
#endif
protected override IRenderPipeline InternalCreatePipeline ( )
{
return new LowEndRenderPipelineInstance ( this ) ;
}
#endregion
#region PipelineAssetSettings
public bool m_SupportsVertexLight = true ;
public int m_ShadowAtlasWidth = 1 0 2 4 ;
public int m_ShadowAtlasHeight = 1 0 2 4 ;
public bool SupportsVertexLight { get { return m_SupportsVertexLight ; } private set { m_SupportsVertexLight = value ; } }
public int ShadowAtlasWidth { get { return m_ShadowAtlasWidth ; } private set { m_ShadowAtlasWidth = value ; } }
public int ShadowAtlasHeight { get { return m_ShadowAtlasHeight ; } private set { m_ShadowAtlasHeight = value ; } }
#endregion
}