2011-03-26 21:17:21 +01:00
|
|
|
!!ARBvp1.0
|
2012-04-08 17:55:06 +02:00
|
|
|
|
|
|
|
PARAM cameraPos = program.local[0];
|
|
|
|
PARAM sunDir = program.local[1];
|
|
|
|
PARAM sunColor = program.local[2];
|
|
|
|
PARAM losTransform = program.local[3];
|
|
|
|
PARAM shadowTransform[4] = { program.local[4..7] };
|
|
|
|
#if USE_INSTANCING
|
|
|
|
PARAM instancingTransform[4] = { program.local[8..11] };
|
|
|
|
#endif
|
|
|
|
|
2012-05-21 21:23:14 +02:00
|
|
|
#if USE_FP_SHADOW && USE_SHADOW_PCF
|
|
|
|
PARAM shadowScale = program.local[12];
|
|
|
|
#endif
|
|
|
|
|
2012-04-08 17:55:06 +02:00
|
|
|
TEMP temp;
|
2011-03-26 21:17:21 +01:00
|
|
|
TEMP lighting;
|
|
|
|
|
2012-04-08 17:55:06 +02:00
|
|
|
OUTPUT v_tex = result.texcoord[0];
|
|
|
|
OUTPUT v_shadow = result.texcoord[1];
|
|
|
|
OUTPUT v_los = result.texcoord[2];
|
|
|
|
#if USE_SPECULAR
|
|
|
|
OUTPUT v_normal = result.texcoord[3];
|
|
|
|
OUTPUT v_half = result.texcoord[4];
|
|
|
|
#endif
|
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
//// Compute position and normal:
|
|
|
|
|
2012-04-08 17:55:06 +02:00
|
|
|
#if USE_INSTANCING
|
2011-03-26 21:17:21 +01:00
|
|
|
TEMP position;
|
|
|
|
TEMP normal;
|
|
|
|
DP4 position.x, instancingTransform[0], vertex.position;
|
|
|
|
DP4 position.y, instancingTransform[1], vertex.position;
|
|
|
|
DP4 position.z, instancingTransform[2], vertex.position;
|
|
|
|
MOV position.w, 1.0;
|
|
|
|
DP3 normal.x, instancingTransform[0], vertex.normal;
|
|
|
|
DP3 normal.y, instancingTransform[1], vertex.normal;
|
|
|
|
DP3 normal.z, instancingTransform[2], vertex.normal;
|
|
|
|
#else
|
|
|
|
ATTRIB position = vertex.position;
|
|
|
|
ATTRIB normal = vertex.normal;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DP4 result.position.x, state.matrix.mvp.row[0], position;
|
|
|
|
DP4 result.position.y, state.matrix.mvp.row[1], position;
|
|
|
|
DP4 result.position.z, state.matrix.mvp.row[2], position;
|
|
|
|
DP4 result.position.w, state.matrix.mvp.row[3], position;
|
|
|
|
|
|
|
|
//// Compute lighting:
|
|
|
|
|
|
|
|
// Diffuse factor
|
|
|
|
DP3 lighting, normal, -sunDir;
|
|
|
|
MAX lighting, 0.0, lighting;
|
|
|
|
// Scale diffuse to allow overbrightness (since result.color will be clamped to [0, 1])
|
|
|
|
MUL lighting, lighting, 0.5;
|
|
|
|
// Apply light colour
|
|
|
|
MUL result.color, lighting, sunColor;
|
|
|
|
|
2012-04-08 17:55:06 +02:00
|
|
|
#if USE_SPECULAR
|
|
|
|
// eyeVec = normalize(cameraPos - position);
|
|
|
|
TEMP eyeVec;
|
|
|
|
SUB eyeVec.xyz, cameraPos, position;
|
|
|
|
DP3 eyeVec.w, eyeVec, eyeVec;
|
|
|
|
RSQ eyeVec.w, eyeVec.w;
|
|
|
|
MUL eyeVec.xyz, eyeVec, eyeVec.w;
|
|
|
|
|
|
|
|
// v_half = normalize(-sunDir + eyeVec);
|
|
|
|
TEMP half;
|
|
|
|
SUB half.xyz, eyeVec, sunDir;
|
|
|
|
DP3 half.w, half, half;
|
|
|
|
RSQ half.w, half.w;
|
|
|
|
MUL v_half.xyz, half, half.w;
|
|
|
|
|
|
|
|
MOV v_normal, normal;
|
|
|
|
#endif
|
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
//// Texture coordinates:
|
|
|
|
|
2012-04-08 17:55:06 +02:00
|
|
|
MOV v_tex, vertex.texcoord[0];
|
2011-03-26 21:17:21 +01:00
|
|
|
|
2012-04-08 17:55:06 +02:00
|
|
|
#if USE_SHADOW
|
2012-05-21 21:23:14 +02:00
|
|
|
#if USE_FP_SHADOW && USE_SHADOW_PCF
|
|
|
|
TEMP shadowtc;
|
|
|
|
DP4 shadowtc.x, shadowTransform[0], position;
|
|
|
|
DP4 shadowtc.y, shadowTransform[1], position;
|
|
|
|
MUL v_shadow.xy, shadowtc, shadowScale;
|
|
|
|
#else
|
|
|
|
DP4 v_shadow.x, shadowTransform[0], position;
|
|
|
|
DP4 v_shadow.y, shadowTransform[1], position;
|
|
|
|
#endif
|
2012-04-08 17:55:06 +02:00
|
|
|
DP4 v_shadow.z, shadowTransform[2], position;
|
|
|
|
DP4 v_shadow.w, shadowTransform[3], position;
|
2011-03-26 21:17:21 +01:00
|
|
|
#endif
|
|
|
|
|
2012-04-08 17:55:06 +02:00
|
|
|
MAD v_los, position.xzzz, losTransform.x, losTransform.y;
|
2011-03-26 21:17:21 +01:00
|
|
|
|
|
|
|
END
|