No announcement yet.

Virtual Shader Source Path - Link custom Shaders 4.21

  • Filter
  • Time
  • Show
Clear All
new posts

    Virtual Shader Source Path - Link custom Shaders 4.21

    Hello developers community,

    I used to write custom shaders and store them locally in my game projects root/ "Shaders" directory, which used to be defined as a virtual shader source path by default until 4.21.

    If you're working in C++ an easy way to add it back:

    While initiating your C++ project, you'll have a file implementing your project as a 'game module' :

    IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, MyUE4Project, "MyUE4Project");

    Instead of using 'FDefaultGameModuleImpl', you can create your own simple game module and override "StartupModule" and "ShutdownModule" (check ShooterGame project for reference).

    Add ShaderCore as a dependency in your project "" :

    PublicDependencyModuleNames.AddRange(new string[] { "RHI", "ShaderCore", ...}
    And add back the project "shaders" directory as a potential source for shader files:

    void FMyUE4ProjectModule::StartupModule()
        FString ShaderDirectory = FPaths::Combine(FPaths::ProjectDir(), TEXT("Shaders"));
        AddShaderSourceDirectoryMapping("/Project", ShaderDirectory);

    Now you can create a "Shaders" folder at the root of your game project and store your shaders in there !

    Tutorial for custom HLSL shaders:

    Last edited by MaximumDup; 12-17-2018, 06:21 AM.
    LinkedIn | Link custom Shaders in 4.21 | Atmosphere Modelisation | Nvidia GameWorks builds - 4.19.2 : VXGI2.0, Blast, HairWorks, Flow - Plugins: VictoryBP