Download

Material Editor Distance Node doesn't work in Android

So I’m a bit confused why the distance node in material editor doesn’t work. Isn’t that just simple math? I also tried using AB formula to find distance but it seems that material editor in Android doesn’t take in square roots node math. Is this really a limitation to Android? Or just a bug?

Pixel shaders on ES2 use medium precision by default. Computing distance requires sum of squared vector components (x^2+ y^2 + z^2), this sum will overflow if vector magnitude is more than 256 (256^2 = limit for medium precision). You can set “Use High Precision” option in material editor, that will force pixel shader to use higher precision if it’s available (not available on old ES2 devices).

Ah thanks exactly what I needed and works like a charm. I had a work around but it required spawning bps. This saved me the trouble.

could we get a supports high precision routing node so we can have a fallback shader if the device doesn’t support?

The high precision shader will still compile and work on such devices, just the “highp” modifier will not have any effect. I would suggest to use Material Quality routing node instead of introducing new nodes. Then setup in device profiles which quality level device should use. There 3 buckets In Config/BaseDeviceProfiles.ini - [Android_Low] - [Android_Mid] - [Android_High]
All devices in last two buckets will support highp modifier.

thanks ddvlost!