gl_lights - disable normal calculation?

Started by
10 comments, last by zedzeek 18 years, 10 months ago
Is it posible to use point lights without using normals for calculating the amount of light on each face, but instead calculating the amount of light solely based on the distance? I have a point light with its attenuation set to what I want. Is there a way to disable the light's normal calculations? Or some hacky workaround? By the way, al the normals and vertices are stored in display lists. Thanks, ~Mark
~ChickenMcOwnage~
Advertisement
I think you can specify one normal - pointing in the direction of the camera - and render the whole mesh using that normal.
This should at least work with the begin-end paradigm - I can't remember if anything changes if you switch to drawElements or VBOs.
its possible but most likely will not give the right results visually, the normal is needed so opengl can see which what the pixel/polygon is facing and shade accordindly.
well, I've implemented a shader that does not use normals to calculate the amount of light, only the distance. It's the look I want, but I don't want to have to use pixel shaders for my game because it limits the graphics cards that can play it. So, I want to imitate the shader using the standard ogl lights, and using the normals with the ogl lights looks just plain bad.

@janharal: the problem with setting just one normal before calling the list is that there will be multiple light sources.
~ChickenMcOwnage~
well if youre sure thats the look u want ie
take a wall the side facing away from the light is gonna be the same brightness as the side facing towards the light

just go glNormal3f(1,1,1) somewhere in the start of your code and dont call glNormal ever again in your app
Thanks for the reply. It works, and looks great, but there's a problem. Looking North-West in the game, everything looks good. The lighting, however, completely stops along the SW/NE diagonal, and if you are looking South-East, there is absolutely no light. A crappy picture might help:
  +------ light looks fine on this side  |+-V--+|   /||  / || /  ||/   <--- no light on this side+----+(The player is standing somewhere along the diagonal)


If you look down at your feet (basically where the origin of the light is) half of the quad you're looking down at will be 100% lit, the other half 100% black (more or less).

Also, flipping the normals to (-1, -1, -1) will make the lit area dark, and the dark area light. I'm pretty lost.. I'm not sure why it's doing this or what can fix it.
Thanks,
~Mark
~ChickenMcOwnage~
Alright so I've figured out what the problem is, and that's that zedzeek's answer is apparently incorrect. Calling glNormal3f(1.0f, 1.0f, 1.0f) at the start of the program will make all of the normals on all of the faces in the display list point diagonally up and out, which causes the strange lighting I defined in my previous post. By the way, if you change the numbers from 1's to 10's, the lit side will be more strongly lit.

So, back to my original question. Is it possible to disable normal calculations for lighting? I'm beginning to think it is not possible, nor are there any workarounds.

~Mark
~ChickenMcOwnage~
Quote:Original post by zedzeek
well if youre sure thats the look u want ie
just go glNormal3f(1,1,1) somewhere in the start of your code and dont call glNormal ever again in your app


... ? How will an arbitrary normal, that isn't even unit length, result in anything but the strangest lighting ever??


CaptainMcOwnage: My suggestion would be to scrap OpenGL's lighting entirely. AFAIK, it only computes colors per vertex using a phong-ish model, anyway. Instead, generate a color for every vertex in your meshes using your own lighting model that can completely ignore the normal.
Here is a good tutorial on phong lighting.
Err. AP was me. Link I meant to give you
What's the big problem here? To quote MDSN:

Quote:
Each light source contributes the sum of three terms: ambient, diffuse, and specular. The ambient light source contribution is the product of the material ambient reflectance and the light's ambient intensity. The diffuse light source contribution is the product of the material diffuse reflectance, the light's diffuse intensity, and the dot product of the vertex's normal with the normalized vector from the vertex to the light source. The specular light source contribution is the product of the material specular reflectance, the light's specular intensity, and the dot product of the normalized vertex-to-eye and vertex-to-light vectors, raised to the power of the shininess of the material. All three light source contributions are attenuated equally based on the distance from the vertex to the light source and on light source direction, spread exponent, and spread cutoff angle.


Just don't use diffuse lighting. You can give ambient intensity to a point light, and it's attenuated as well.

This topic is closed to new replies.

Advertisement