浏览代码

Fixed cascade UI

/lw-bias_per_cascade
Felipe Lira 7 年前
当前提交
4c6c80fe
共有 3 个文件被更改,包括 20 次插入9 次删除
  1. 5
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
  2. 21
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightAssetEditor.cs
  3. 3
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs

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


{
private const int PACKAGE_MANAGER_PATH_INDEX = 1;
private const float kDefaultBias = 0.05f;
private Shader m_DefaultShader;
public static readonly string m_SearchPathProject = "Assets";
public static readonly string m_SearchPathPackage = "Packages/com.unity.render-pipelines.lightweight";

[SerializeField] private ShadowCascades m_ShadowCascades = ShadowCascades.FOUR_CASCADES;
[SerializeField] private float m_Cascade2Split = 0.25f;
[SerializeField] private Vector3 m_Cascade4Split = new Vector3(0.067f, 0.2f, 0.467f);
[SerializeField] private Vector3 m_CascadeBiasOffset = new Vector3(kDefaultBias, kDefaultBias, kDefaultBias);
[SerializeField] private Vector4 m_CascadeBiasOffset = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
[SerializeField]
private LightweightPipelineResources m_ResourcesAsset;

private set { m_Cascade4Split = value; }
}
public Vector3 CascadeBiasOffset
public Vector4 CascadeBiasOffset
{
get { return m_CascadeBiasOffset; }
}

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


EditorGUILayout.PropertyField(prop, content);
}
void DrawShadowCascadeBias(int cascadeCount)
void DrawShadowCascadeBiasOffset(int cascadeCount)
if (cascadeCount > 0)
Vector4 cascadeBiasOffset = m_ShadowCascadeBias.vector4Value;
EditorGUI.BeginChangeCheck();
for (int i = 0; i < cascadeCount; ++i)
EditorGUILayout.PropertyField(m_ShadowCascadeBias, Styles.shadowCascadeBias);
EditorGUILayout.BeginHorizontal();
cascadeBiasOffset[i] = Mathf.Max(0.0f, EditorGUILayout.FloatField(string.Format("Cascade {0} Bias Offset: ", i), cascadeBiasOffset[i]));
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
m_ShadowCascadeBias.vector4Value = cascadeBiasOffset;
}
public override void OnInspectorGUI()

CoreEditorUtils.DrawPopup(Styles.shadowCascades, m_ShadowCascadesProp, Styles.shadowCascadeOptions);
ShadowCascades cascades = (ShadowCascades)m_ShadowCascadesProp.intValue;
DrawShadowCascadeBias(m_ShadowCascadesProp.intValue);
{
DrawShadowCascadeBiasOffset(4);
}
{
DrawShadowCascadeBiasOffset(2);
}
EditorGUI.indentLevel--;

3
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


cmd.SetGlobalVector(ShadowConstantBuffer._ShadowOffset3, new Vector4(invHalfShadowResolution, invHalfShadowResolution, 0.0f, 0.0f));
cmd.SetGlobalVector(ShadowConstantBuffer._ShadowmapSize, new Vector4(invShadowResolution, invShadowResolution, m_Asset.ShadowAtlasResolution, m_Asset.ShadowAtlasResolution));
Vector3 cascadeBias = m_Asset.CascadeBiasOffset;
cmd.SetGlobalVector("_ShadowCascadeBiasOffset", new Vector4(cascadeBias.x, cascadeBias.y, cascadeBias.z, 0.05f));
cmd.SetGlobalVector("_ShadowCascadeBiasOffset", m_Asset.CascadeBiasOffset);
}
private void SetShaderKeywords(CommandBuffer cmd, ref LightData lightData, List<VisibleLight> visibleLights)

正在加载...
取消
保存