| 1 | ps.1.4 | 
|---|
| 2 |   // conversion from Cg generated ARB_fragment_program to ps.1.4 by NFZ | 
|---|
| 3 |   // command line args: -profile arbfp1 -entry main_fp | 
|---|
| 4 |   // program main_fp | 
|---|
| 5 |   // c0 : distortionRange | 
|---|
| 6 |   // c1 : tintColour | 
|---|
| 7 |   // testure 0 : noiseMap | 
|---|
| 8 |   // texture 1 : reflectMap | 
|---|
| 9 |   // texture 2 : refractMap | 
|---|
| 10 |   // v0.x : fresnel  | 
|---|
| 11 |   // t0.xyz : noiseCoord | 
|---|
| 12 |   // t1.xyw : projectionCoord  | 
|---|
| 13 |  | 
|---|
| 14 | def c2, 2, 1, 0, 0 | 
|---|
| 15 |  | 
|---|
| 16 |   // Cg:        distort.x = tex3D(noiseMap, noiseCoord).x; | 
|---|
| 17 |   // arbfp1:    TEX R0.x, fragment.texcoord[0], texture[0], 3D; | 
|---|
| 18 |   // sample noise map using noiseCoord in TEX unit 0  | 
|---|
| 19 |  | 
|---|
| 20 | texld r0, t0.xyz | 
|---|
| 21 |  | 
|---|
| 22 |   // get projected texture coordinates from TEX coord 1 | 
|---|
| 23 |   // will be used in phase 2 | 
|---|
| 24 |  | 
|---|
| 25 | texcrd r1.xy, t1_dw.xyw | 
|---|
| 26 | mov r1.z, c2.y | 
|---|
| 27 |  | 
|---|
| 28 |   // Cg:        distort.y = tex3D(noiseMap, noiseCoord + yoffset).x; | 
|---|
| 29 |   // arbfp1:    ADD R1.xyz, fragment.texcoord[0], c1; | 
|---|
| 30 |   // arbfp1:    TEX R1.x, R1, texture[0], 3D; | 
|---|
| 31 |   // arbfp1:    MOV R0.y, R1.x; | 
|---|
| 32 |  | 
|---|
| 33 |   // Cg:        distort = (distort * 2 - 1) * distortionRange; | 
|---|
| 34 |   // arbfp1:    MAD R0.xy, R0, c0.x, -c0.y; | 
|---|
| 35 |   // arbfp1:    MUL R0.xy, R0, u0.x; | 
|---|
| 36 |   // (distort * 2 - 1) same as 2*(distort -.5) so use _bx2 | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 |   // Cg:        final = projectionCoord.xy / projectionCoord.w; | 
|---|
| 40 |   // Cg:        final += distort; | 
|---|
| 41 |   // arbfp1:    RCP R0.w, fragment.texcoord[1].w; | 
|---|
| 42 |   // arbfp1:    MAD R0.xy, fragment.texcoord[1], R0.w, R0; | 
|---|
| 43 |   //    final = (distort *  projectionCoord.w) + projectionCoord.xy | 
|---|
| 44 |   // for ps.1.4 have to re-arrange things a bit to perturb projected texture coordinates | 
|---|
| 45 |  | 
|---|
| 46 | mad r0.xyz, r0_bx2, c0.x, r1 | 
|---|
| 47 |  | 
|---|
| 48 | phase | 
|---|
| 49 |  | 
|---|
| 50 |   // do dependant texture reads | 
|---|
| 51 |   // Cg:        reflectionColour = tex2D(reflectMap, final); | 
|---|
| 52 |   // arbfp1:    TEX R0, R0, texture[1], 2D; | 
|---|
| 53 |   // sampe reflectMap using dependant read : texunit 1  | 
|---|
| 54 |  | 
|---|
| 55 | texld r1, r0.xyz | 
|---|
| 56 |  | 
|---|
| 57 |   // Cg:        refractionColour = tex2D(refractMap, final) + tintColour; | 
|---|
| 58 |   // arbfp1:    TEX R1, R0, texture[2], 2D; | 
|---|
| 59 |   // sample refractMap : texunit 2  | 
|---|
| 60 |  | 
|---|
| 61 | texld r2, r0.xyz | 
|---|
| 62 |  | 
|---|
| 63 |   // adding tintColour that is in global c1 | 
|---|
| 64 |   // arbfp1:    ADD R1, R1, u1; | 
|---|
| 65 |  | 
|---|
| 66 | add r2, r2, c1 | 
|---|
| 67 |  | 
|---|
| 68 |   // Cg:        col = lerp(refractionColour, reflectionColour, fresnel); | 
|---|
| 69 |   // arbfp1:    ADD R0, R0, -R1; | 
|---|
| 70 |   // arbfp1:    MAD result.color, fragment.color.primary.x, R0, R1; | 
|---|
| 71 |  | 
|---|
| 72 | lrp r0, v0.x, r1, r2 | 
|---|