Shader compiler throws error when referencing file via #include

Hey, I’d like to use an external library in a shader without having to change it to be stride/sdsl specific. Therefore I tried #include but unfortunately the compiler can’t find the file and throws an error.


E0009: Unexpected exception: CppNet.LexerException: Error at 1:0: File not found: Vibrance.hlsl in .(CppNet.J
avaFile) shaders
   at Stride.Core.Shaders.PreProcessor.ErrorListener.handleError(Source source, Int32 line, Int32 column, Stri
ng msg)
   at CppNet.Preprocessor.error(Int32 line, Int32 column, String msg)
   at CppNet.Preprocessor.include(String parent, Int32 line, String name, Boolean quoted, Boolean isImport, Bo
olean checkOnly)
   at CppNet.Preprocessor.include(Boolean next, Boolean isImport)
   at CppNet.Preprocessor._token()
   at CppNet.Preprocessor.token()
   at Stride.Core.Shaders.PreProcessor.Run(String shaderSource, String sourceFileName, ShaderMacro[] defines, 
String[] includeDirectories)
   at Stride.Shaders.Parser.Mixins.ShaderLoader.LoadShaderClass(ShaderClassCode classSource, String generics, 
LoggerResult log, ShaderMacro[] macros)

ShaderInclude.7z (2.6 KB)

1 Like

From the gray book:

According to git history this was added by @joreg .
Did you test this at that time?

That was probably based on my words. I never tested it though, I guess it needs some paths to be added to the compiler statement. But it would need a deep dive into the stride source code to know for sure.

Fixed in upcoming builds. The relevant commit can be found here.


Great! The file extensions could also include .fx .fxh .hlsli and maybe also lesser used ones like .vs .ps .gs .cs.

1 Like

You mean the ones which get copied to the output folder on export? In any case feel free to create a PR for it.