How to make a decal shader that projects on all 3 axis and can be rotated locally

I’m looking for help to create a decal shader that projects on all 3 axis. So a shader that when the decal is projecting onto a box with 90 degree angles, it will wrap around it nicely without stretching. I currently have a version that is world aligned, however I need the shader to be able to rotate locally without being locked in worldspace. Any help to sketch out what that shader would look like is much appreciated

You need to explain this better.

Decals are 2d. You can fake some triplanar mapping with them so they splatter on all the planes of the geometry they cover rather than only on the top.

I could assume that is what you mean, but I rather not.

If that is what you meant, just look up how to make triplanar decals. Generally speaking they are world aligned (the Z has to come from something).

If not, please explain what you need…

Thanks for the reply MostHost_LA :).

Yeah so basically I’m looking to create a shader that does what this video, linked below, is doing at timestamp 25 sec. Where it describes the function as Triplanar UV - with rotation and scale based on Decal Actor position. Thanks in advance! https://www.reddit.com/r/unrealengine/comments/xx0xhd/decal_with_triplanar_projection_which_respects/

Right so, like the video says. The material itself can’t do that.

The reason for it is that the engine’s decal actor doesn’t pass the data or make it accessible to the material.

The work around is for you to make a BP, then create a dynamic material and update the variables of it via code in the blueprint.

The possible issues here are the cost of it - it’s minimal but the BP works when it’s moved or on tick.

If you need this in engine and then baked, “oncreate” would work in the editor and very likely fail when you make the final packaged product; you need to test it.

if you need this for gameplay at runtime, then tick can work if you do it smart; you need to look into what that means and decide how to properly handle it via managers, threading, or all of the above.

IF (because the engine does change, and I’m assuming the video is correct as it was when I used the engine) the engine has changed, then all you really need to do is to try and input the correct math for the rotation (same math you would need to develop via scalar or rather vector values that you pass to the material as parameters); You have ActorPosition, ObjectPosition, PivotPoint, ObjectOrientation, etc
( Coordinates Material Expressions in Unreal Engine | Unreal Engine 5.7 Documentation | Epic Developer Community )

The scaling part is just math on ObjectBoundingBox (usually x2 it for full size if the paramter is half bounding box?).

Share the graph you have that you can share and I or someone can look up/fix the math.
However you probably don’t need to? There’s 10001 tutorials out there on how to make the rotation and stretching work for regular materials, don’t get suckered into the fact “it’s a decal”.

If you can’t “math”, I suggest you start with learning to math on far more complex stuff:
https://youtu.be/VwAM1xyn0Bg?si=SKyNjA82qOgatH2k

From there on, it’s just a matter of trial and error to port what you see into the texture’s UV space.
But remember that for what you are describing you need UV space:
https://www.youtube.com/watch?v=f9a780XjoKI

Also remember that Epic doesn’t know which way to make “rotations” work because egg heads run the system, so some stuff uses Radians, some stuff uses Degrees, some stuff uses percentages, etc. Don’t assume you know what unit to use on any of the “rotation” stuff until you tested the effect of the values :stuck_out_tongue:

PS: The way I am, I would open that custom rotator node extact the math and make my own function for it. You NEVER know when epic decides to change that function just to screw with you!