• entries
    232
  • comments
    1462
  • views
    955654

Parallax mapping

Sign in to follow this  
Ysaneya

913 views

Finally, an update ? Yes and no.. the "major" thing I've been working on recently, the planetary engine, is making good progress, and I have a lot to say about it, and pics to show but.. not yet. I prefer to make sure everything is 100% running as expected before doing that, but once it'll be ready, expect many dev updates in a row.

Parallax mapping ( and rant )

Right.. parallax mapping. I'm going to rant a bit, not particularly against anybody in particular, even though innociv and Jammer have been the most recent people stressing and pushing for an implementation of parallax mapping ( and not believing me when I say that parallax mapping is, in practise, pretty much useless ).

Parallax mapping is a trick, implemented in a pixel shader, to distort the texture coordinates of a pixel before performing the usual per-pixel operations such as texturing and lighting. The distortion effect is made so that it offsets the pixels to give the illusion of parallax, the 3D effect you get due to moving pixels in the depth of the screen.

Parallax mapping has been a buzzword for years now. It is also probably the number #1 feature that is completely mis-understood by non-graphical programmers / non-programmers. Most people think of parallax mapping as an ultimate technique that will enhance a lot the visual quality at little costs.

I blame this misconception on the fact that many parallax mapping tech demos are extremely visually impressive. Too bad they usually don't apply in the "real world"..

In order for parallax mapping to be useful, a set of conditions have to be filled:

1. The surface you're looking at must be magnified ( this is the tech word for saying very zoomed-in ). If you are very far from the surface, parallax mapping is invisible.

2. For a constant surface dimension, the higher the UV tiling, the lesser the magnification, which makes the parallax effect invisible ( this is pretty much the same than rule #1 ). In other words, the more tiled a surface is, the closer you have to be to see the effect.

3. The view angle must be low: if you're on the top of the surface, looking down, even when you're close: no parallax effect.

In other words, for the parallax effect to be visible, you need to be close the surface and look at it from a low angle.

Parallax mapping has other drawbacks:

- aliasing artifacts: pixels do flicker especially in areas with a sharp bump contrast.

- performance cost: the basic implementation ( offset parallax mapping ) has a low cost and tons of visual artifacts - it just looks ugly. The correct implementation ( iterative parallax mapping ) has a medium cost and can easily cut your framerate in half.

Now, let's demonstrate why parallax mapping is useless in practise with a few pictures. Thanks to Wargrim/Rhino for the textured Cannibal model.

Terrain texture: the camera is at a low distance with a low angle. The parallax effect can clearly be visible - this is the good case for the algorithm! -.



The camera is moved at a bigger distance with a lower angle. Good luck for finding an improvement:



Now, let's see it in action on the Cannibal. Remember those large MK2 hardpoints ? They are textured with a 1024^2 from SpAce's texture pack. The camera, in world space, is already pretty close to it, maybe 20m. This is almost as close as you can get in a small craft/fighter, due to collisions.



Better, let's see some greeble. Again, pretty much as close as you can get from the hull in a small craft. The effect is visible, but is it worth half of your framerate ?

Also, notice the aliasing on the parallax version ( right image ), between the plating on the left of the image:



Finally, at a larger distance, it's impossible to say if one is better than the other:



So, next time somebody speaks of parallax mapping with stars in his eyes, don't let him fool you. It is one of those techniques that look good in tech demos, papers with specific scenes, textures and viewpoints.. but not in general. Stop thinking it's a magical solution that will magically make all your textures and shaders come to life.
Sign in to follow this  


12 Comments


Recommended Comments

Perfect! Now I have an explanation for why I can dump those expensive shaders ;)

I do wonder though, how does a much more expensive technique (such as relief mapping) fare in the same situations?

Share this comment


Link to comment
I agree with what you're saying but just wondering if you have seen/implemented Parallax Occlusion with adaptive LOD from ATi. I can't find the paper at the moment (might have been on Humus) but the basic effect was based on calculating the mip map level and then reducing the sampling based on the distance and eventually switching over to normal mapping (blending between the mip map boundary) where parallax would be useless. It was implemented in the toyshop demo for X1800's if I remember correctly.

Share this comment


Link to comment
hey! I've been on the infinity forums for a while now. I am just curious if you have a rough estimate as to when infinity will go into Beta? This seems to be a topic that never has any definitive answer...

BLOG

Share this comment


Link to comment
Heya. Great post. Also wanted to add some of my opinion to the mix.

Yeah, I've also been under the impression that parallax looks better when the camera is moving. Allowing the user to perceive the coarser detail.

Secondly, this effect is probably not a good choice for an application such as yours where the camera can often be at large distances and steep viewing angles from the textured surfaces. A better use might be (for example) in a FPS where you're walking around an underground cave. The effect could be used to bring out the courseness of the rock/dirt and create more atmosphere than flat textured tris. As the player walks around corners or close to walls, or "ducks" the camera close to the floor, the effect should create the illusion of much more detail than the mesh would otherwise convey. Of course, artifacts ruin the illusion altogether. Metal objects would often not gain much here as they have large flat areas with little detail.

Please note that I don't even use this effect in my work. These are just my impressions of the best uses for it.

Share this comment


Link to comment
Good rant [grin]

I have to edit my section of our D3D10.1 book at the moment, so I'll double check I've got these sorts of points covered in my chapter on per-pixel lighting. Thanks for the reminder!

I was going to raise the ATI adaptative approach - the Parallax Occlusion Mapping sample in the SDK is an implementation of this. I don't like the way that its a huge shader with quite a lot of branching, but conceptually its very interesting and should resolve a lot of the cases you've discussed in your journal.

Likewise with LachlanL, there are some common gaming/visualisation cases (e.g. FPS) where a parallax effect has more credibility. But that doesn't discount the fact that, as your main point states, its not the 'magic bullet' ...

Keep up the good work!
Jack

Share this comment


Link to comment
It's true that it would work better in a FPS, due to the camera being "naturally" at a lower angle. *But*, with texture resolutions rising up, and the frequency of details increasing, it will become harder and harder to see a strong parallax effect.

There are many ways to reduce the performance drop. The main two ones I have in mind ( and will probably implement ) are:

- LERPing the number of iterations between a min and max value, based on the angle you're viewing the surface at; it's very easy, just take the .Z component of the view direction once you're in tangent space.

- using the mipmap level to disable the effect when the texture is mignified/far away.

Share this comment


Link to comment
Quote:
Original post by Ysaneya
There are many ways to reduce the performance drop. The main two ones I have in mind ( and will probably implement ) are:

- LERPing the number of iterations between a min and max value, based on the angle you're viewing the surface at; it's very easy, just take the .Z component of the view direction once you're in tangent space.

- using the mipmap level to disable the effect when the texture is mignified/far away.


Your post didn't quite state if this rant meant you weren't going to implement the Parallax mapping technique in your engine but this reply of yours suggest you are still going to implement it, despite it's shortcomings, is this true?

Also, on a side note, if you want to see a game that implemented this feature which actually added a lot of atmosphere to the game, you should go play Oblivion and enter a few of the caves in that game. The high quality textures (using a HQ texture mod), good usage of HDR and the Parallax mapping really bring those caves to live.

Share this comment


Link to comment
Meh. I'll stick to mid-high poly models w/2k^2 color/normal/specular maps and be happy. You can always scale down texture resolutions, but you have to watch the pixel shader complexity as you mentioned it ain't hard to cut your frame rate in half :-)

Nice post btw, I agree with you 100%.

I wonder what you think of the engine used in crysis.

Share this comment


Link to comment
I am assuming that Relief Mapping will suffer the same issues as Parallax Mapping? I know that Relief Mapping is more expensive yet to run. Yeah I thought parallax mapping was cool at first but after thinking about, unless its close and objects like bricks, rocks, its worthless. I would rather see displacement mapping done, now with GL3.0 and DX10 hardware with GS units this would be nice to see in action.

Share this comment


Link to comment
great post, I agree. Was wondering, could you "turn off" the parallax mapping for geometry that isn't close? if on SM3+ cards, using a branch on length-squared(eye-position - vertex-position) against a threshold value could prevent distant aliasing, and also save your framerate when the effect is negligible, no? just a thought, probably effective in practice.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now