parallax mapping or virtual displacement mapping

I came across the graphics topic of parallax mapping when I was reading about the Unreal 3 engine. They call it virtual displacement mapping, but I think that’s kinda missleading. Of course I had to go implement this for myself, so this post is all about my results. After my previous project “pongy”, you might guess that I’m ready to get back to graphics. Here’s the lowdown, bump/normal mapping looks good, but still seems flat. It looks like this because it changes the normal perpixel so you get varying lighting, but you dont get what’s called “parallax”. Parallax is a huge visual cue for depth, so bump mapping just aint good enough. When doing parallax mapping you attempt to offset texture coords on a perpixel basis to simulate the parallax effect based on the users perspective. RenderMonkey is great for doing these types of shaders effects because you can usually find something close to what you want and then just modify it. I started with the “ReflectiveSpecularBump” effect in the illumination project because it already implemented bump mapping. Using this research paper on the subject as a reference, I ported the OpenGL assembly shader into a couple lines of HLSL. After that I went through the project and cleaned up a bunch of stuff that ATI did poorly and optimized it the best I could.

The resulting shaders:
parallax.vs
parallax.ps

I’m in the process of making a managed directx project using .fx files to show off the effect better. I’ll post something about that in a few days with a link to the exe. For now check out the images I captured from my parallax RenderMonkey shader:

Click for full size
This is the texture without bump mapping or parallax mapping.

Click for full size
This is the texture witht bump mapping but without parallax mapping.

Click for full size
This is the texture witht bump mapping and parallax mapping.

Click for full size
Another view with parallax mapping to see the effect.

Click for full size
And yet another view.

You must realize that I didn’t add any geometry. All images above show just one side of a cube, that’s 2 triangles only.

4 Responses to “parallax mapping or virtual displacement mapping”

  1. Technomancer Says:

    Looks very good … I’ll have to do some investigation myself looks better than bump mapping for sure.

  2. Sebastien St-Laurent Says:

    Sweet brandon! Something i wanted to try myself but am just too busy right now :)

  3. Rory Says:

    Parallax Mapping is the r0×0r!!!111one

  4. discochimp Says:

    don’t know you but thank for posting this. helped me understand the unreal engines virtual displacemnt mapping and write my uni report.

    cheers :)

Leave a Reply