Sign in to follow this  
crshinjin

OpenGL Proper lighting

Recommended Posts

Hi! In my current program I'm having trouble adjusting the light and material properties of some models. The lit models are either too bright or too dark. These "stations" are pretty flat and I guess that makes it harder to have good results without knowing exactly what am I doing. I know some theory about the light components, but hardly anything about OpenGL's way to do these. Some the setting I use:
	float pos[] = {20,80,20,0};
	float amb[] = {0.4f, 0.4f, 0.4f, 1.0f};
	float diff[] = {0.4f, 0.4f, 0.4f, 1.0f};
	float spec[] = {0.1f, 0.1f, 0.1f, 1.0f};
	glClearColor(1.0f,1.0f,1.0f,0.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_LIGHTING);
	glLightfv(GL_LIGHT0, GL_POSITION, pos);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diff);
	glLightfv(GL_LIGHT0, GL_SPECULAR, spec);
	glEnable(GL_LIGHT0);
	// ...
	glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, somcolour);

This is how the program looks like now shinjin

Share this post


Link to post
Share on other sites
That's all I set in the one in the video.

Later I tried adding

glMaterialfv(GL_FRONT, GL_SPECULAR, playercolours[cp]);
glMaterialf(GL_FRONT, GL_SHININESS, 10);


with different shininess values, but didn't really changed a thing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this