PDA

View Full Version : Offset limiting in parallax mapping



M/\dm/\n
12-05-2004, 06:12 AM
What is the best way to limit offset in parallax mapping? The original paper advises to drop division by zth component of view vector, but I think, that there was a solution to divide by tangent of something, not sure what...

Twixn
12-05-2004, 12:22 PM
Well, from what i've seen, offset limiting is simply normalizing the Eye vector and adding a bias to the heightmap.

Heres the fragshader code i use:

//get height of fragment
float VDCoord = texture2D(HeightMap,gl_TexCoord[0].xy).x;
// Bias height (so that white is not too high, and black is 'deep')
VDCoord = VDCoord * 0.03 - 0.015;
// Normalize frag->Eye vector
vec3 EyeTemp = normalize(EyePos);
//Apply Parallax mapping to texcoords
gl_TexCoord[0].xy = VDCoord * EyeTemp.xy + gl_TexCoord[0].xy;
This is the only way Ive seen, so i think its the best way, but if anyone has a faster/better way i'd be glad to see it too.

mogumbo
12-07-2004, 06:36 AM
Looks like Twixn isn't doing the divide by z, just like M/\dm/\n said. (Wow, M/\dm/\n is hard to type fast.) I originally took out the divide by z because it gives a decent effect and it's faster than doing any fancy extra math.

M/\dm/\n
12-07-2004, 08:04 AM
If I recall correctly, you was first to suggest parallax mapping, yes? Cool effect :)
I implemented the method by reading pdf about it, and I am ommiting z too. Gives speedup and seems to work nice, but I think I read somewhere about some tg stuff. Maybe I'm just mistaking something.