Absolute World Position doesnt take geometry into account in SM3

I am having a problem with rendering a fog effect for mobile.
I was trying to use a combination of *Absolute World Position *and Camera Position in a *Post Process Material *to render the distance and to tint the result based on that distance.
Below you see a test setting for this.

This works like a charm in Shader Model 5:

Unfortunately when rendered in Android GLES3.1 preview (my project shall run on Android devices), the geometry is showing no effect.

Right now I am using *Exponential Height Fog *to render the fog in my map, but I am afraid that it is too expensive for many devices.
So I would love to find a solution for this problem.
I have already played with a fog effect via the materials based on the distance. But with that, I have to change each material in a map, which is annoying.

Is anyone having an idea, how I could achieve a cheap fog effect in SM3?


You’re “afraid” or did you actually verify that exponential height fog is too expensive? Because AFAIK it’s calculated per vertex in mobile, which should be a lot cheaper than any post process.

If you want even cheaper fog, roll your own vertex fog using vertex interpolators and add it to all your materials.

Thanks for you reply.
I am actually using *exponential height fog *and I am very happy with it :slight_smile:

Between the absolute world position and camera position, you want to use a distance node, not a subtract node.

Hi and thank you for your response.
I tested it in Shader Model 3.1 and it didn’t help.
The screen is getting white now instead of RGB. But the geometry is still not taken into account.

I think, I am gonna use exponential height Fog anyway, because it doesn’t have any serious impact into the performance.