Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/Samples/Media/materials/programs/OffsetMapping_specular.asm @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 1.4 KB
Line 
1// Pixel Shader for doing bump mapping with parallax plus diffuse and specular lighting by nfz 
2
3// uv               TEXCOORD0 
4// lightDir            TEXCOORD1 
5// eyeDir            TEXCOORD2 
6// half               TEXCOORD3 
7
8// lightDiffuse         c0 
9// lightSpecular      c1 
10// Parallax scale and bias c2 
11// normal/height map   texunit 0 - height map in alpha channel 
12// diffuse texture      texunit 1 
13
14ps.1.4 
15
16
17texld r0, t0               // get height 
18texcrd r2.xyz, t0            // get uv coordinates 
19texcrd r3.xyz, t2            // get eyedir vector 
20
21
22mad r0.xyz, r0.a, c2.x, c2.y   // displacement = height * scale + bias 
23mad r2.xyz, r3, r0, r2         // newtexcoord = eyedir * displacement + uv 
24
25phase 
26
27texld r0, r2.xyz            // get normal N using newtexcoord 
28texld r1, r2.xyz            // get diffuse texture using newtexcoord 
29texcrd r4.xyz, t1            // get lightdir vector 
30texcrd r5.xyz, t3            // get half angle vector 
31
32dp3_sat r5.rgb, r0_bx2, r5         // N dot H - spec calc 
33dp3_sat r4.rgb, r0_bx2, r4         // N dot L - diffuse calc 
34+ mul r5.a, r5.r, r5.r 
35mul r0.rgb, r4, r1            // colour = diffusetex * N dot L 
36+ mul r5.a, r5.a, r5.a 
37
38mul r5.rgb, r5.a, r5.a         
39mul r5.rgb, r5, r5         
40mul r5.rgb, r5, r5         
41mul r5.rgb, r5, c1            // specular = (N dot H)^32 * specularlight 
42
43mad r0.rgb, r0, c0, r5         // colour = diffusetex * (N dot L)* diffuselight + specular 
44+ mov r0.a, c2.b 
Note: See TracBrowser for help on using the repository browser.