Permalink
Browse files

Remove materials support from the game. This never worked well, and is

not supported in OpenGL ES 2 and above.
  • Loading branch information...
perim committed Sep 1, 2013
1 parent d0273b7 commit 823cf08bb18cf24852bac8595b3899aca12d4f7b
Showing with 18 additions and 40 deletions.
  1. +13 −12 data/base/shaders/tcmask.frag
  2. +0 −15 lib/ivis_opengl/imd.cpp
  3. +5 −6 lib/ivis_opengl/imdload.cpp
  4. +0 −2 lib/ivis_opengl/ivisdef.h
  5. +0 −5 lib/ivis_opengl/piedraw.cpp
@@ -4,29 +4,30 @@
varying float vertexDistance;
varying vec3 normal, lightDir, eyeVec;
-uniform sampler2D Texture0;
-uniform sampler2D Texture1;
-uniform sampler2D Texture2;
-uniform vec4 teamcolour;
-uniform int tcmask, normalmap;
-uniform int fogEnabled;
-uniform bool ecmEffect;
-uniform float graphicsCycle;
+uniform sampler2D Texture0; // diffuse
+uniform sampler2D Texture1; // tcmask
+uniform sampler2D Texture2; // normal map
+uniform vec4 teamcolour; // the team colour of the model
+uniform int tcmask; // whether a tcmask texture exists for the model
+uniform int normalmap; // whether a normal map exists for the model
+uniform int fogEnabled; // whether fog is enabled
+uniform bool ecmEffect; // whether ECM special effect is enabled
+uniform float graphicsCycle; // a periodically cycling value for special effects
void main(void)
{
vec4 mask, colour;
- vec4 light = (gl_FrontLightModelProduct.sceneColor * gl_FrontMaterial.ambient) + (gl_LightSource[0].ambient * gl_FrontMaterial.ambient);
+ vec4 light = gl_FrontLightModelProduct.sceneColor + gl_LightSource[0].ambient;
vec3 N = normalize(normal);
vec3 L = normalize(lightDir);
float lambertTerm = dot(N, L);
if (lambertTerm > 0.0)
{
- light += gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse * lambertTerm;
+ light += gl_LightSource[0].diffuse * lambertTerm;
vec3 E = normalize(eyeVec);
vec3 R = reflect(-L, N);
- float specular = pow(max(dot(R, E), 0.0), gl_FrontMaterial.shininess);
- light += gl_LightSource[0].specular * gl_FrontMaterial.specular * specular;
+ float specular = pow(max(dot(R, E), 0.0), 10); // 10 is an arbitrary value for now
+ light += gl_LightSource[0].specular * specular;
}
// Get color from texture unit 0, merge with lighting
View
@@ -38,21 +38,6 @@ iIMDShape::iIMDShape()
tcmaskpage = iV_TEX_INVALID;
normalpage = iV_TEX_INVALID;
numFrames = 0;
- memset(material, 0, sizeof(material));
- // Set default values
- material[LIGHT_AMBIENT][0] = 1.0f;
- material[LIGHT_AMBIENT][1] = 1.0f;
- material[LIGHT_AMBIENT][2] = 1.0f;
- material[LIGHT_DIFFUSE][0] = 1.0f;
- material[LIGHT_DIFFUSE][1] = 1.0f;
- material[LIGHT_DIFFUSE][2] = 1.0f;
- material[LIGHT_SPECULAR][0] = 1.0f;
- material[LIGHT_SPECULAR][1] = 1.0f;
- material[LIGHT_SPECULAR][2] = 1.0f;
- shininess = 10;
- material[LIGHT_AMBIENT][3] = 1.0f;
- material[LIGHT_DIFFUSE][3] = 1.0f;
- material[LIGHT_SPECULAR][3] = 1.0f;
}
//*************************************************************************
@@ -534,27 +534,26 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE
char buffer[PATH_MAX] = {'\0'};
int cnt = 0, n = 0, i;
iIMDShape *s = NULL;
+ float dummy;
if (nlevels == 0)
{
return NULL;
}
- // Load optional MATERIALS directive
pTmp = pFileData; // remember position
i = sscanf(pFileData, "%255s %n", buffer, &cnt);
ASSERT_OR_RETURN(NULL, i == 1, "Bad directive following LEVEL");
s = new iIMDShape;
+ // Optionally load and ignore deprecated MATERIALS directive
if (strcmp(buffer, "MATERIALS") == 0)
{
- i = sscanf(pFileData, "%255s %f %f %f %f %f %f %f %f %f %f%n", buffer,
- &s->material[LIGHT_AMBIENT][0], &s->material[LIGHT_AMBIENT][1], &s->material[LIGHT_AMBIENT][2],
- &s->material[LIGHT_DIFFUSE][0], &s->material[LIGHT_DIFFUSE][1], &s->material[LIGHT_DIFFUSE][2],
- &s->material[LIGHT_SPECULAR][0], &s->material[LIGHT_SPECULAR][1], &s->material[LIGHT_SPECULAR][2],
- &s->shininess, &cnt);
+ i = sscanf(pFileData, "%255s %f %f %f %f %f %f %f %f %f %f%n", buffer, &dummy, &dummy, &dummy, &dummy,
+ &dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &cnt);
ASSERT_OR_RETURN(NULL, i == 11, "Bad MATERIALS directive");
+ debug(LOG_WARNING, "MATERIALS directive no longer supported!");
pFileData += cnt;
}
else // use defaults
@@ -110,8 +110,6 @@ struct iIMDShape
unsigned int nShadowEdges;
EDGE *shadowEdgeList;
- float material[LIGHT_MAX][4];
- float shininess;
// The old rendering data
unsigned int npoints;
@@ -217,11 +217,6 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
if (light)
{
- glMaterialfv(GL_FRONT, GL_AMBIENT, shape->material[LIGHT_AMBIENT]);
- glMaterialfv(GL_FRONT, GL_DIFFUSE, shape->material[LIGHT_DIFFUSE]);
- glMaterialfv(GL_FRONT, GL_SPECULAR, shape->material[LIGHT_SPECULAR]);
- glMaterialf(GL_FRONT, GL_SHININESS, shape->shininess);
- glMaterialfv(GL_FRONT, GL_EMISSION, shape->material[LIGHT_EMISSIVE]);
pie_ActivateShader(SHADER_COMPONENT, shape, teamcolour, colour);
}
else

0 comments on commit 823cf08

Please sign in to comment.