Lights again

Started by
40 comments, last by Dtag 21 years, 2 months ago
I showed you the settings of the light before. The light is a static location which is out on the yard. So why are you not surprised by this behaviour of the light?
Advertisement
Could you please give an idea of the world dimensions, in OpenGL units ? For instance, what is the height of a character, approximatively ?
Y Size: ~2400
X Size: ~1000
Z: Dunno like 250 maybe? No idea

Character Height: 64
Character Width: 32
Ok, so you would like your spotlight to be around the middle of the scene, and pointing down. Ang this light would be unique (no other light). Am I right ?
Nope its neither a spotlight nor is it pointing down. Its a point light initialized in the X Middle, Upper Y area. ( Yard )
Oh, you''re telling me that it''s a point light and it also should be unique ? Now I understand your fears.

If you could post the rendering code that sets up the light (with few lines before and after) that would help for sure.
int i=0;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


glPushMatrix();
ApplyVelocity(); // Applies the vel to display objects

m_pCamera->Apply(); // Sets up the camera


glEnable( GL_LIGHTING );

GLfloat light1_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
GLfloat light1_diffuse[] = { 1.0, 0.0, 0.0, 1.0 };
GLfloat light1_specular[] = { 1.0, 1.0, 1.0, 1.0 };

GLfloat light1_position[] = { 714.0, 1991.0, 50.0, 1.0 };
GLfloat light1_dir[] = { 714.0, 1991.0, 49.0};

glLightfv(GL_LIGHT0, GL_AMBIENT, light1_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light1_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light1_position);


glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 1.5);

glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180.0);
glLighti(GL_LIGHT0, GL_SPOT_EXPONENT, 250);

glLightModelfv(GL_LIGHT_MODEL_AMBIENT,light1_ambient);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);


glEnable( GL_LIGHT0 );
glEnable(GL_COLOR_MATERIAL);


// Rest of rendering
ok, a few thoughts :

- do you know if the models define normals ? It looks like no normal is given into the pipeline, thus resulting in uniform and weird lighting like that.
- do you know if models are emissive ?
- why do you call glLight with LIGHT1 when setting QUADRATIC_ATTENUATION. Is it a typo error when copying the code to the post, or is it like that in your source code too ?
- it''s not allowed to set a SPOT_EXPONENT out of the range [0,128]. If you want the highest exponent, set either 127 or 128 (I recommend 127 because of floating point precision and because you almost won''t notice the difference with 128).
- you should trying disabling LIGHT0 (but enable LIGHTING) and see what is the light contribution when all lights are off : in fact, you''ll see how much light model and emission contribute.
- are you sure that no piece of code enables/disables LIGHTING ? (for instance, if the 3D models are rendered using an external library, are you sure that this external library does not call glEnable/Disable with LIGHTING) ?
1. Dunno. I just load them from the MD3 files. How can I find that out?
2. I dunno that either. Same reason as above
3. Its an outcommented line which shouldnt be in the code actually.
4. I tried everything that doesnt change the lights behaviour
6. The scene gets very very dark and you can barely see anything
7. Yep im sure this is the only place i mess with lighting
You can know if normals are sent or not if you look at the code that renders the models. Is it a rendering source code that you''ve copied (or written), or is it an external library you''re using ?

This topic is closed to new replies.

Advertisement