Custom shader code in Unreal Engine — Part 1: Setup and Configuration

Intro

Preface

Here are some library files I’d recomment taking a peak at:

  • Engine/Shaders/Private/BasePassCommon.ush
  • Engine/Shaders/Private/BasePassVertexShader.ush
  • Engine/Shaders/Private/MaterialTemplate.ush

Project Settings

Create shader debug information

After following the setup described above, every material used in your project, will produce files showing you the combined / final shader file, after the UE shader preprocessor has glued all dependencies together. The output of your shader debug information can be found under: [YouProjectRoot]/Saved/ShaderDebugInfo/[ShaderTarget] where ShaderTarget might be PCD3D_SM5.

Optional / Recommended Settings

Build Script

In MyShaderDevPlugin.Build.cs:

Plugin Setup

Directory Structure

Module Definition

In MyShaderDevPlugin.cpp:

Outlook

Originally published at https://biq.solutions on February 23, 2020.

Today’s impossible, will be tomorrow’s reality. https://think-biq.com