Jump to content
  • Advertisement
Sign in to follow this  
3dnewbie

lighting, shadows and normals

This topic is 4336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, A few questions. If you setup lighting, isn't setting up shadows (for example with stencil buffer) redundant? Or are those shadows way better. 2. I set up lighting, and it looks cool (especially combined with fog). However, since i did not texture my objects yet, and use glcolor instead, is it normal that it only lights up the place but does not do any other lighting effects until i texturize the objects? 3. Is setting up normals required? currently i use this:

	GLfloat light_position[4]={0.0f,-100.0f,0.0f,1.0f};
	GLfloat light_ambient[4]={0.5f,0.5f,0.5f,1.0f};
	GLfloat light_diffuse[4]={10.0f,10.0f,10.0f,1.0f};
	GLfloat light_specular[4]={10.0f,10.0f,10.0f,1.0f};
	glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
	glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular);
	glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
	glLightfv(GL_LIGHT0,GL_POSITION,light_position);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_COLOR_MATERIAL);

Share this post


Link to post
Share on other sites
Advertisement
Ad 1. Lighting does not produce shadows only shades objects according to the face/vertex normals. So this answers questions 3 as well. You have to have normals for proper lighting. I assume you use some sort of quadrics where normals are generated for you.

Ad 2. Textures do not effect lighting. You can incorporate shadows or glows or whatever in your textures to give an illusion of lighting effects but that's it.
However material definitions do. Look up "glMaterial".

Share this post


Link to post
Share on other sites
1)Lighting is one thing, shadowing is another. Setting up lighting results in surfaces being only litten, without calculating the shadows they receive from other objects. OpenGL does not support directly shadows, you have to implement them yourself(stencil buffer is one way, as you mentioned).

2)What "other lighting effects" were you expecting? Regardless, the answer probably is the same as (1). OpenGL just calculates the diffuse,specular,ambient and emmisive lighting every surface gets, and the calculation takes place per-vertex. The light values of the vertices are then interpolated across the entire surface. That's it. Any other effects(like,say,bumpmapping or bloom) need to be implemented by the user using the fixed function pipeline or,preferably, using vertex and fragment shaders.

3)Yes it is required. OpenGL needs the normals to calculate the lighting. You will have to either provide them via glNormal3f() or glNormalPointer(), or there are some circumstances where they are calculated automatically, like GLU's support for NURBS(strictly speaking, OpenGL never calculates normals, only GLU does it some times, but GLU almost always pairs with GL).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!