1
0
forked from 0ad/0ad
0ad/binaries/data/mods/public/shaders/model_common.vp
Ykkrosh d295dacb9b # Add new renderer mode based on GL_ARB_fragment_program.
Change lighting model for new maps to allow better overbrightness.
Cache player colours instead of loading from scripts every time the
renderer wants them.

This was SVN commit r9123.
2011-03-26 20:17:21 +00:00

55 lines
1.7 KiB
Plaintext

!!ARBvp1.0
PARAM sunDir = program.local[0];
PARAM sunColor = program.local[1];
PARAM losTransform = program.local[2];
PARAM shadowTransform[4] = { program.local[3..6] };
TEMP lighting;
//// Compute position and normal:
#ifdef USE_INSTANCING
PARAM instancingTransform[4] = { program.local[7..10] };
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;
//// Texture coordinates:
MOV result.texcoord[0], vertex.texcoord[0];
#ifdef USE_SHADOW
DP4 result.texcoord[1].x, shadowTransform[0], position;
DP4 result.texcoord[1].y, shadowTransform[1], position;
DP4 result.texcoord[1].z, shadowTransform[2], position;
DP4 result.texcoord[1].w, shadowTransform[3], position;
#endif
MAD result.texcoord[2], position.xzzz, losTransform.x, losTransform.y;
END