Hi,
hier mal der Anfang des RM-Algorithmus als Cg-Implementierung:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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;
...
|
Ich wundere mich gerade über den depth-Paramter. Angeblich soll er ja die Höhe der Oberflächendetails steuern und das tut er auch, nur verstehe ich nicht wieso. Wenn ich das richtig sehe ist das hier:
ds = s.xy*depth/s.z;
ja die Berechnung des Parallax-Vektors wie im Paper von T. Welsh beschrieben (Projektion des Blickvektors auf die Oberflächenebene). D.h. wenn ich den depth-Paramter dazu nutze, diesen Vektor zu skalieren, steuere ich doch, wie fein die Depth-Map abgetastet wird. Also müsste das doch auch irgendwie die Sampling-Qualität erhöhen. Wo kommt jetzt also die Höhenskalierung?