famous
09-09-2010, 03:09 AM
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?
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?