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:
This is the texture without bump mapping or parallax mapping.
This is the texture witht bump mapping but without parallax mapping.
This is the texture witht bump mapping and parallax mapping.
Another view with parallax mapping to see the effect.
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.
August 31st, 2004 at 12:34 am
Looks very good … I’ll have to do some investigation myself looks better than bump mapping for sure.
August 31st, 2004 at 3:17 pm
Sweet brandon! Something i wanted to try myself but am just too busy right now
September 20th, 2004 at 3:16 pm
Parallax Mapping is the r0×0r!!!111one
March 23rd, 2005 at 6:25 pm
don’t know you but thank for posting this. helped me understand the unreal engines virtual displacemnt mapping and write my uni report.
cheers