Material Vector Expressions not working on Android?

Hi

We have started testing our scene settings on mobiles, and I have just came across a strange problem. We have decided to go with totally unlit scene, no lightmaps and no post-processing for our lowest performance tier. But what the scene really needs to look nice is some cool atmospheric perspecitve. So instead of using the fog I have decided to mix some predefined Fog Color directly into the materials, based on the objects’ distance from the camera. And it basically looks like this:

But when I built it on my Xperia M the “fog” effect got ignored. It simply does not calculate the Fog Color into the shaders, and besides that, everything works fine. I have tested all 3 options for the Feature Level Preview in the Editor, and all of them work fine with my “fog”.

And this is how it looks on the phone:

So where is the catch?

Forum link:

Hey rimau -

This is probably do to the UV math begin done through a pixel pipeline which has limits on mobile. If you go into your material attributes you can add a customized UV channel (if you are using any Textures better to add 2 that way you can not effect UV0). Take all the math for your Fog color and the MPC Parameters and plug that clamp into Customized UV0 (or UV1 depending), then create a UV coordinate with the exact and mask it to just the R channel and plug that into your LERP Alpha.

It should work as intended on mobile now. This is forcing the math to run on the vertex shader which has more options in mobile.

Thank You

Eric Ketchum

I’m affraid I do not follow :slight_smile: I do understand that I do add a Make Material Attributes node. The last Clamp node I should connect to one of the Customized UVs, and this should be no problem. But the part with “creating a UV coordinate with the exact” is where I’m getting lost. I’m missing some bigger picture here, as this are some of my first steps with UE4 materials.
I have attached a full material setup, with just Make Material Attributes node added. If you could be a bit more specific what to connect where that would be great. And some tips what to look for in the documenation/tutorials to get some better understanding of the problem.

Here is my setup this should clear it up, my apologies for the confusion.

Thank You

Eric Ketchum

Thanks a lot, now I get it! :slight_smile: In the meantime I have tested one other approach. I have placed the meshes inside the blueprints, than got their world locations and passed that values into a new Distance parameter. So it looks like now I have two working solutions at my disposal. Thanks again for your help.