Jump to content
  • Advertisement
Sign in to follow this  
whathappened

Parallax mapping

This topic is 4602 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I dont really know if this topic fits into the DirectX forum but I hope so since it's about shaders. I just wonder, what is parallax mapping? I know how to make bump mapping and some displacement mapping (to actual change the geometry) but what is parallax mapping? Anyone who has a good link where it's explained cause I couldnt find one

Share this post


Link to post
Share on other sites
Advertisement
Also, in case you are interested in an actual implementation, a Parallax Mapping sample has been recently added to the SDK samples. Grab the April '06 SDK to give it a go.

Hope this helps. :)

Share this post


Link to post
Share on other sites
Don't know about a tutorial, but if you google "parallax mapping site:ati.com" you should find a couple of docs. ATI's March SDK contains an article about this.

Share this post


Link to post
Share on other sites
Its quite simple, actually. It only requires a heightmap texture for the shader pass.


float3 vEye = -TBNViewDir;
float fBumpScale = 0.05f;
float2 vCoord = texCoord;

float fDepth = tex2D(sHeightMapSampler, vCoord).w;
float2 vHalfOffset = normalize(vEye).xy * (fDepth) * fBumpScale;

fDepth = (fDepth + tex2D(sHeightMapSampler, vCoord + vHalfOffset).x) * 0.5;
vHalfOffset = normalize(vEye).xy * (fDepth) * fBumpScale;

fDepth = (fDepth + tex2D(sHeightMapSampler, vCoord + vHalfOffset).x) * 0.5;
vHalfOffset = normalize(vEye).xy * (fDepth) * fBumpScale;

return vCoord + vHalfOffset;


Then, sample the diffuse texture and the normal texture using the returned coordinates.

Basically, it samples the height map at the texture coordinate, and offsets the texture coordinates in the direction away from the viewer. I do 3 iterations to get good results. If you only do one, the effect is negligible.

In these 2 screenshots, I have doubled the parallax amount to make the difference clearly visible.


No parallax mapping


Parallax mapping

Share this post


Link to post
Share on other sites
Ah cool, I didn't think about multiple samples/calculations. Does that increase accuracy or create a larger offset?

Share this post


Link to post
Share on other sites
Cadef, in the second screenshot if seems like your parallax mapping goes off to the left. Maybe a projection problem?

Share this post


Link to post
Share on other sites
Multiple samples increase accuracy. If you take 1 sample, it will look wrong.

It is supposed to go off to the left, that is parallax mapping. It might seem a bit wrong, because I exaggerated the parallax scale to make the effect prominent.

Share this post


Link to post
Share on other sites
So parallax mapping is just about the texture coordinates? Would be great with a little more detailed explanation :)

and does anyone know any links where I can find a simple texture and a nice parallax map to work with :)

[Edited by - whathappened on April 16, 2006 7:25:58 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!