I’ve really been struggling with an issue here. I’m almost 100% there’s an issue with how unreal is building shaders for iOS (possibly other mobile platforms, but I can’t confirm). I’m trying to reveal a material over the whole environment from a world position using some basic distance math but when building for iOS the results are completely broken. All the different preview modes work great (SM4, SM5, ES2), but when it gets on to the platform everything falls apart. I have [another question][1] going to try and solve it, but with no luck. At least over there, you can see the result of the error with the supplied images.
But out of all my tests, I really feel like there may be an issue with either the AbsoluteWorldPosition, distance, or division shader nodes. I doubt it’s the div. node, but the other two seem to be the culprits. Would someone be able to confirm?
This is the math that’s causing my problem. Again - only when built an iOS device.
I’ll give that a shot and see what happens. I’m going to suggest (wherever that may be. Forums, I guess) to have the ES2 preview simulate the precision so that it’s not a surprise when doing a build.
All this because unreal doesn’t support custom Post processes on mobile. I hope that changes once Metal is completely supported / integrated.
indeed, but if Epic actually wants to be a serious contender with Unity for the mobile market then those are the types of things they need to make sure work very well.
the more this goes on, the less I’m thinking it’s actually a precision error. Especially now that I have it all calculated in the customizedUVs and the result I’m getting is the exact same.
Normally low precision returns garbage. This is not my case, it’s returning a very smooth/clean but wrong result.
I am not seeing the same results you are describing. Using only the math you are showing above and a Texture I am able to feed the math into a UV and get the results I would expect both using a Material Function and without.
Here is a screenshot of my results on an iPhone5s:
Can you provide the full Material and Material Function for testing, screenshots of said materials, or explain in detail how you are using the math specific to the material causing your issue?
hi Eric, thanks for the reply. I’ll definitely do that as soon as I get to my machine. But in the meantime - in the Scale input I’m setting the offset. If this offset goes over a certain value, it no longer works. The value is around 250. Over that it ramps up exponentially, resulting in the whole world being covered as if the falloff (hardness) is set to infinity.
If you look here at another question (this thread is a bug as opposed to an regular question), you can see a little closer how I’m using it. Just so you know - the animation I’m doing now is a simple clamped sin wave for debugging fed from a blueprint. Eventually this will be driven by gameplay. This actually makes me wondering if the bug is coming from blueprint instead of from the shader editor. I’ve output (print to screen) the result of my blueprint script to see if it was generating any strange values. Everything was ok, but I guess that doesn’t mean it’s working properly in a build. When I get to my pc I’ll also put the debug sin*time in the shader to see if it has the same result.
hey Eric, is there somewhere I can direct message you to send you a link to the project? I have no clue how to extract all the pieces so that you can import it. The export tool does not seem to take along the dependencies of the selected item. At least that’s how it seems. It’s probably just easier to share the whole thing, but I would rather not post the link to that here.
I was able to get a reproduction of the error internally and have submitted a bug report as UE-25532. As we investigate a solution and cause I will keep you informed here of the outcome.
Our engineers are actively working on the issue currently, but it does not look like it will be ready by the 4.11 release. As soon as I have a fix I will post back here with the Github pull for you though.
There isn’t an update at this time. The current target is listed as 4.13 for a fix, but this could likely get pushed out to a later release depending on other priorities.
This is a floating point overflow. Pixel shader on es2 devices uses medium floating precision which has range about [-65000, 65000]. Distance and normalize functions work without overflow only for vectors with magnitude less than 255. Because to compute distance, device needs to compute sum of vector components squares. In 4.13 we have added an option to use full precision in pixel shader on devices that support it. (Material → Mobile → Use Full Precision). So you will need to rework this material to not use Absolute World Position in pixel shader. Or wait for 4.13 to come out.