Skip to content

How to use ShaderReplacer

AzumattDev edited this page Mar 31, 2022 · 2 revisions

How to use ShaderReplacer


In your Piece creation journeys you might find yourself wanting to make pieces that respect the rain inside Valheims ecosystem.

The rain interaction is based off a shader in Valheim. So PieceManager gives you an easy option to make use of that shader on your pieces

Unity Portion


When creating your piece in Unity you will want to choose the Custom/Piece shader as shown below

160685497-3b1fde47-6aa4-4729-9de8-79f61b6d33ee

If you desire to have rain on your part tick the Add Rain box on the inspector for the shader

If your piece is like a roof or a wall you will want this box unchecked

Code Portion


When Setting up your piece in the Awake() method you need to only add 1 line

RegisterGameObjectForShaderSwap(insertyourprefabhere)

If you need a different shader that isn't Custom/Piece you can get it using the line below MaterialReplacer.RegisterGameObjectForShaderSwap(insertyourprefabGOhere, MaterialReplacer.ShaderType.*);

The easiest way to do this is to just pass the .prefab from your custom build piece you have just created

Clone this wiki locally