iOS - is the subtract, divide or distance shader math broken?
I created a little material function to add a spherical falloff to my materials, but for some reason the result is completely off on iOS builds.
I'm using the SphericalMask node (i also tried with my own function that does the same thing, but also did not work). This is what my material function looks like -
On PC in all the preview modes I've tried it works great. Here's what it should look like (noticed the cloudy overlay on the floor's material) -
When I send this to iOS though, the falloff is completely broken and covers the whole world when the value for the Radius input goes over ~260. Here's what I get -
With values between zero and ~250 the look is the same on both. Anything higher on iOS quickly covers the entire world. So between ~260 and ~280 the gradient goes from what you see in the first result (working) to what you see in the second result (not working).
On all other builds and previews I've tried I can increase the Radius value to as high as I want and it will slowly cover the entire map as intended.
This is how I'm using the material function btw -
It really feels something is going off with the division in the SphericalMask node. Has anyone else run into a similar issue? Any help would be great.
looks like there was indeed a bug that's been logged - UE-25532.
answered Jan 26 '16 at 05:52 PM
It's hard to say without looking at your entire material. But keep in mind that on most mobile devices/chipsets, you have less floating point depth than on desktop. So for example, on desktop, you will typically have 32 bits of floating point depth when doing shader math. On mobile, you typically have 16 bits, which is a lot less. If you have a large chain of math operations, especially ones where you subtract two large numbers and end up with a small number, you will run out of floating point precision and underflow or become unexpectedly quantized, which will give you unexpected results.
I'm guessing this is what is happening to you here. You can try restructuring your material to avoid precision loss, or use a switch to select a simplified version on mobile.
answered Jan 06 '16 at 02:23 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here