2011-03-26 21:17:21 +01:00
|
|
|
!!ARBvp1.0
|
|
|
|
PARAM sunColor = program.local[0];
|
2012-01-22 19:20:33 +01:00
|
|
|
PARAM textureTransform = program.local[1];
|
|
|
|
PARAM losTransform = program.local[2];
|
|
|
|
PARAM shadowTransform[4] = { program.local[3..6] };
|
2011-03-26 21:17:21 +01:00
|
|
|
|
2012-05-21 21:23:14 +02:00
|
|
|
#if USE_FP_SHADOW && USE_SHADOW_PCF
|
|
|
|
PARAM shadowScale = program.local[7];
|
|
|
|
#endif
|
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
TEMP lighting;
|
|
|
|
|
|
|
|
//// Compute position and normal:
|
|
|
|
|
|
|
|
ATTRIB position = vertex.position;
|
|
|
|
|
|
|
|
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 is precomputed in vertex attribute
|
|
|
|
// Scale diffuse to allow overbrightness (since result.color will be clamped to [0, 1])
|
|
|
|
MUL lighting, vertex.color, 0.5;
|
|
|
|
// Apply light colour
|
|
|
|
MUL result.color, lighting, sunColor;
|
|
|
|
|
|
|
|
//// Texture coordinates:
|
|
|
|
|
2012-04-10 22:55:01 +02:00
|
|
|
#if DECAL
|
2012-01-22 19:20:33 +01:00
|
|
|
MOV result.texcoord[0], vertex.texcoord[0];
|
|
|
|
#else
|
|
|
|
// Compute texcoords from position and terrain-texture-dependent transform.
|
|
|
|
// textureTransform is stored as [c, -s, s, 0],
|
|
|
|
// and we want texcoord = (x*c + z*-s, x*-s + z*-c, 0, 1)
|
|
|
|
DP3 result.texcoord[0].x, textureTransform.xyww, position.xzww;
|
|
|
|
DP3 result.texcoord[0].y, -textureTransform.zxww, position.xzww;
|
|
|
|
MOV result.texcoord[0].z, 0;
|
|
|
|
MOV result.texcoord[0].w, 1;
|
|
|
|
#endif
|
2011-03-26 21:17:21 +01:00
|
|
|
|
2012-04-10 22:55:01 +02:00
|
|
|
#if BLEND
|
2011-03-26 21:17:21 +01:00
|
|
|
MOV result.texcoord[1], vertex.texcoord[1];
|
|
|
|
#endif
|
|
|
|
|
2012-04-10 22:55:01 +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 result.texcoord[2].xy, shadowtc, shadowScale;
|
|
|
|
#else
|
|
|
|
DP4 result.texcoord[2].x, shadowTransform[0], position;
|
|
|
|
DP4 result.texcoord[2].y, shadowTransform[1], position;
|
|
|
|
#endif
|
2011-03-26 21:17:21 +01:00
|
|
|
DP4 result.texcoord[2].z, shadowTransform[2], position;
|
|
|
|
DP4 result.texcoord[2].w, shadowTransform[3], position;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
MAD result.texcoord[3], position.xzzz, losTransform.x, losTransform.y;
|
|
|
|
|
|
|
|
END
|