/* oPos = Local2World * World2Camera * Position(v0) oD0 = Color0(v1) oD1 = Color1(v2) oT0 = UV(v3) oT1 = UV(v3) */ #pragma screenspace #define IN_XYZ v0 #define IN_NORMAL v1 #define IN_UV v2 #define IN_RGBA0 v3 #define IN_RGBA1 v4 #define IN_SKIN_INDEX v3 #define IN_SKIN_WEIGHT v4 #define C_TM_LOCAL2WORLD c0 #define C_TM_WORLD2SCREEN c4 #define C_V_CAMERA_POSITION c8 #define C_V_LIGHT_DIRECTION c9 // fog #define C_F_FOG_NEAR c10.x #define C_F_FOG_INV_FAR_SUB_NEAR c10.y #define C_F_FOG_MIN c10.z #define C_F_FOG_MAX_SUB_MIN c10.w #define C_F_FOG_FAR c11.x #define C_F_FOG_MAX c11.y // const #define C_F_0 c11.z #define C_F_05 c11.w // UV' scrool #define C_UV_SCROLL_UV c12.xy #define C_UV_SCROLL_U c12.x #define C_UV_SCROLL_V c12.y // opacity #define C_OPACITY c12.z #define C_F_1 c12.w // OFFSET & SCALE #define C_V_PROJECTION_OFFSET c13 #define C_V_PROJECTION_SCALE c14 // MODEL ORIGIN #define C_V_MODEL_ORIGIN c15 #define C_V_SHADOW_SCALE c15.w // VERTEX DECOMPRESSION #define C_V_POS_SCALE c19 #define C_V_POS_ADD c20 #define C_V_UV_SCALE c21 #define C_V_UV_ADD c22 xvs.1.1 // decompress mul r2, IN_XYZ, C_V_POS_SCALE add r2, r2, C_V_POS_ADD // (R0) position m4x4 r0, r2, C_TM_LOCAL2WORLD // shadow attenuation // r8 = distance(origin,vertex) sub r8, r0, C_V_MODEL_ORIGIN mul r8.w, r8.x, r8.x mad r8.w, r8.z, r8.z, r8.w rsq r8.w, r8.w rcp r8.w, r8.w // attn = 1-(dist*scale-min)/(max-min) // min =0, max = 1, therefore attn = 1-dist*scale. clamped mul r8.w, r8.w, C_V_SHADOW_SCALE sub r9.x, C_F_1, r8.w min r9.x, r9.x, C_F_1 max r9.x, r9.x, C_F_0 mul r9.x, r9.x, C_F_05 // color mov oD0.xyzw, r9.xxxx // oPos m4x4 oPos, r0, C_TM_WORLD2SCREEN // offset and scale mul oPos.xyz, r12, C_V_PROJECTION_SCALE // scale rcc r1.x, r12.w // compute 1/w mad oPos.xyz, r12, r1.x, C_V_PROJECTION_OFFSET // scale by 1/w, add offset