How can i implement other shader in unreal engine?

Hello everyone
I’m newbie in Ue4, I would like to know how can i implement new shader in my project such as volumetric cloud.
Thank you

Materials are shaders the node graph there will be converted to specific sheder language needed. First try to reproduce shader code using nodes, there material functions assets to emulate functions in sahder code, this will be the least invasive solution.

If you want to inject raw shader code there 2 ways

  1. Use custom node, which works like HLSL function (so you still would need to do some node work), problem is it does not guarranty it will work after packageing, you got warnings on bottom here: Custom Material Expressions in Unreal Engine | Unreal Engine 5.1 Documentation
  2. Edit shaders in UE4 source code, here is toon shader plugin somebody did, you might use it as a example how to do it:Toon shading model - Game Development - Epic Developer Community Forums

But first try using material nodes based on code you have :slight_smile: use stuff above only as last resort

Thank you for your reply and I just have some question about how to make volumetric cloud. When I adjust or shade texture of teapot, i can apply it to teapot’s mesh. In volumetric clouds, which mesh can i shade ? I have no idea for it.

I don’t know either im did du much shader work, try searching examples somewhere even HLSL or GLSL examples

As said you have to make it by using the material nodes. You can, however, make custom nodes with custom shader code. I will try to break it down into a few short steps.

  1. Create a box with inverted faces. Apply your material to this box.
  2. Create a volumetric cloud and slice it into many slices. 256 slices is ok. Then you have to glew them together into a grid.
  3. Use the camera position and the camera direction to calculate the ray and where it intersects the box.
  4. Calculate how many steps are required to traverse the box.
  5. Loop numSteps times and sample the volume by projecting the 3D volume to the 2D slice grid.
  6. Blend/accumulate/absorb all the samples as you see fit.

If you want some more information on this you can take a look at an excellent blog here. There is also a thread about it here.