+// this enum is multiplied by SHADERPERMUTATION_MODEBASE
+typedef enum shadermode_e
+{
+ SHADERMODE_FLATCOLOR, // (lightmap) modulate texture by uniform color (q1bsp, q3bsp)
+ SHADERMODE_VERTEXCOLOR, // (lightmap) modulate texture by vertex colors (q3bsp)
+ SHADERMODE_LIGHTMAP, // (lightmap) modulate texture by lightmap texture (q1bsp, q3bsp)
+ SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE, // (lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp deluxemap)
+ SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE, // (lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp deluxemap)
+ SHADERMODE_LIGHTDIRECTION, // (lightmap) use directional pixel shading from fixed light direction (q3bsp)
+ SHADERMODE_LIGHTSOURCE, // (lightsource) use directional pixel shading from light source (rtlight)
+ SHADERMODE_REFRACTION, // refract background (the material is rendered normally after this pass)
+ SHADERMODE_WATER, // refract background and reflection (the material is rendered normally after this pass)
+ SHADERMODE_COUNT
+}
+shadermode_t;
+
+// NOTE: MUST MATCH ORDER OF SHADERMODE_* ENUMS!
+shadermodeinfo_t shadermodeinfo[SHADERMODE_COUNT] =
+{
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_FLATCOLOR\n", " flatcolor"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_VERTEXCOLOR\n", " vertexcolor"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTMAP\n", " lightmap"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTSOURCE\n", " lightsource"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_REFRACTION\n", " refraction"},
+ {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_WATER\n", " water"},
+};
+
+typedef struct r_glsl_permutation_s
+{
+ // indicates if we have tried compiling this permutation already
+ qboolean compiled;
+ // 0 if compilation failed
+ int program;
+ // locations of detected uniforms in program object, or -1 if not found
+ int loc_Texture_Normal;
+ int loc_Texture_Color;
+ int loc_Texture_Gloss;
+ int loc_Texture_Glow;
+ int loc_Texture_SecondaryNormal;
+ int loc_Texture_SecondaryColor;
+ int loc_Texture_SecondaryGloss;
+ int loc_Texture_SecondaryGlow;
+ int loc_Texture_Pants;
+ int loc_Texture_Shirt;
+ int loc_Texture_FogMask;
+ int loc_Texture_Lightmap;
+ int loc_Texture_Deluxemap;
+ int loc_Texture_Attenuation;
+ int loc_Texture_Cube;
+ int loc_Texture_Refraction;
+ int loc_Texture_Reflection;
+ int loc_FogColor;
+ int loc_LightPosition;
+ int loc_EyePosition;
+ int loc_Color_Pants;
+ int loc_Color_Shirt;
+ int loc_FogRangeRecip;
+ int loc_AmbientScale;
+ int loc_DiffuseScale;
+ int loc_SpecularScale;
+ int loc_SpecularPower;
+ int loc_GlowScale;
+ int loc_SceneBrightness; // or: Scenebrightness * ContrastBoost
+ int loc_OffsetMapping_Scale;
+ int loc_TintColor;
+ int loc_AmbientColor;
+ int loc_DiffuseColor;
+ int loc_SpecularColor;
+ int loc_LightDir;
+ int loc_ContrastBoostCoeff; // 1 - 1/ContrastBoost
+ int loc_DistortScaleRefractReflect;
+ int loc_ScreenScaleRefractReflect;
+ int loc_ScreenCenterRefractReflect;
+ int loc_RefractColor;
+ int loc_ReflectColor;
+ int loc_ReflectFactor;
+ int loc_ReflectOffset;
+}
+r_glsl_permutation_t;
+
+// information about each possible shader permutation
+r_glsl_permutation_t r_glsl_permutations[SHADERMODE_COUNT][SHADERPERMUTATION_LIMIT];
+// currently selected permutation
+r_glsl_permutation_t *r_glsl_permutation;
+
+static char *R_GLSL_GetText(const char *filename, qboolean printfromdisknotice)