Question about parallax bump mapping

I don’t manage to find how make this in a single pass, do you know how ?
Otherwise where can i find documentation about multipass rendering and how render to a texture ?

Just to be sure we are talking about the same thing : is that it ?

if it is, it’s not multipass
have a look at this :

and this :

hope it helped

ok thanks it’s that.
Just a question about the documentation, they are talking about bias, what is it ?

bias is a parameter you ADD to something to offset it. Scale and bias are used to map a value to a certain range.

thanks, but there is a thing which i wonder :
how is calculated the bias ? i have understood for the scale but i don’t understand how find the bias :

“The correct scale factor for this material would be 0.02 /
2 = 0.01. Coupling this with a bias of 0.0 would then remap the height field to a range of
{0.0, 0.01}. Using a bias of ­-0.01
would remap the range to {-­0.99,
0.0}. The average of
these two extremes is probably best for most textures.
b = s ∙ -­0.5”

how are found these ranges : {0.0, 0.01} and mainly {-­0.99,0.0} ?

PS : why for the computation of the new texture coordinates they divide by V(z) ? here : Tn = To + ( hsb ∙ V{x, y} / V{z} )

It would be nice of helping me, i just miss that to understand all what i want before implementing this effect.

There my responses will get a little bit more fuzzy :rolleyes:
#1 - there isn’t 1 set of correct scale/bias values : I’ve seen a couple demos implementing this effect, and sets where different each times. Basically, increasing the scale produces higher bumps.
#2 - I don’t know. Dividing or not doesn’t change anything in my demo.

sorry i cant help you more

ok thanks for help, somebody knows something about it ?

In parallax mapping texels are slughtly displaced from their position based on input bias and scale parameter. So, without bias and scale, your parallax mapping will look awfull because of too big displacement. To be more precize, reading height returns float value 0.0 - 1.0. So, you need to scale this to ~2% of it’s value. To do this just multiply height by 0.02. Now, height value is in range 0.0 - 0.02.

Since height value is still positive number, this mean, value 0.0 will not displace and value 0.02 will be maximum displacement. It will be nice to offset height by -0.01, and after all math, black color in height texture will displace pixels by -scale/2 and white color in height texture will displace pixels by +scale/2. Gray color will not displace pixels.


float height = texture2D(heightmap, texcoord).a;
height = height * 0.02 - 0.01;
vec2 newtexcoord = texcoord + eyevec.xy*height;


ok thanks for your answer but i have three questions :
1)why do you offset height by -0.01 ?
2)why do you divide scale by 2 ?
3)why gray color will not displace pixels ? if we read in the height map a value of 0.6, the result will not be 0 ?

Scale and bias is used to map one range to another. So… in this case, you have to map range 0.0 - 1.0 to range -X to X.

To do this you have to do following math:

newval = val * 2X - X

So… scale is 2X and bias is -X

If X is 0.01 then it looks like
newval = val * 0.02 - 0.01 -> range 0…1 is mapped -0.01 to 0.01
If val is 0.0 newval will be -0.01 -> negative displacement
if val is 1.0 newval will be 0.01 -> positive displacement
if val is 0.6 newval will be 0.002 -> small positive displacement
if val is 0.5 newval will be 0.0 -> no displacement

And, if you ask why scale and bias is 0.02 and -0.01?. Well, you can try to change this values, but bigger values lead to “over-displacement” and result is not looking good.


ok and can we always use these values with all textures ?

This depend on your artist… Some textures can be more displaced, some less. But all textures in active shader should be displaced by same scale and bias vales. This mean… compute displacement once and then fetch pixels from other textures (diffuse texutre, normal map, gloss map, …)


ok thank you.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.