This adds an extra shader keyword, ‘when’, which appears at the same level as diffuseMap etc. It takes two parameters: a word describing what condition (purely a convenience for the reader) and the name of another shader. Currently, there are two condition names: ‘unpowered’ and ‘destroyed’.
Which alternative shader is used is set when calling R_AddRefEntityToScene: the code (usually cgame) sets the altShaderIndex member of the parameter to a value in enum altShader_t.
This is implemented and working for (some) MD5 building models, and implemented but untested for MD5 player models.
479db9e Initial support for alternative shaders based on entity state.
src/engine/renderer/tr_animation.c | 6 ++++
src/engine/renderer/tr_local.h | 6 ++++
src/engine/renderer/tr_shader.c | 53 ++++++++++++++++++++++++++++++-
src/engine/renderer/tr_types.h | 10 ++++++
src/engine/rendererGL/tr_animation.c | 6 ++++
src/engine/rendererGL/tr_local.h | 5 +++
src/engine/rendererGL/tr_shader.c | 58 ++++++++++++++++++++++++++++++++--
src/gamelogic/cgame/cg_buildable.c | 11 +++++++
src/gamelogic/cgame/cg_players.c | 22 +++++++++++++
9 files changed, 174 insertions(+), 3 deletions(-)
Upstream: github.com