My scene is too dark but light is at max

DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #16
I have not yet recieved any email, but it may take a while because it is forwarded. I will edit this message when I get the mail.

Just one more thought: are you calling glEnable(GL_BLEND) ? Just asking because I have not seen it in the previous code samples.
Quote this message in a reply
Member
Posts: 269
Joined: 2005.04
Post: #17
Quote: By the way, I noticed that the image the other guy posted has normals coming from the middle of the polygon - my normals are the vertex normals not the polygon normal, is that o.k? Should I just be specifying one normal per triangle?

You have to define a normal for every vertex in the triangle. If the normal is the same for all three vertices then you have per-polygon lighting which is what that shot showed. I just drew the normals from the center of the polygon in that shot because it's easier to see if you've got the right normals that way than if you have them coming from the vertices. To get per-vertex lighting you just have to add up the normals for all the polygons that use that vertex, then divide by the number of polygons.

I'm almost out of ideas as to why lighting wouldn't be working. Try switching your winding between clockwise and counter-clockwise by using "glFrontFace(GL_CCW);" and "glFrontFace(GL_CW);" or draw the front and back faces in two different ways like this "glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_LINE); // draw front faces in filled mode, back faces in wireframe". Oh, and make sure you aren't applying any transformations to your GL_PROJECTION matrix.

Other than that, I'm completely out of ideas now.
Quote this message in a reply
henryj
Unregistered
 
Post: #18
Haven't seen this mentioned but have you examined the length of your normals, they should equal 1.0

Also where is your light. It may be that you are looking at the dark side of the moon.
Quote this message in a reply
OSXRules
Unregistered
 
Post: #19
I got a delivery failure from your e-mail dooog. My message says that what I sent was too large - 1.2 MB and that the message was truncated to 5k.

Anyway, I uploaded my code as a GLSurgery.tgz file to my yahoo briefcase at

http://uk.briefcase.yahoo.com/ajr650

so any of you can look at it. It should be in the "my documents" folder, which is public.

I removed the build code to save space so you will have to compile it yourself but I included the project builder files so just open the .pbproj file and everything should be o.k.

When you compile it and run it, go to the menu load surface and select the file bernard.srf (also included). It takes a wee bit of time to load as the model contains ~130,000 polygons. You will also notice that you can't see the face when it first loads. It is just misaligned. You have to move the first and third sliders half way to the left to see it. In the lighting tab, you can switch on the extra light to make it a bit brighter. Ignore the default light as it is redundant now.

If you select the translucent and wireframe buttons, you will see what I was saying about the brightness.
Quote this message in a reply
henryj
Unregistered
 
Post: #20
Your briefcase is empty.
Quote this message in a reply
OSXRules
Unregistered
 
Post: #21
That's weird, I made all my folders public (damn yahoo). I see what you mean though, I logged out and saw the folder was empty. I don't know how to fix it though.

Anyway, I have made a trial .mac account. Please someone access it quickly at

homepage.mac.com/osxrules

I only have less than a month left on my project - I need to get it fixed (panic).

Wacko
Quote this message in a reply
Member
Posts: 148
Joined: 2003.03
Post: #22
I know you are enabling lighting: glEnable(GL_LIGHTING), but are you enabling one of the light instances? ie: glEnable(GL_LIGHT0)?

Quote:glClear(GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT+GL
_STENCIL_BUFFER_BIT);

I've never seen it done that way. I've always seen glClear(bit | bit | bit...). Not sure if there is any difference, but you might want to look into it.

Try adding a constant spin to the object you are rending (for debug purposes) and see if it lights up any.
Quote this message in a reply
Member
Posts: 148
Joined: 2003.03
Post: #23
I just looked at your source. Try putting (if you havent already tried this):

[sourcecode]
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
[/sourcecode]

at the beginning of drawGLScene and see what happens. If it works, then the error is in your checkLighting or related lighting functions.
Quote this message in a reply
OSXRules
Unregistered
 
Post: #24
My extra light (called LIGHT_1) is enabled and disabled by flipping the switch in the interface. That's not the problem. The problem lies in the amount of light being reflected from or blended with my model.

Has anyone had it running and can see what's going on?

I had considered using software lighting but I shouldn't have to resort to that.

Please bear in mind that although the code is very large, the problem is only in GLView.mm. So, there is no point in trailing through any of the other code. I probably should have pointed that out earlier.
Quote this message in a reply
OSXRules
Unregistered
 
Post: #25
I see what you mean about using + in glClear(). I think I just saw someone else's code that used it. It didn't seem to make a difference though.

As for rotation, my sliders allow the model to rotate 360 degrees in all directions. Still there is no difference.
Quote this message in a reply
OSXRules
Unregistered
 
Post: #26
Hey, have you forgotten about me? (boo hoo). No one has replied for a while. Am I to assume that no one has sorted out my problem?

Come on, surely one of you 'gurus' and 'code crunchers' can figure it out. Pleeeeeease.
Quote this message in a reply
Member
Posts: 79
Joined: 2002.08
Post: #27
Quote:Originally posted by OSXRules
I see what you mean about using + in glClear(). I think I just saw someone else's code that used it. It didn't seem to make a difference though.

As for rotation, my sliders allow the model to rotate 360 degrees in all directions. Still there is no difference.


Yes, but where is your light positioned? If it's behind the model (from the cameras point of view) it doesn't matter how much you rotate the model.

KenD

CodeBlender Software - http://www.codeblender.com
Quote this message in a reply
Member
Posts: 177
Joined: 2002.08
Post: #28
You said you are using light 1... Try switching over to light 0 (unless it's already used for something else). The clip planes have a bug where none of the planes work unless plane 0 is enabled, maybe lights work the same way.
Quote this message in a reply
OSXRules
Unregistered
 
Post: #29
You misunderstand, my light 1 works. It is making a visible difference to the scene in that when I turn it on, the scene is brighter but it looks like I have turned on a torch in a dark room whose batteries are run down.

The brightness intensity is just not there. The easiest way for you to see how to make a difference is to download the code I uploaded to

http://homepage.mac.com/osxrules

and compile it yourself. You just have to modify the file GLView.mm.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #30
Sorry, its on my HD, but havent had the time to look through the stuff yet.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Transforming directional light to eye space in GLSL Coyote 4 6,387 Dec 8, 2009 03:16 PM
Last Post: Coyote
  OpenGL Blending for 2D Light Effects metacollin 10 12,667 Jun 6, 2009 12:51 AM
Last Post: NelsonMandella
  light attenuation NelsonMandella 2 3,602 Jun 4, 2009 03:28 PM
Last Post: reubert
  Surface/Vertice Normals and Scene Placement Jones 3 2,918 Aug 22, 2006 02:45 PM
Last Post: scgames
  Use Spencil in 2D scene and OpenGl ? RB jp 1 2,151 Apr 12, 2006 02:33 PM
Last Post: RB jp