浏览代码

Added shader stripping settings for the pipeline.

/main
Felipe Lira 7 年前
当前提交
d426889d
共有 4 个文件被更改,包括 125 次插入12 次删除
  1. 36
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
  2. 50
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightAssetEditor.cs
  3. 43
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineCore.cs
  4. 8
      Tests/GraphicsTests/RenderPipeline/LightweightPipeline/LightweightPipelineAsset.asset

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


[SerializeField] private bool m_LocalShadowsSupported = true;
[SerializeField] private ShadowResolution m_LocalShadowsAtlasResolution = ShadowResolution._512;
[SerializeField] private bool m_SoftShadowsSupported = false;
[SerializeField] private bool m_CustomShaderVariantStrippingSettings = false;
[SerializeField] private bool m_KeepAdditionalLightVariants = true;
[SerializeField] private bool m_KeepVertexLightVariants = true;
[SerializeField] private bool m_KeepDirectionalShadowVariants = true;
[SerializeField] private bool m_KeepLocalShadowVariants = true;
[SerializeField] private bool m_KeepSoftShadowVariants = true;
[SerializeField]
private LightweightPipelineResources m_ResourcesAsset;

public bool SupportsSoftShadows
{
get { return m_SoftShadowsSupported; }
}
public bool CustomShaderVariantStripping
{
get { return m_CustomShaderVariantStrippingSettings; }
}
public bool KeepAdditionalLightVariants
{
get { return m_KeepAdditionalLightVariants; }
}
public bool KeepVertexLightVariants
{
get { return m_KeepVertexLightVariants; }
}
public bool KeepDirectionalShadowVariants
{
get { return m_KeepDirectionalShadowVariants; }
}
public bool KeepLocalShadowVariants
{
get { return m_KeepLocalShadowVariants; }
}
public bool KeepSoftShadowVariants
{
get { return m_KeepSoftShadowVariants; }
}
public override Material GetDefaultMaterial()

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


public static string[] opaqueDownsamplingOptions = {"None", "2x (Bilinear)", "4x (Box)", "4x (Bilinear)"};
}
public static class StrippingStyles
{
public static GUIContent strippingLabel = new GUIContent("Shader Stripping");
public static GUIContent pipelineCapabilitiesLabel = new GUIContent("Pipeline Capabilities", "Select pipeline capabilities variants to be kept in the build.");
public static string[] strippingOptions = {"Automatic", "Custom"};
public static GUIContent localLightsLabel = new GUIContent("Additional Lights", "If enabled additional lights variants won't be stripped from build.");
public static GUIContent vertexLightsLabel = new GUIContent("Vertex Lights", "If enabled vertex lights variants wont' be stripped from build.");
public static GUIContent directionalShadowsLabel = new GUIContent("Directional Shadows", "If enabled directional shadows variants won't be stripped from build.");
public static GUIContent localShadowsLabel = new GUIContent("Local Shadows", "If enabled local shadows variants won't be stripped from build.");
public static GUIContent softShadowsLabel = new GUIContent("Soft Shadows", "If enabled soft shadows variants won't be stripped from build.");
}
AnimBool m_ShowSoftParticles = new AnimBool();
AnimBool m_ShowOpaqueTextureScale = new AnimBool();

private SerializedProperty m_LocalShadowSupportedProp;
private SerializedProperty m_LocalShadowsAtlasResolutionProp;
private SerializedProperty m_CustomShaderVariantStripSettingsProp;
private SerializedProperty m_KeepAdditionalLightsProp;
private SerializedProperty m_KeepVertexLightsProp;
private SerializedProperty m_KeepDirectionalShadowsProp;
private SerializedProperty m_KeepLocalShadowsProp;
private SerializedProperty m_KeepSoftShadowsProp;
void OnEnable()
{
m_RenderScale = serializedObject.FindProperty("m_RenderScale");

m_LocalShadowsAtlasResolutionProp = serializedObject.FindProperty("m_LocalShadowsAtlasResolution");
m_SoftShadowsSupportedProp = serializedObject.FindProperty("m_SoftShadowsSupported");
m_CustomShaderVariantStripSettingsProp = serializedObject.FindProperty("m_CustomShaderVariantStrippingSettings");
m_KeepAdditionalLightsProp = serializedObject.FindProperty("m_KeepAdditionalLightVariants");
m_KeepVertexLightsProp = serializedObject.FindProperty("m_KeepVertexLightVariants");
m_KeepDirectionalShadowsProp = serializedObject.FindProperty("m_KeepDirectionalShadowVariants");
m_KeepLocalShadowsProp = serializedObject.FindProperty("m_KeepLocalShadowVariants");
m_KeepSoftShadowsProp = serializedObject.FindProperty("m_KeepSoftShadowVariants");
m_ShowSoftParticles.valueChanged.AddListener(Repaint);
m_ShowSoftParticles.value = m_RequireSoftParticlesProp.boolValue;
m_ShowOpaqueTextureScale.valueChanged.AddListener(Repaint);

EditorGUILayout.PropertyField(m_SoftShadowsSupportedProp, Styles.supportsSoftShadows);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.Space();
}
void DrawStrippingSettings()
{
EditorGUILayout.LabelField(StrippingStyles.strippingLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
CoreEditorUtils.DrawPopup(StrippingStyles.pipelineCapabilitiesLabel, m_CustomShaderVariantStripSettingsProp, StrippingStyles.strippingOptions);
if (m_CustomShaderVariantStripSettingsProp.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_KeepAdditionalLightsProp, StrippingStyles.localLightsLabel);
EditorGUILayout.PropertyField(m_KeepVertexLightsProp, StrippingStyles.vertexLightsLabel);
EditorGUILayout.PropertyField(m_KeepDirectionalShadowsProp, StrippingStyles.directionalShadowsLabel);
EditorGUILayout.PropertyField(m_KeepLocalShadowsProp, StrippingStyles.localShadowsLabel);
EditorGUILayout.PropertyField(m_KeepSoftShadowsProp, StrippingStyles.softShadowsLabel);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.Space();
}
public override void OnInspectorGUI()

UpdateAnimationValues();
DrawRenderingSettings();
DrawShadowSettings();
DrawStrippingSettings();
serializedObject.ApplyModifiedProperties();
}

43
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineCore.cs


{
s_PipelineCapabilities = 0U;
if (pipelineAsset.MaxPixelLights > 1 || pipelineAsset.SupportsVertexLight)
s_PipelineCapabilities |= PipelineCapabilities.AdditionalLights;
// Strip variants based on selected pipeline features
if (!pipelineAsset.CustomShaderVariantStripping)
{
if (pipelineAsset.MaxPixelLights > 1 || pipelineAsset.SupportsVertexLight)
s_PipelineCapabilities |= PipelineCapabilities.AdditionalLights;
if (pipelineAsset.SupportsVertexLight)
s_PipelineCapabilities |= PipelineCapabilities.VertexLights;
if (pipelineAsset.SupportsDirectionalShadows)
s_PipelineCapabilities |= PipelineCapabilities.DirectionalShadows;
if (pipelineAsset.SupportsLocalShadows)
s_PipelineCapabilities |= PipelineCapabilities.LocalShadows;
bool anyShadows = pipelineAsset.SupportsDirectionalShadows || pipelineAsset.SupportsLocalShadows;
if (pipelineAsset.SupportsSoftShadows && anyShadows)
s_PipelineCapabilities |= PipelineCapabilities.SoftShadows;
}
else
{
if (pipelineAsset.KeepAdditionalLightVariants)
s_PipelineCapabilities |= PipelineCapabilities.AdditionalLights;
if (pipelineAsset.SupportsVertexLight)
s_PipelineCapabilities |= PipelineCapabilities.VertexLights;
if (pipelineAsset.KeepVertexLightVariants)
s_PipelineCapabilities |= PipelineCapabilities.VertexLights;
if (pipelineAsset.SupportsDirectionalShadows)
s_PipelineCapabilities |= PipelineCapabilities.DirectionalShadows;
if (pipelineAsset.KeepDirectionalShadowVariants)
s_PipelineCapabilities |= PipelineCapabilities.DirectionalShadows;
if (pipelineAsset.SupportsLocalShadows)
s_PipelineCapabilities |= PipelineCapabilities.LocalShadows;
if (pipelineAsset.KeepLocalShadowVariants)
s_PipelineCapabilities |= PipelineCapabilities.LocalShadows;
bool anyShadows = pipelineAsset.SupportsDirectionalShadows || pipelineAsset.SupportsLocalShadows;
if (pipelineAsset.SupportsSoftShadows && anyShadows)
s_PipelineCapabilities |= PipelineCapabilities.SoftShadows;
if (pipelineAsset.KeepSoftShadowVariants)
s_PipelineCapabilities |= PipelineCapabilities.SoftShadows;
}
}
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material,

8
Tests/GraphicsTests/RenderPipeline/LightweightPipeline/LightweightPipelineAsset.asset


m_Cascade2Split: 0.25
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_LocalShadowsSupported: 1
m_LocalShadowsAtlasResolution: 256
m_LocalShadowsAtlasResolution: 512
m_CustomShaderVariantStrippingSettings: 0
m_KeepAdditionalLightVariants: 1
m_KeepVertexLightVariants: 1
m_KeepDirectionalShadowVariants: 1
m_KeepLocalShadowVariants: 1
m_KeepSoftShadowVariants: 1
m_ResourcesAsset: {fileID: 11400000, guid: aac5a08c32552a14c89394b703f1978a, type: 2}
m_ShadowType: 0
正在加载...
取消
保存