[4.24]Cannot implement HLSL in custom node in material editor

So I’m following this tutorial

What I am trying to do is to distort the landscape UV a little bit
If I write this line directly into the custom node, it is ok

But if I put it into a usf file under project/shaders, it cannot work
It even does not recognize the #include command
P2.pngdxxx

Says
[SM5] /Engine/Generated/Material.ush(1819,8): error X3000: syntax error: unexpected token ‘#’

If I write this


float norepeatjit

and then call it
in the custom node directly it still cannot work,becasue it will prompt

[SM5] /Engine/Generated/Material.ush(1819,18): error X3000: syntax error: unexpected token ‘(’
[SM5] /Engine/Generated/Material.ush(1823,1): error X3000: syntax error: unexpected token ‘}’

I mean…How the hell could I do this…
I think I can blueprint it, but it will be a complicated spaghetti noodle that people cannot read; and I cannot pack them and make it portable.

1 Like

I’m currently experiencing something very similar.

This is the code I’m using, copied directly from a green screening tutorial.

float3 ExtractColor(float3 Color, float LumaMask)
{

float Luma = dot(Color,1);
float ColorMask = exp(-Luma * 2 * PI / LumaMask);
Color = lerp( Color, Luma, ColorMask);

return Color / (dot(Color,2));
}

It’s giving me similar errors.

[SM5] /Engine/Generated/Material.ush(2082,20): error X3000: syntax error: unexpected token ‘(’
[SM5] /Engine/Generated/Material.ush(2086,24-27): error X3004: undeclared identifier ‘Luma’

I haven’t seen any ways to correct this yet?

you should add “return 1;” at the end. like this:

#include “/Project/Shaders/XXXX.usf”
return 1;