Closed parnic-sks closed 1 year ago
Hi there,
I've tried to fix this issue many times but it keeps coming back from time to time.
I'm concerned about this warning:
warning X3570: gradient instruction used in a loop with varying iteration, attempting to unroll the loop
This breaks the unroll loop of the shader, creating the compilation error later. Is this shader the vanilla VDB Material ? Or are you using a custom Material ? If it is you should not have any gradient functions in it.
Prefacing each for-loop in VdbFogVolume.usf with [loop] I've found will suppress the error, but I'm judging by your comment above that this may not be the correct way to address this. Tried to use [unroll(x)] first but need a compile-time constant to do so, and it looks like the number of iterations is dynamic.
Is this shader the vanilla VDB Material ? Or are you using a custom Material ? If it is you should not have any gradient functions in it.
We haven't made any changes to the shaders or materials that come with the plugin, so it's vanilla.
Yes, adding [loop] (or LOOP with Unreal's macros) before the two for loops usually helps.
I was convinced I had done it already but apparently I only did it in VdbPrincipled.usf (the shader equivalent of the other mode).
Can you try adding LOOP on line 121 and 300 ? Let us know if it helps.
If it helps anybody, the USE_FORCE_TEXTURE_MIP 1
macro (added from CPP) is supposed to disable all gradient instruction from texture samples.
That's why I'm worried you're still getting a warning saying there are still gradient instructions. It should not happen.
Can you try also adding #define FORCED_TEXTURE_MIP 0.0f
before #include "/Engine/Private/Common.ush"
?
Will do, and thank you for following up so quickly with this help.
Adding #define FORCED_TEXTURE_MIP 0.0f
in the usf did not fix the problem. Adding the two [loop]
prefaces on the for loops does fix the cook errors/warnings.
We are on UE 5.2.1 using release 0.6.10 (SparseVolumetrics_ue5.2.1_0.6.10.zip). Attempting to cook our project results in cook warnings due to materials that are failing to compile due to errors in VdbFogVolume. The full cook output is:
Before I go diving much deeper into investigating this on our end, are the "unable to unroll loop" errors something that has been seen before that we're simply doing wrong or is this something unique to us in some way? This can be reproduced by using the Cook Content option in the editor and looking at the warning summary once it finishes.
We had the same problem with release 0.6.8 and were hoping that 0.6.10 would fix it, but it didn't. I realize this repo currently says it's archived, but thought I'd see if you could point us in the right direction.