Sign in to follow this  

Relief Mapping depth parameter

This topic is 2650 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

Hey,

I guess most of you know the relief-mapping algorithm:

f2s main frag relief( v2f IN,
uniform sampler2D rmtex:TEXUNIT0, // rm texture map
uniform sampler2D colortex:TEXUNIT1, // color texture map
uniform float4 lightpos, // light position in view space
uniform float4 ambient, // ambient color
uniform float4 diffuse, // diffuse color
uniform float4 specular, // specular color
uniform float2 planes, // near and far planes info
uniform float tile, // tile factor
uniform float depth) // scale factor for height-field depth
{
f2s OUT;
float4 t,c; float3 p,v,l,s; float2 dp,ds,uv; float d;
// ray intersect in view direction
p = IN.vpos; // pixel position in eye space
v = normalize(p); // view vector in eye space
// view vector in tangent space
s = normalize(float3(dot(v,IN.tangent.xyz),
dot(v,IN.binormal.xyz),dot(IN.normal,-v)));
// size and start position of search in texture space
ds = s.xy*depth/s.z;
dp = IN.texcoord*tile;
...

I'm just wondering about the depth parameter because I don't get why it controls the height of the heightmap details. I.e. if you put in a terrain map, a bigger depth parameter will result in higher mountains etc.

This s.xy*depth/s.z seems like it's the calculation of the parallax vector as described in Welsh's paper (projection of the eye vector onto the surface) and you can scale it with the depth parameter. This means that smaller depth paramter = shorter parallax vector = smaller sampling stepsize. So how does this scale the heightmap at all?

Share this post


Link to post
Share on other sites
Try to vizualize it mentaly. When the vector length increases, it increases backwards. That is, as the height incresases the origin of the ray is pushed backwards, in the direction of the ray, so that it remains located at the height limit.

If the ray a the surface full of bumps at an oblique angle, you will hopefully notice that increasing the height and pushing the ray origin backwards makes the ray hit the bumps in a lower position. That gives the illusion that the bumps are higher.

Share this post


Link to post
Share on other sites
ok, I still don't get it 100% but I feel like I'm close :)

So what do you mean by that: "[...]so that it remains located at the height limit."

Lets say my vector hits the top of a mountain and it's length is increased with the depth parameter. Now it increases backwards, right? Does that mean the end of the vector still remains at the top of the mountain?

You 2nd paragraph implies that it doesn't and that's where it gets weird in my mind :)

Share this post


Link to post
Share on other sites

This topic is 2650 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.

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

Sign in to follow this