Is it possible to have a particular material not use half floats on Mobile?


We have a particular material that renders fine on PC but is really low res on Mobile. My understanding is that mobile uses half floats in the pixel shader. Is there anyway to turn this off for a particular material?

Is the use of half floats a hardware limitation or is it just a performance optimisation? If there’s no current way to turn this off could you please point me in the right direction so I might be able to implement it myself?



Hi Ryan,

Some older devices don’t support full precision floats at all. For those that do, full floats are generally half the speed of half floats, but we realize there are cases where you want to eat the cost, and we have a feature request currently slated for 4.13 that will enable you to turn on full precision on a per material basis. The ticket for that is UEMOB-109.

In the interim, you could try use the “CustomUV” feature of the material system which lets you perform calculations in the vertex shader and send the results to the pixel shader, which does allow you to work around a lot of precision issues.

Hi ,

I plan to only run this particular material on iOS devices that support Metal.

I’ve tried using custom UVs, but I need more floats than I can fit into 3 custom UV slots and my understanding is I can’t have more than 3 custom UVs on Mobile. Also, some of the calculations I need to do are on values pulled from texture samples.

Would you be able to point me to the code that forces half floats. I might be able to hack something in while I wait for 4.13.



There’s a define in the shader code (Engine/Shaders/*usf files) FORCE_FLOATS. You could modify Common.usf and so it’s set to 1 rather than 0 when it’s not defined:

#define FORCE_FLOATS 1

There’s no way to do that on a per-material basis yet. The best way to do that would be to add code to FHLSLMaterialTranslator::GetMaterialEnvironment to set the define based on an FMaterial property, which would map to a UMaterial checkbox. The ShouldGenerateSphericalParticleNormals() virtual function is an example of how to get to a UMaterial checkbox from the FMaterial.

Thanks ! That all worked.

I’m having one other issue with a material / render target on mobile. I created a new question for it here. If you could take a quick look that would be great!