浏览代码

Merge pull request #1252 from Unity-Technologies/lw/shader-keywords-stripping-v2

Stripped invalid variants.
/main
GitHub 7 年前
当前提交
0c7c73e4
共有 2 个文件被更改,包括 26 次插入0 次删除
  1. 23
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderPreprocessor.cs
  2. 3
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineCore.cs

23
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderPreprocessor.cs


return false;
}
bool StripInvalidVariants(ShaderCompilerData compilerData)
{
bool isShadowVariant = compilerData.shaderKeywordSet.IsEnabled(LightweightKeywords.DirectionalShadows) ||
compilerData.shaderKeywordSet.IsEnabled(LightweightKeywords.LocalShadows);
if (compilerData.shaderKeywordSet.IsEnabled(LightweightKeywords.SoftShadows) && !isShadowVariant)
return true;
if (compilerData.shaderKeywordSet.IsEnabled(LightweightKeywords.VertexLights) &&
!compilerData.shaderKeywordSet.IsEnabled(LightweightKeywords.AdditionalLights))
return true;
// Note: LWRP doesn't support Dynamic Lightmap.
if (compilerData.shaderKeywordSet.IsEnabled(LightweightKeywords.DirectionalLightmap) &&
!compilerData.shaderKeywordSet.IsEnabled(LightweightKeywords.Lightmap))
return true;
return false;
}
bool StripUnused(PipelineCapabilities capabilities, Shader shader, ShaderSnippetData snippetData, ShaderCompilerData compilerData)
{
if (StripUnusedShader(capabilities, shader))

return true;
if (StripUnusedVariant(capabilities, compilerData))
return true;
if (StripInvalidVariants(compilerData))
return true;
return false;

3
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineCore.cs


public static readonly ShaderKeyword DirectionalShadows = new ShaderKeyword(DirectionalShadowsText);
public static readonly ShaderKeyword LocalShadows = new ShaderKeyword(LocalShadowsText);
public static readonly ShaderKeyword SoftShadows = new ShaderKeyword(SoftShadowsText);
public static readonly ShaderKeyword Lightmap = new ShaderKeyword("LIGHTMAP_ON");
public static readonly ShaderKeyword DirectionalLightmap = new ShaderKeyword("DIRLIGHTMAP_COMBINED");
}
public partial class LightweightPipeline

正在加载...
取消
保存