Shader includes not working

image
I’m trying to make a shader for a mesh pipeline but any includes i include in the .usf file seem to never work because of them not being able to find a source file.

where do you get the error? in the engine or visual studio?

don’t trust visual studio errors.

make sure you also include the shaders folder

    	
void FLifeDevModule::StartupModule() {
	IModuleInterface::StartupModule();

	// https://biq.medium.com/configuring-unreal-engine-for-custom-shader-development-biq-cf79f72e7137
	const FString& ShaderDirectory = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders"));
	const FString VirtualShaderDirectory = TEXT("/Project/Shaders/LD");
	// avoid crash on hotreload. yes. hotreload. and yes. a crash.
	if (AllShaderSourceDirectoryMappings().Contains(VirtualShaderDirectory)) {
		UE_LOG(LogTemp, Warning, TEXT("%hs Shader directory already exists. dir=%s"),
			__func__, *VirtualShaderDirectory);
		return;
	}

	UE_LOG(LogTemp, Log, TEXT("%hs LifeDev Shaders path '%s'"), __func__, *ShaderDirectory);

	AddShaderSourceDirectoryMapping(VirtualShaderDirectory, ShaderDirectory);
}

then you add a folder called “Shaders” besides your .uproject file

you include them using the virtual shader directory as path.