Jump to content
  • Advertisement
Sign in to follow this  

lighting, shadows and normals

This topic is 4251 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};

Share this post

Link to post
Share on other sites
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!