I’m rendering a nice looking car in my app and want it to look like the light is shining off the bodywork and windows (I’m not really interested in true reflections), I have played around with this but can’t get any results.
Can someone please tell me the steps I should use to get this kind of effect.


You can blend a texture (representing a sky for example) over the reflective parts using sphere mapping.
To obtain good results you need a good number of faces.


Is their no way to achieve this using the material and lighting settings?
I only want it to look kind of shiny using the easiest method.

I assumed GL_SHININESS would do something like what I want, but I cant get any results.

GL_SHININESS only controls how big the specular point should be. You should be able to se the difference when you change from 1 to 40 to 128 but only if you have set specular color in the material to something else than 0,0,0 that is the default… (white should be fine)

but to get reflection of the enviroonment (needed to get a real looking reflective material, like chrome objects and stuff) just apply spheremapping or reflectionmapping(cubemaps)


I’m also using shine stuff in my model with sphere mapping, but would you happend to know how to ‘move’ the shine texture over my model witehout using glTranslate ot glRotate?
By that I mean the effect that was in Kingpin if you can remember: when you just looked around the weapon shined nicely.

To get a good result with OpenGL’s lighting system, you also need to tesselate your object into faily small triangles. This is because OpenGL calculate lighting per vertex, and not per pixel. The larger the shininess, the smaller the highlight, and the more you need to tesselate your object. If you can’t tesselate your object as much as needed, a reflection texture is a very good solution.

i dont really want the scenery to be reflected in the car. I just want it to look like the light is shining on a matt object. what i really would like is for the spots that would reflect the light directly to the camera to look brighter than the rest of the car.

the if you have a high tessellated object, specular would to it, else, you can do a map with a white dot on it ( white to black gradient from the middle and out) to simulate the light and get more accurat result.


And to just move the light, rotate the texture matrix of the textureunit holding the light texture

[This message has been edited by Mazy (edited 05-14-2002).]

I have not experimented with tessellated objects and have no idea what they are.
My car has around 5000 polys (I think they are all triangles but my app can deal with any number of points for a face) and a texture applied from one 32 bit TGA (for windows) and one 24 bit TGA for the rest of the car. At the moment my windows are completely transparent and I would like the light to shine on the windows when the angle is correct. Can this be done easly?

If you want bright highlights on your objects, has a tutorial on specular lighting… and its quite easy! That might be what you want.

Thanks Tazar, that’s exactly what I wanted. Still more questions though. In the code the light settings are not set (I could only find glEnable(GL_LIGHT0) and glEnable(GL_LIGHTING).
Do you have to use and special settings for this to work.
Here is what I have so far:

glColorMaterial(GL_FRONT, GL_SPECULAR);
GLfloat LightAmbient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, LightDiffuse);
glLightfv(GL_LIGHT1, GL_SHININESS, LightDiffuse);

//drawing routine
GLfloat specularColor[3] = {1.0, 1.0, 1.0};
float g_Shine = 50.0;

glBindTexture(GL_TEXTURE_2D, texture[textureNumber]);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularColor);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, &g_Shine);

glColor3ub(255, 255, 255);


	for(int a=0; a<numVects; a++)
		glNormal3d(Normal[a].x, Normal[a].y, Normal[a].z);
		glTexCoord2f(TexCoords[a].x, TexCoords[a].y);
		glVertex3d(Vects[a].x, Vects[a].y, Vects[a].z);


this is pretty much how it is in the example code but I still don’t get the quote “intense white light created on shiny objects, like metalic surfaces”

Am I missing something?


Hi, yes, your car is textured so it wont work because OpenGL doesnt apply specular highlights after you map the texture. Its in the FAQ under the Texture section. Its really easy to fix though, just call

#ifdef GL_EXT_separate_specular_color

Ofcourse you want to test to make sure the extension is supported.

Ahh, good call OldGLman.

Also, I don’t think this is a valid light parameter, so you can probably remove this:

glLightfv(GL_LIGHT1, GL_SHININESS, LightDiffuse);

[This message has been edited by yakuza (edited 05-14-2002).]

As OLD OGLman said specular lights dont apply to textures directly…
But this is a way around this…

First you have to draw your scene without texture to get the specular highlight and another time to get the final result… Then you blend them… All of these sounds like a huge overhead…

So, you could have something like this…

glLightModelxx( GL_LIGHT_MODEL_AMBIENT, color );

glLightxx( GL_LIGHT0, GL_DIFFUSE, color );
glLightxx( GL_LIGHT0, GL_SPECULAR, color );
glLightxx( GL_LIGHT0, GL_POSITION, position );

glMaterialxx( GL_FRONT, GL_AMBIENT, color );
glMaterialxx( GL_FRONT, GL_DIFFUSE, color );
glMaterialxx( GL_FRONT, GL_SPECULAR, color );
glMaterialxx( GL_FRONT, GL_SHINENESS, 128 );

glColorxx( color );

//your polygons…

glRectangle(); // I dont know, something.

glBlendFunc(GL_ONE, GL_ONE);

glLightxx( GL_LIGHT0, GL_AMBIENT, normal );
glLightxx( GL_LIGHT0, GL_DIFFUSE, normal );
glLightxx( GL_LIGHT0, GL_SPECULAR, color );

glMaterialxx( GL_FRONT, GL_AMBIENT, normal );
glMaterialxx( GL_FRONT, GL_DIFFUSE, normal );
glMaterialxx( GL_FRONT, GL_SPECULAR, color );
glMaterialxx( GL_FRONT, GL_SHINENESS, 0 );

//You polygons again…

I hope this helps… I am not saying this is optimal either. But it is an idea.

Hi, yeah you can do a two pass technique like above also, its entirely preference. You should always try to avoid the use of extensions if there is another way though.

Old GLman

You may disappointed with specular highlights. Research how to do “environment mapping”.

Thanks Old GLman and yakuza.

I added the
#ifdef GL_EXT_separate_specular_color
bit as suggested but my code skips that bit (I assume the extension is not supported). What do I need to do to make it work?

Are you doing a check anywhere to define GL_EXT_seperate_specular_color as true if your card supports it? I have an InitExtensions() routine that checks all extensions returned from glGetString(GL_EXTENSIONS).

If you are doing that, what video card are you using?