Skip to main content
gamedev.net
🔒 Locked

Lighting / Normal question

Started by catch Jun 29, 2007 at 11:53 AM 2 replies 750+ views
Original Post
catch
catch
I have a Ortho2d scene and I wanted to add a light to it. Basically, I want light sources that could be a torch or whatever. This is a mock-up 2d tiled looking game. So when I draw my quad, each vertex I specify the normal to 0, 0, -1, thinking that that light should reflect back toward the camera (which looks down the negative z axis). When I do an ambient light, everything lights up fine. But I wanted a directional or spot light, and I can't get those to appear unless I set the normals to be 1,1,0, or some non-zero value for X and Y. Well, no matter what I specify for Z in the normal, it's just pure black all the time. However, if I specify X or Y in the normal, the light will appear, but of course, the directions are all screwy and the shading looks funky. What am I missing? Am I thinking about the normals wrong?
"Creativity requires you to murder your children." - Chris Crawford
nPenAPaT
nPenAPaT
For a 2D game i would suggest to use LightMaps, simply because you wont need to simulate complex lighting. (Of course I could be wrong but I havent seen a 2D game with a ralistic lighting :) ) But if you want to do it with Lights - Make sure you use:
glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE,ptr);
Where 'ptr' is a pointer to a GLfloat. And *ptr=1;
This could slow down your application a bit, but you won
t have to worry if the normal is (0,0,1) or (0,0,-1).
If this doesn`t solve the problem chek if you have specified all the stuff for the lighting like Spot cutoff exponent etc.(a link from Red Book of OGL)
http://fly.cc.fer.hr/~unreal/theredbook/chapter06.html
catch
catch
Thanks for the reply!! I actually hadn't thought about light maps.

I originally was doing alpha lights, meaning just a quad with a blended texture that looked sort of how a volume of light might look, but the problem with that is it doesn't actually LIGHT anything! so a dark room, it's still dark.

But a light map would "light" the area up around it, no?

Basically, the stuff behind the quad with the "fake light" on it would need to be brightened, otherwise, the effect wouldn't work.

Good suggestion, maybe I'll look into it.

About the two-sided lighting model, I saw that in my OpenGL book but didn't think it would apply to me. I should try it out when I get home!

Thanks!

++rating
"Creativity requires you to murder your children." - Chris Crawford
catch
catch
Here's a small tutorial I found on dynamic lightmaps.

I'll give this a shot.

http://www.3ddrome.com/articles/dynamiclightmaps.php
"Creativity requires you to murder your children." - Chris Crawford

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.