Pages

Monday, September 2, 2013

[UDK] Iterative Parallax Mapping

Iterative Parallax Mapping is a good way to improve the simple, old fashioned Parallax/BumpOffset Mapping which often suffers from texture swimming and only barely noticable effects. Yet it's way cheaper than complex techniques like parallax occlusion mapping or relief mapping.


Material

To get started with the material editor I'd suggest to rebuild the functionality of the BumpOffset node first.




With iterative parallax mapping the texcoords of this simple parallax effect are used as an input for another parallax pass. In addition the height value is being multiplied by the normal maps blue channel which prevents from texture swimming at steep slopes. Having multiple iterations also means that the total height ratio is equal to [height ratio per pass * iteration count].
This is the material setup for 2 iterations:




As an alternative you can chain up multiple BumpOffset nodes. This won't include a multiply by normal.z but is faster to set up as well as cheaper on instructions.




For a more flexible setup (varying iteration counts) you can put all of this into a custom node:




Results

Iterative parallax mapping can produce some visually pleasing results. Of course it's not as good POM as it won't handle self occlusion. But even though it's just a shift of texture coordinates, some of the fakery depth can be preserved even at an oblique angle of view. For textures like bricks or cobble stone it might be also a good idea to implement some fakery self shadowing for the material.






Performance

The performance impact of the material is 5 shader instructions per additional iteration (or 3 instructions per iteration if you stick with multiple BumpOffset nodes). For most materials there is no need to go higher than 4 iterations.




Normal Mapping Normal + Parallax Normal + Iterative Plx
(1 Iteration)
Normal + Iterative Plx
(2 Iterations)
Normal + Iterative Plx
(3 Iterations)
Normal + Iterative Plx
(4 Iterations)
Normal + Iterative Plx
(8 Iterations)
Instructions 48 51 54 59 64 69 89

3 comments:

  1. wow this is pretty simple and very nice result, thank u :)

    ReplyDelete
  2. float2 Optimize = Ratio * Camera.xy;
    Coordinate += (tex2D(Height, Coordinate).x + Offset) * Optimize;
    Coordinate += (tex2D(Height, Coordinate).x + Offset) * Optimize;
    Coordinate += (tex2D(Height, Coordinate).x + Offset) * Optimize;
    return Coordinate;

    This code is based on here without multiply normal.z but has same instructions with 3 bump offset node.
    Thanks for sharing...

    ReplyDelete
  3. Any chance you could do a setup for UE4? I never used UDK.

    ReplyDelete