1#ifdef VERTEX 2 xvs.1.1 3 4 #define vPosition oPos 5 #define vColor oD0 6 #define vTexCoord oT0 7 #define vFog oFog 8#else 9 ps.1.0 10 11 #define vColor v0 12#endif 13 14; attributes 15#define aCoord v0 16#define aNormal v1 17#define aTexCoord v2 18#define aColor v3 19#define aLight v4 20 21; constants 22#define uParam 0 23#define uTexParam 1 24#define uViewProj 2 25#define uBasis 6 26#define uLightProj 70 27#define uMaterial 74 28#define uAmbient 75 29#define uFogParams 81 30#define uViewPos 82 31#define uLightPos 83 32#define uLightColor 87 33#define uRoomSize 91 34#define uCosCoeff 92 35#define uAngles 93 36 37#define ZERO c94.xxxx 38#define HALF c94.yyyy 39#define ONE c94.zzzz 40#define TWO c94.wwww 41#define UW_COLOR c95.xyz 42#define MAX_SHORT c95.wwww 43#define WAVE_SIZE c[uAngles].wwww ; 1 / 1024 44#define WAVE_LUM c[uAngles].zzzz ; 0.75 45 46#define tmp r8 47 48#define mulMat(dst, src, matrix) \ 49 mul tmp, c[matrix + 0], src.x \ 50 mad tmp, src.y, c[matrix + 1], tmp \ 51 mad tmp, src.z, c[matrix + 2], tmp \ 52 mad dst, src.w, c[matrix + 3], tmp 53 54#define mulQuat(dst, src, joint) \ 55 mul dst.xyz, c[uBasis + joint], src.zxyw \ 56 mad dst.xyz, src, c[uBasis + joint].zxyw, -dst \ 57 mad dst.xyz, src.yzxw, c[uBasis + joint].w, dst \ 58 mul tmp.xyz, c[uBasis + joint].zxyw, dst \ 59 mad dst.xyz, dst.yzxw, c[uBasis + joint].yzxw, -tmp \ 60 mad dst.xyz, dst, TWO, src \ 61 mov dst.w, ONE 62 63#define mulQuatPos(dst, src, joint) \ 64 mul dst.xyz, c[uBasis + joint], src.zxyw \ 65 mad dst.xyz, src, c[uBasis + joint].zxyw, -dst \ 66 mad dst.xyz, src.yzxw, c[uBasis + joint].w, dst \ 67 mul tmp.xyz, c[uBasis + joint].zxyw, dst \ 68 mad dst.xyz, dst.yzxw, c[uBasis + joint].yzxw, -tmp \ 69 mad dst.xyz, dst, TWO, src \ 70 add dst.xyz, c[uBasis + joint + 1], dst \ 71 mov dst.w, c[uBasis + joint + 1].w 72 73#define reflect(dst, a, b) \ 74 dp3 tmp.x, a, b \ 75 add tmp.x, tmp.x, tmp.x \ 76 mad dst, -tmp.xxxx, b, a 77 78#define normalize(v) \ 79 dp3 tmp.x, v, v \ 80 rsq tmp.x, tmp.x \ 81 mul v, v, tmp.xxxx 82 83#define applyFog(dst, src) \ 84 add tmp.xyz, c[uViewPos].xyz, -src.xyz \ 85 mul tmp.xyz, tmp.xyz, c[uFogParams].www \ 86 dp3 tmp.x, tmp.xyz, tmp.xyz \ 87 rsq tmp.x, tmp.x \ 88 rcp dst.x, tmp.x 89 90#define encodeColor(v) \ 91 mul vColor, v, HALF 92 93#define applyColor(dst, src) \ 94 mul dst, src, vColor \ 95 add dst, dst, dst \ 96 add dst, dst, dst 97 98#define cos(dst, ang) \ 99 mad dst.x, ang, c[uAngles].y, c[uAngles].x \ 100 expp dst.yw, dst.xxxx \ 101 add dst.x, dst.y, -c[uAngles].x \ 102 mul dst, dst.wwxx, dst.wxxx \ 103 mul dst.w, dst.w, dst.y \ 104 mul dst, dst, dst \ 105 dp4 dst.x, dst, c[uCosCoeff] 106 107#ifdef UNDERWATER 108 #define applyUnderwater(dst, pos) \ 109 dp3 tmp.x, pos, WAVE_SIZE \ 110 add tmp.x, tmp.x, c[uParam].x \ 111 cos(tmp, tmp.x) \ 112 max tmp.x, tmp.x, -tmp.x \ 113 mul tmp.x, tmp.x, WAVE_LUM \ 114 add tmp.x, tmp.x, HALF \ 115 mul dst.xyz, dst.xyz, tmp.xxx \ 116 mul dst.xyz, dst.xyz, UW_COLOR 117 118#else 119 #define applyUnderwater(dst, pos) 120#endif 121