I’ve just updated to unreal engine 5.4 and sadly all HLSL nodes are not working anymore
Here’s the code which was working fine in previous versions:
float planeDist = View.ViewToClip[3][2] * (1.0+FixDist);
float3 localPos = LWCMultiply(DERIV_BASE_VALUE(GetWorldPosition(Parameters)), GetPrimitiveData(Parameters).WorldToLocal);
float fov = View.ClipToView[0][0].x;
float3 CamPosition = LWCMultiply(LWCSubtract(mul(float4(0,0,0,1), ResolvedView.ViewToTranslatedWorld).xyz, ResolvedView.PreViewTranslation), GetPrimitiveData(Parameters).WorldToLocal);
float ratio = View.ViewSizeAndInvSize.y / View.ViewSizeAndInvSize.x;
float diagonal = length(fov * float2(ratio, 1.0));
float z = sqrt(1.0 - diagonal * diagonal);
float3 viewPos = float3(1, -ratio, 0) * planeDist * localPos * fov * 0.02 * (1.1) + float3(0, 0, planeDist);
float3 worldFPos = mul(float4(viewPos, 1), ResolvedView.ViewToTranslatedWorld).xyz;
return LWCToFloat(LWCSubtract(LWCSubtract(worldFPos, ResolvedView.PreViewTranslation), DERIV_BASE_VALUE(GetWorldPosition(Parameters))));
I’ve looked at the documentation but could not find anything about this case
It looks like the main issue is about LWC and double float could fix it but I can’t find a way.
_Z11
(_Z11)
May 24, 2024, 9:43am
2
I have the same question,My custom Node have worry noise ,but the code can work in 4.26 version.Have you solved it?
I have the same issue as well. After upgrading a copy of my project to 5.4, I get errors with LWCMultiply in my HLSL node.
I was able to find a solution for my problems. This page in the Unreal Documentation was very helpful: Large World Coordinates Rendering In Unreal Engine 5. | Unreal Engine 5.4 Documentation | Epic Developer Community
I had to convert my node to use the DoubleFloat.ush math library, which didn’t exist in previous versions of unreal. It was also helpful to open up that file and look through it. Mainly all I had to do was change LWCMultiply and LWCMultiplyVector to DFMultiplyVector, and change FLWCInverseMatrix to FDFInverseMatrix. There were a few variables and functions that didn’t plug in to these cleanly, but they have some conversion functions to help deal with that which are explained in the documentation. The two conversion functions I used were DFFromTileToOffset and LWCHackToFloat. These functions will cause a performance hit, but I am using this in a pre-rendered short film, so they work for me.
Here is my old code:
FLWCInverseMatrix WorldToLocal = GetWorldToInstance(Parameters);
float3 Scale = LWCMultiplyVector(float3(1.0, 0.0, 0.0), GetInstanceToWorld(Parameters));
float3 CameraPositionLS = LWCToFloat(LWCMultiply(ResolvedView.WorldCameraOrigin, WorldToLocal));
float3 CameraVectorLS = LWCMultiplyVector(CameraVectorWS, GetPrimitiveData(Parameters).WorldToLocal);
And here is my new code after converting it to work with 5.4:
FDFInverseMatrix WorldToLocal = DFFromTileOffset(GetWorldToInstance(Parameters));
float3 Scale = DFMultiplyVector(float3(1.0, 0.0, 0.0), DFFromTileOffset(GetInstanceToWorld(Parameters)));
float3 CameraPositionLS = DFMultiplyVector(LWCHackToFloat(ResolvedView.WorldCameraOrigin), WorldToLocal);
float3 CameraVectorLS = DFMultiplyVector(CameraVectorWS, GetPrimitiveData(Parameters).WorldToLocal);
1 Like