@@ -22,7 +22,7 @@ enum ShaderFeatures
2222 TerrainHoles = ( 1 << 7 )
2323 }
2424
25- internal class ShaderPreprocessor : IPreprocessShaders
25+ public class ShaderPreprocessor : IPreprocessShaders
2626 {
2727 ShaderKeyword m_MainLightShadows = new ShaderKeyword ( ShaderKeywordStrings . MainLightShadows ) ;
2828 ShaderKeyword m_AdditionalLightsVertex = new ShaderKeyword ( ShaderKeywordStrings . AdditionalLightsVertex ) ;
@@ -47,6 +47,19 @@ internal class ShaderPreprocessor : IPreprocessShaders
4747 // The first one executed is the one where callbackOrder is returning the smallest number.
4848 public int callbackOrder { get { return 0 ; } }
4949
50+ /// <summary> A function returning true if the shader should be stripped. </summary>
51+ public static Func < Shader , ShaderCompilerData , ShaderSnippetData , bool > CustomStrippingFunction ;
52+
53+ bool StripCustom ( Shader shader , ShaderCompilerData compilerData , ShaderSnippetData snippetData )
54+ {
55+ if ( CustomStrippingFunction != null )
56+ {
57+ return CustomStrippingFunction ( shader , compilerData , snippetData ) ;
58+ }
59+
60+ return false ;
61+ }
62+
5063 bool StripUnusedShader ( ShaderFeatures features , Shader shader , ShaderCompilerData compilerData )
5164 {
5265 if ( ! CoreUtils . HasFlag ( features , ShaderFeatures . MainLightShadows ) &&
@@ -186,6 +199,9 @@ bool StripUnused(ShaderFeatures features, Shader shader, ShaderSnippetData snipp
186199 if ( StripDeprecated ( compilerData ) )
187200 return true ;
188201
202+ if ( StripCustom ( shader , compilerData , snippetData ) )
203+ return true ;
204+
189205 return false ;
190206 }
191207
0 commit comments