Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Fixed-Function Light Flickering when dot(N,L)=0


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Geometrian   Crossbones+   -  Reputation: 1582

Like
0Likes
Like

Posted 27 May 2013 - 04:57 PM

Hi,

 

I have a bizarre problem. There is a simple OpenGL fixed-function light drawn at (0.0f,10.0f,-1.0f). There are several boxes that happen to have faces lying in the plane z=-1.0f. Consequently, the light vector and the normal are exactly orthogonal.

 

When this happens, instead of being black, the color flickers light and dark along that face, even when the camera is stationary. The draw settings are identical each frame. It's not a z-fighting effect; there's only one layer of polygons, and the flickering continues even when the camera is stationary. Each vertex of the face appears either lit or unlit, though it's unpredictable which a given vertex will be from frame to frame.

 

The light has no ambient, and by tweaking the light's diffuse and specular factors, I find that the problem only occurs when the light's specular coefficient is nonzero. Perturbing the light slightly along z fixes the problem; it's only when the light is exactly in line with the surface that the problem occurs. I can fix the problem better by just using a shader (which I plan to do anyway), but I'm wondering if anyone has encountered this before?

 

I suspect it may be some kind of driver bug.

Hardware: NVIDIA GeForce GTX 580M

Driver: 305.60

 

Thanks,

-G


Edited by Geometrian, 27 May 2013 - 06:04 PM.

And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

Sponsor:

#2 apatriarca   Crossbones+   -  Reputation: 1747

Like
0Likes
Like

Posted 28 May 2013 - 02:01 AM

I'm not sure what effect you are trying to achieve doing this. Floating point numbers do not have infinite precision so the light is sometimes located in front of the face and sometimes behind it. If I remember correctly, DirectX do not have two sided lightning in the fixed pipeline, so you compute the specular color (the diffuse color is clearly mostly zero in both cases) in only one of the two cases and you thus have flickering. Shaders may helo fixing this, but I do not understand why you want a light located on a surface in this way.



#3 Geometrian   Crossbones+   -  Reputation: 1582

Like
0Likes
Like

Posted 28 May 2013 - 02:12 AM

This just ended up happening accidentally; it seemed like undefined/wrong behavior. I was just trying to achieve basic fixed-function lighting.

 

When N dot L is 0.0, then R, the reflected light direction is the same no matter which way the normal faces. This is then dotted against the viewing ray to produce a specular term. This is raised to the power of the specular coefficient.

 

The only thing I can think of is that the driver is optimizing the case where N dot L < 0 and not computing any specular at all, causing variation among different vertices because of floating point precision. This is sorta plausible since even at extremely low angles, specular can still be strong. But it still doesn't explain why the variation can change each frame.


And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#4 apatriarca   Crossbones+   -  Reputation: 1747

Like
0Likes
Like

Posted 28 May 2013 - 02:24 AM

The last time I used the fixed pipeline was years ago and I do not remember the details. What happen when you move the light behind the surface? If the polygon has no lightning, then lights behind a surface are ignored as I said in my last post. Since the light is located on the surface, any small change may cause the light to move between the two "states" (in front or behind the surface). I think you should simply try to avoid such cases (or use shaders to make it work as you wish).



#5 Geometrian   Crossbones+   -  Reputation: 1582

Like
0Likes
Like

Posted 05 June 2013 - 12:52 PM

What happen when you move the light behind the surface?

Perturbing the light slightly along z fixes the problem

.

Since the light is located on the surface, any small change may cause the light to move between the two "states" (in front or behind the surface).

Yes, but the diffuse should be ~0.0 in either case, and while specular can jump, the only time it should be visible at all is at an extreme glancing angle (0.0, to be specific, in which case it's edge-on and not visible anyway).

The problem recurred in a shader, but I managed to solve it. It was related to the object's tangents for normalmapping (they weren't being passed in). This doesn't explain why the fixed function pipeline was being drawn incorrectly, however.


And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.

#6 marcClintDion   Members   -  Reputation: 431

Like
0Likes
Like

Posted 09 June 2013 - 06:08 AM

Maybe some variable that is being applied to the lighting is not initialized. This will cause flickering. It might be present at other angles but washed out so you can only see it where the model is dark.


Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, because you know that the testing of your faith produces perseverance. Let perseverance finish its work so that you may be mature and complete, not lacking anything.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS