Skip to content

Phyronnaz/MaterialShaderExample

Repository files navigation

Material Shader Example

This project is a small example on how to do a FMaterialShader in Unreal Engine.

It also shows how to hook into the Nanite visibility buffer to replace shading bins with custom ones.

A quick overview of this plugin is available here: https://victorcareil.com/making-material-shaders

Structure

All the relevant C++ code is here: https://github.com/Phyronnaz/MaterialShaderExample/tree/master/Plugins/MaterialShaderPlugin/Source/MaterialShaderPlugin/Private

The only shader in this project is here: https://github.com/Phyronnaz/MaterialShaderExample/blob/master/Plugins/MaterialShaderPlugin/Shaders/MaterialShaderExample.usf

What this does

This example plugin adds a new actor class, MaterialShaderExampleActor. There should only be one placed per level.

This actor has a few settings:

  • MaterialToReplace: this is the material to replace in the Nanite visibility buffer

  • MaterialSelector: this is the material handling material selection. It will be called by our custom material shader. The BaseColor.r output will be used as index into the NewMaterials array.

  • NewMaterials: the materials to replace MaterialToReplace with, selected by MaterialSelector

Screenshots

The floor material here is replaced by red & blue materials:

image

Red and blue are two fully different materials:

image

The material selector is using noise to pick which material to render:

image

The actor settings, note the material indices:

image

About

Example of how to do a material shader in Unreal Engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors