That’s a very good suggestion, I hadn’t thought to try it.
Unfortunately this also doesn’t work.
First of all the link you sent is for Texture3D::SampleLevel, not Texture3DSampleLevel.
Or in other words, the function shouldn’t become Texture3DSampleLevel(GlobalDistanceFieldTexture0, (float instead of sampler), GlobalUV, 0).x;
but GlobalDistanceFieldTexture0.SampleLevel(SharedGlobalDistanceFieldSampler0, GlobalUV, 0).x; Minor problem, mostly just saying this for people coming here from google searching for a similar problem
GlobalDistanceFieldTexture0 is my texture3D object here.
I believe Texture3DSampleLevel(Texture3D, samplerState, float, float [,int]) might just be a function in unreal to wrap the function you showed.
This code compiles, but the same issue still persists.
I tried a few other things while I’m at it.
When using the DistanceToNearestSurface node, this code gets generated.
I ran this through a code compare tool and the lines I’m showing are the only differences between the two
shaders. Except for that, the two shaders are identical.
i guess the “Get Distance To Nearest Surface Global” is included by any function library.
You will find the “include” files and the path in the upper part of your hlsl code.
Mostly this include file collecting a bunch of functions also macros etc or other methods.
It’s part of GlobalDistanceFieldShared.ush
I opened this file inside of vs and copied over the code from there originally, that’s where the ComputeGlobalUV and Texture3DSampleLevel Functions came from.
Hey @Niels sorry to resurrect an old thread but were you able to get this figured out? I came across this thread while trying to write a custom node that I could use for ray marching while sampling the scene. I’m really new to using the custom node and not sure where to find documentation for the available functions.
Can’t remember, this is a long time ago.
But more than likely the solution in one of the recent engine versions is to either add GlobalDistanceFieldShared.ush as an include on the custom node, or add a dummy node that has that file as it’s dependency so unreal includes it.
Thank you this was just the hint I needed. I had to look around in the engine files and learn about FLWCvectors and how to convert between them and regular floats but I finally got it to work.
Just wish there was better documentation for these things…