xvs.1.1 ; Shader for a three bone matrix palette system with up to 60 bones ; lit by a single directional light and ambient color ; Data is in two streams. One for position, normal, and texture. The other for indices and weights ; Uses all 190 constant registers. Matrix indices are tweaked to avoid -37 and -38 ; ; v0 = position ; v1 = normals ; v2 = texture coords ; v3 = matrix indices ; v4 = weights ; ; c92-c96 = world*view*projection matrix ; ; c-96+ = bone matrices ; #define V_POSITION v0 #define V_NORMAL v1 #define V_TEXTURE v2 #define V_BONEINDEX v3 #define V_BONEWEIGHTS v4 #define V_S v5 #define V_T v6 #define V_SxT v7 #define S_WORLD r0 #define T_WORLD r1 #define SxT_WORLD r9 #define LIGHT_LOCAL r3 #define R_EYE_VECTOR r8 #define R_WORLDSPACE_NORMAL r9 #define R_WORLDSPACE_NORMAL_REFRACT r6 #define R_DIFFUSE_COLOR r9 #define R_GOURAUD_SHADE r7 #define R_NDOTE r4 #define R_NDOTN r5 #define R_TEMP r1 #define SHADER_WORLD_LIGHTDIR1_REGISTER 78 #define SHADER_WORLD_EYEPOS 79 #define SHADER_WORLD_TRANS 80 #define SHADER_ZERO_REGISTER 83 #define SHADER_LIGHTDIR1_REGISTER 84 #define SHADER_LIGHTCOL1_REGISTER 85 #define SHADER_LIGHTDIR2_REGISTER 86 #define SHADER_LIGHTCOL2_REGISTER 87 #define SHADER_LIGHTDIR3_REGISTER 88 #define SHADER_LIGHTCOL3_REGISTER 89 #define SHADER_AMBIENTLIGHT_REGISTER 90 #define SHADER_MATERIAL_REGISTER 91 #define SHADER_TRANSFORM_REGISTER 92 ; First bone mov a0.x, V_BONEINDEX.x mul r2, V_BONEWEIGHTS.x, c[a0.x+0] mul r3, V_BONEWEIGHTS.x, c[a0.x+1] mul r4, V_BONEWEIGHTS.x, c[a0.x+2] ; Second bone mov a0.x, V_BONEINDEX.y mad r2, V_BONEWEIGHTS.y, c[a0.x+0], r2 mad r3, V_BONEWEIGHTS.y, c[a0.x+1], r3 mad r4, V_BONEWEIGHTS.y, c[a0.x+2], r4 ; Third bone mov a0.x, V_BONEINDEX.z mad r2, V_BONEWEIGHTS.z, c[a0.x+0], r2 mad r3, V_BONEWEIGHTS.z, c[a0.x+1], r3 mad r4, V_BONEWEIGHTS.z, c[a0.x+2], r4 ; Transform weighted position dp4 r0.x, V_POSITION, r2 dp4 r0.y, V_POSITION, r3 dp4 r0.z, V_POSITION, r4 ; Rotate weighted normal dp3 R_WORLDSPACE_NORMAL.x, V_NORMAL, r2 dp3 R_WORLDSPACE_NORMAL.y, V_NORMAL, r3 dp3 R_WORLDSPACE_NORMAL.z, V_NORMAL, r4 dp3 r2, R_WORLDSPACE_NORMAL, c[SHADER_LIGHTDIR1_REGISTER] ; light1 dotted with normal min r3, r2,c[SHADER_ZERO_REGISTER].x ; -1 to 0 mul r2, r3, c[SHADER_ZERO_REGISTER].z slt r1, r2, c[SHADER_ZERO_REGISTER].x mad r2, r1, -c[SHADER_LIGHTDIR1_REGISTER], r0.xyz ; World, view, projection dph oPos.x, r2, c[92] dph oPos.y, r2, c[93] dph oPos.z, r2, c[94] dph oPos.w, r2, c[95]