Intel sponsors gamedev.net search:   
Journal of YsaneyaBy Ysaneya      
Main project:

Infinity, a space-based MMOG

Forums

Wednesday, January 16, 2008
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.


Comments: 10 - Leave a Comment

Link


All times are ET (US)

 
S
M
T
W
T
F
S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
17
18
19
20
21
22
23
24
25
26
27
28
29
30

OPTIONS
Track this Journal

 RSS 

ARCHIVES
October, 2009
August, 2009
July, 2009
May, 2009
April, 2009
March, 2009
February, 2009
January, 2009
November, 2008
October, 2008
July, 2008
June, 2008
May, 2008
April, 2008
March, 2008
January, 2008
December, 2007
November, 2007
October, 2007
September, 2007
August, 2007
July, 2007
June, 2007
May, 2007
April, 2007
March, 2007
February, 2007
January, 2007
December, 2006
November, 2006
October, 2006
September, 2006
August, 2006
July, 2006
June, 2006
May, 2006
April, 2006
March, 2006
February, 2006
January, 2006
December, 2005
November, 2005
October, 2005
September, 2005
August, 2005
July, 2005
June, 2005
May, 2005
April, 2005
March, 2005
February, 2005
January, 2005
December, 2004
October, 2004
September, 2004
August, 2004