No announcement yet.

Absolute World Position doesnt take geometry into account in SM3

  • Filter
  • Time
  • Show
Clear All
new posts

    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.
    Click image for larger version

Name:	PPMat.jpg
Views:	67
Size:	107.6 KB
ID:	1584490

    This works like a charm in Shader Model 5:
    Click image for larger version

Name:	SM5.jpg
Views:	51
Size:	36.7 KB
ID:	1584489

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

Name:	SM3.jpg
Views:	57
Size:	45.7 KB
ID:	1584488

    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?

    Attached Files

    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


        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.