浏览代码

Added little helper to the shadow registry to set a global override for the shadow algorithm. This will disable the UI. Shader source still needs to be manually synced with this override.

/main
uygar 8 年前
当前提交
255625f4
共有 3 个文件被更改,包括 67 次插入21 次删除
  1. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  2. 79
      Assets/ScriptableRenderPipeline/common/Shadow/ShadowBase.cs
  3. 4
      Assets/ScriptableRenderPipeline/fptl/FptlLighting.cs

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


scInit.resourceBinder = binder;
m_ShadowMgr = new ShadowExp.ShadowManager(shadowSettings, ref scInit, m_Shadowmaps);
// set global overrides - these need to match the override specified in ShadowDispatch.hlsl
bool useGlobalOverrides = true;
m_ShadowMgr.SetGlobalShadowOverride( GPUShadowType.Point , ShadowAlgorithm.PCF, ShadowVariant.V1, ShadowPrecision.High, useGlobalOverrides );
m_ShadowMgr.SetGlobalShadowOverride( GPUShadowType.Spot , ShadowAlgorithm.PCF, ShadowVariant.V1, ShadowPrecision.High, useGlobalOverrides );
m_ShadowMgr.SetGlobalShadowOverride( GPUShadowType.Directional , ShadowAlgorithm.PCF, ShadowVariant.V1, ShadowPrecision.High, useGlobalOverrides );
shadowManager = m_ShadowMgr;
}

79
Assets/ScriptableRenderPipeline/common/Shadow/ShadowBase.cs


public Dels[] variantDels;
}
struct Override
{
public bool enabled;
public ShadowAlgorithm algorithm;
public ShadowVariant variant;
public ShadowPrecision precision;
}
Override[] m_GlobalOverrides = new Override[(int)GPUShadowType.MAX];
Dictionary<ShadowAlgorithm, Entry>[] m_Entries = new Dictionary<ShadowAlgorithm, Entry>[ShadowConstants.Counts.k_GPUShadowType]
{ new Dictionary<ShadowAlgorithm, Entry>(),
new Dictionary<ShadowAlgorithm, Entry>(),

int shadowAlgorithm;
int shadowVariant;
int shadowPrecision;
ald.GetShadowAlgorithm( out shadowAlgorithm, out shadowVariant, out shadowPrecision );
bool globalOverride = m_GlobalOverrides[(int)shadowType].enabled;
if( globalOverride )
{
shadowAlgorithm = (int) m_GlobalOverrides[(int)shadowType].algorithm;
shadowVariant = (int) m_GlobalOverrides[(int)shadowType].variant;
shadowPrecision = (int) m_GlobalOverrides[(int)shadowType].precision;
}
else
ald.GetShadowAlgorithm( out shadowAlgorithm, out shadowVariant, out shadowPrecision );
DrawWidgets( l, shadowType, (ShadowAlgorithm) shadowAlgorithm, (ShadowVariant) shadowVariant, (ShadowPrecision) shadowPrecision );
DrawWidgets( l, shadowType, (ShadowAlgorithm) shadowAlgorithm, (ShadowVariant) shadowVariant, (ShadowPrecision) shadowPrecision, globalOverride );
void DrawWidgets( Light l, GPUShadowType shadowType, ShadowAlgorithm shadowAlgorithm, ShadowVariant shadowVariant, ShadowPrecision shadowPrecision )
void DrawWidgets( Light l, GPUShadowType shadowType, ShadowAlgorithm shadowAlgorithm, ShadowVariant shadowVariant, ShadowPrecision shadowPrecision, bool globalOverride )
{
var dict = m_Entries[(int)shadowType];
int[] algoOptions = new int[dict.Count];

idx++;
}
UnityEditor.EditorGUI.BeginChangeCheck();
shadowAlgorithm = (ShadowAlgorithm) UnityEditor.EditorGUILayout.IntPopup( new GUIContent( "Shadow Algorithm" ), (int) shadowAlgorithm, algoDescs, algoOptions );
if( UnityEditor.EditorGUI.EndChangeCheck() )
shadowVariant = 0;
using (new UnityEditor.EditorGUI.DisabledGroupScope(globalOverride))
{
UnityEditor.EditorGUI.BeginChangeCheck();
shadowAlgorithm = (ShadowAlgorithm) UnityEditor.EditorGUILayout.IntPopup( new GUIContent( "Shadow Algorithm" ), (int) shadowAlgorithm, algoDescs, algoOptions );
if( UnityEditor.EditorGUI.EndChangeCheck() )
shadowVariant = 0;
}
UnityEditor.EditorGUI.indentLevel++;
Entry e = dict[shadowAlgorithm];

UnityEditor.EditorGUILayout.BeginHorizontal();
shadowVariant = (ShadowVariant) UnityEditor.EditorGUILayout.IntPopup( new GUIContent( "Variant + Precision" ), (int) shadowVariant, varDescs, varOptions );
using( new UnityEditor.EditorGUI.DisabledGroupScope( globalOverride ) )
{
shadowVariant = (ShadowVariant) UnityEditor.EditorGUILayout.IntPopup( new GUIContent( "Variant + Precision" ), (int) shadowVariant, varDescs, varOptions );
if( e.variantDels[(int)shadowVariant].low != null && e.variantDels[(int)shadowVariant].high != null )
{
GUIContent[] precDescs = new GUIContent[] { new GUIContent( "High" ), new GUIContent( "Low" ) };
int[] precOptions = new int[] { 0, 1 };
shadowPrecision = (ShadowPrecision)UnityEditor.EditorGUILayout.IntPopup((int)shadowPrecision, precDescs, precOptions, GUILayout.MaxWidth(65));
}
else
{
using( new UnityEditor.EditorGUI.DisabledScope() )
if( e.variantDels[(int)shadowVariant].low != null && e.variantDels[(int)shadowVariant].high != null )
GUIContent[] precDescs = new GUIContent[] { new GUIContent( e.variantDels[(int)shadowVariant].low == null ? "High" : "Low" ) };
int[] precOptions = new int[] { e.variantDels[(int)shadowVariant].low == null ? 0 : 1 };
UnityEditor.EditorGUILayout.IntPopup(precOptions[0], precDescs, precOptions, GUILayout.MaxWidth(65));
shadowPrecision = (ShadowPrecision) precOptions[0];
GUIContent[] precDescs = new GUIContent[] { new GUIContent( "High" ), new GUIContent( "Low" ) };
int[] precOptions = new int[] { 0, 1 };
shadowPrecision = (ShadowPrecision)UnityEditor.EditorGUILayout.IntPopup((int)shadowPrecision, precDescs, precOptions, GUILayout.MaxWidth(65));
}
else
{
using( new UnityEditor.EditorGUI.DisabledScope() )
{
GUIContent[] precDescs = new GUIContent[] { new GUIContent( e.variantDels[(int)shadowVariant].low == null ? "High" : "Low" ) };
int[] precOptions = new int[] { e.variantDels[(int)shadowVariant].low == null ? 0 : 1 };
UnityEditor.EditorGUILayout.IntPopup(precOptions[0], precDescs, precOptions, GUILayout.MaxWidth(65));
shadowPrecision = (ShadowPrecision) precOptions[0];
}
}
}

ald.SetShadowAlgorithm( (int) shadowAlgorithm, (int) shadowVariant, (int) shadowPrecision, (int) packedAlgo, shadowData );
UnityEditor.EditorGUI.indentLevel--;
}
public void SetGlobalShadowOverride( GPUShadowType shadowType, ShadowAlgorithm shadowAlgorithm, ShadowVariant shadowVariant, ShadowPrecision shadowPrecision, bool enable )
{
m_GlobalOverrides[(int)shadowType].enabled = enable;
m_GlobalOverrides[(int)shadowType].algorithm = shadowAlgorithm;
m_GlobalOverrides[(int)shadowType].variant = shadowVariant;
m_GlobalOverrides[(int)shadowType].precision = shadowPrecision;
}
void SetGlobalOverrideEnabled( GPUShadowType shadowType, bool enabled )
{
m_GlobalOverrides[(int)shadowType].enabled = enabled;
}
}

4
Assets/ScriptableRenderPipeline/fptl/FptlLighting.cs


scInit.resourceBinder = binder;
m_ShadowMgr = new ShadowExp.ShadowManager(shadowSettings, ref scInit, m_Shadowmaps);
// set global overrides - these need to match the override specified in ShadowDispatch.hlsl
m_ShadowMgr.SetGlobalShadowOverride( GPUShadowType.Point , ShadowAlgorithm.PCF, ShadowVariant.V1, ShadowPrecision.High, true );
m_ShadowMgr.SetGlobalShadowOverride( GPUShadowType.Spot , ShadowAlgorithm.PCF, ShadowVariant.V1, ShadowPrecision.High, true );
m_ShadowMgr.SetGlobalShadowOverride( GPUShadowType.Directional , ShadowAlgorithm.PCF, ShadowVariant.V1, ShadowPrecision.High, true );
shadowManager = m_ShadowMgr;
}
public void Dispose()

正在加载...
取消
保存