Closed TisAFleshWound closed 3 years ago
Have to agree that this issue being fixed would help immensely.
I've added support for this - although first I had to read up on how these virtual directory things work in Unreal Engine 😄
You can now add virtual directory mappings to shadertoolsconfig.json
(I've updated the readme with this information):
{
"hlsl.virtualDirectoryMappings": {
"/Shaders": "C:\\MyProject\\Shaders"
}
}
I'm going to release a new version of HLSL Tools shortly, and then I'd appreciate if you can please test this and let me know if it works correctly.
@tgjones Unfortunately I can't seem to get the virtual directories to work. I still get the error :
HLSL0018 Cannot open source file '/Engine/Public/Platform.ush'. D:\Private Shit\Unreal\DrasticAction\Shaders\Compute\CartesianSphere.usf
offending line in the shader is :
#include "/Engine/Public/Platform.ush"
config file is :
{
"root": true,
"hlsl.preprocessorDefinitions":
{
"HLSL_TOOLS": true
},
"hlsl.additionalIncludeDirectories":
[
"C:\\Program Files\\Unreal Engine\\UE_4.26\\Engine\\Shaders\\Public"
],
"hlsl.virtualDirectoryMappings":
{
"/Engine": "C:\\Program Files\\Unreal Engine\\UE_4.26\\Engine\\Shaders"
}
}
The shader works fine in Unreal so as a workaround I am using a pre-processor definition with an additional include directory
#ifndef HLSL_TOOLS
#include "/Engine/Public/Platform.ush"
#else
#include "Platform.ush"
#endif
The workaround works fine in Unreal and with HLSL Tools.
One thing I have noticed is the include directive points to /Engine/Public/Platform.ush
although the file actually resides at Engine/Shaders/Public/Platform.ush
Due to format requirements using for Unreal Engine 4 user is currently forced to keep #includes in a "/Folder/File.usf" format. This seems to prevent the #include from registering with this extension.
Example of #include working in Unreal Engine but failing in this extension HLSL TOOLS (Visual Studio Code)
Example of #include which fails in Unreal Engine which works with this extension HLSL TOOLS (Visual Studio Code) UNREAL ENGINE
An extension option allowing equivocation of "Folder/File.usf" and "/Folder/File.usf" or a fallback #include search using the latter would greatly enhance utility of the extension with Unreal Engine 4 and be greatly appreciated by this user.