@@ -13,17 +13,20 @@ namespace UnityShaderParser.ShaderLab
1313 public class ShaderLabParserConfig : HLSLParserConfig
1414 {
1515 public bool ParseEmbeddedHLSL { get ; set ; }
16+ public bool IncludeProgramBlockPreamble { get ; set ; }
1617
1718 public ShaderLabParserConfig ( )
1819 : base ( )
1920 {
2021 ParseEmbeddedHLSL = true ;
22+ IncludeProgramBlockPreamble = true ;
2123 }
2224
2325 public ShaderLabParserConfig ( ShaderLabParserConfig config )
2426 : base ( config )
2527 {
2628 ParseEmbeddedHLSL = config . ParseEmbeddedHLSL ;
29+ IncludeProgramBlockPreamble = config . IncludeProgramBlockPreamble ;
2730 }
2831 }
2932
@@ -229,15 +232,18 @@ protected HLSLProgramBlock ParseOrSkipEmbeddedHLSL()
229232
230233 // Add preamble
231234 string preamble = string . Empty ;
232- if ( isSurfaceShader )
235+ if ( config . IncludeProgramBlockPreamble )
233236 {
234- // Surface shader compiler has some secret INTERNAL_DATA macro and special includes :(
235- preamble = $ "#ifndef INTERNAL_DATA\n #define INTERNAL_DATA\n #endif\n #include \" UnityCG.cginc\" \n ";
236- }
237- else if ( programToken . Kind != TokenKind . HlslProgramBlock ) // HLSLPROGRAM doesn't include anything implicitly.
238- {
239- // UnityShaderVariables.cginc should always be included otherwise
240- preamble = $ "#include \" UnityShaderVariables.cginc\" \n ";
237+ if ( isSurfaceShader )
238+ {
239+ // Surface shader compiler has some secret INTERNAL_DATA macro and special includes :(
240+ preamble = $ "#ifndef INTERNAL_DATA\n #define INTERNAL_DATA\n #endif\n #include \" UnityCG.cginc\" \n ";
241+ }
242+ else if ( programToken . Kind != TokenKind . HlslProgramBlock ) // HLSLPROGRAM doesn't include anything implicitly.
243+ {
244+ // UnityShaderVariables.cginc should always be included otherwise
245+ preamble = $ "#include \" UnityShaderVariables.cginc\" \n ";
246+ }
241247 }
242248 fullCode = $ "{ preamble } { fullCode } ";
243249 if ( ! config . ParseEmbeddedHLSL )
0 commit comments