HLSL #include crashes in several listed scenarios

#include “” crash no relevant log
#include “C:/Test.ush” crash
#include “C:\Test.ush” crash
#include “/Engine/beyond/Test” crash
#include “/Engine/beyond/Test.ush” works!
#include “/Engine/beyond/Test.usf” works
#include “/Engine/beyond/NonExistent.ush” silently ignored
#include “/Game/Public/Test.usf” crashes, see below
#include (empty) the only relevant log error without a crash

from inside Test.ush:
#include "Test2.ush" works
#include "Test2.usf" works
#include "Test2" crash
#include "NonExistent.ush" silently ignored

Creating an empty Shaders directory under the Project, immediately crashes the Editor upon launch. This also happens with a clean copy of PhotorealisticCharacter. It also happens even Shaders has basic Public content with a Test.ush. What is impressive however is, Generate Visual Studio files command, picks up the Shaders structure for Visual Studio, even though everything about Shaders crashes the editor upon launch.

Thank you Andrew!

It may be more helpful to note that the empty Shaders directory alone is a separate issue to #includes. Just creating an empty Shaders directory under a Project, will crash the editor upon launch.

Also in the above combinations of #includes, the developers may want to see them besides the first one, as they will reveal how the preprocessor path parser is failing differently in several places with the file extension, the file path root, the missing files, etc.

In 4.16,a full path (#include “C:/Test.ush”) would work, and non existent files would give a compiler error as opposed to giving mysterious missing definitions. All these examples would point to several bugs in the code. I hope relaying these details are not too much trouble, but will make for a much more stable and flexible 4.17 for us shader developers.

Just copying the test lines above into the public tracker UE-47193 description would help me as a developer if I was fixing them. Also the only working examples may help other projects who may be stuck.

In the meanwhile, I am hopeful that moving our code to /Engine/beyond will allow us to migrate to 4.17.

Thank you again.

The engineers are aware of the various other ways to make it crash, I just provided the most simple repro and they will use this post as a reference as needed for more information if necessary.

Thanks for the additional information!

Good news Andrew,

Mr. Bunner just fixed 3 scenarios of properly emitting #include errors to avoid crashes in this commit:

Another good news is that I was able to migrate all our HLSL code to “/Engine/beyond/” virtual path and get them fully working. We are working on an ambitious realtime compositing system that is striving to match Hollywood quality.

There are a couple of remaining issues. I have not seen a commit addressing the empty Project/Shaders (next to Source directory) crashing the Editor at startup. Since now, full file paths to #includes are officially disallowed, the Shaders directory at Project and Plugin locations are the only proper methods to develop and distribute shader code. Also as another minor issue, the missing #include files are silently ignored.

Perhaps, I should wait and test Preview 2, before entering these issues on AnswerHub separately.

Thank you.

Hey Buke,

Thanks for providing clear repro steps. I was able to confirm what you are reporting, and have gone ahead and entered a bug report for the issue. You can track the report following the link below on our public tracker.


Once the issue has been addressed by our engineers the ticket will be updated and reflected in the public tracker. Let me know if you have further questions or need additional assistance.