PDA

View Full Version : help with another simple ligthing problem



gui24a
08-16-2008, 11:30 AM
Hi guys, continuing my work with lighting, now actually I have not a problem at all, but a doubt. Look at the image bellow:

http://img401.imageshack.us/img401/8167/sunexkz6.th.jpg (http://img401.imageshack.us/my.php?image=sunexkz6.jpg)
click for enlarge

I did note OpenGL doesn't calculate if a object is in front of another, in order to receive light (if a objects shadows another). In this image, the light source is slightly up the truck but far behind it. The circulated plate is receiving light even standing hide from the light source, hide behind the truck in relation to the light source. If the plate is hidden from the light, why is it receiving light?

Like I said, I did note Opengl doesn't do that by itself. How can I control that? Is there any "easy" way?

Regards!

dletozeun
08-16-2008, 11:43 AM
Opengl does not do itseft any occlusion computations. What you see is just a gouraud shading artifact.

read this (http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall) at "2. Poor Tessellation Hurts Lighting" section.

babis
08-16-2008, 11:49 AM
OpenGL doesn't know if an object hides another. It only knows the spatial relation of the current vertex/fragment, light, camera and surface normal. No 'easy' way to control that, you need to check how to do shadows.

gui24a
08-16-2008, 12:07 PM
I read 2. Poor Tessellation Hurts Lighting but I could not link that with my doubt.

I don't want to use shadows, is complicated, is there another trick to do, such materials properties to that plate?

babis
08-16-2008, 12:15 PM
Even if you changed material properties for that plate, it would be view/light position dependent. So, to be short, no easy way to get out of this.

If you don't intend to mess with shadows at this point, try to improve on other important things (e.g. shaders) that improve quality.

dletozeun
08-16-2008, 12:15 PM
It is not linked to shadows, this is just because fixed pipeline computes lighting per vertex and then interpolates color at each fragment.

To solve this, you can use a fragment shader and use per pixel illumination like Phong model or not use a spot light.

EDIT: Are to other part of your green object poor tesselated? Check also the normals you set

babis
08-16-2008, 12:21 PM
dletozeun, he said that the light comes from the back of the truck, and we see the front (you can see the ambient on the facing side of the truck), so it's probably a combined problem of shadowing & the interpolation artifact.

gui24a
08-16-2008, 12:30 PM
Sorry, here is how it is:

http://img391.imageshack.us/img391/9153/entirescenest3.th.jpg (http://img391.imageshack.us/my.php?image=entirescenest3.jpg)
click to enlarge

the scene is ugly, but it's all I need for while. After this I'll apply texture. I'd just want to get rid of these problems of shadows and lighting, it seems lighting is the most difficult part of rendering in rasterization. How I love ray tracing... :(

gui24a
08-16-2008, 12:36 PM
I think in setting the sun at 12:00 PM. :D

dletozeun
08-16-2008, 12:42 PM
I am happy to see your beautiful truck, but that does help us if you don't emphasize the lighting bug, I don't see it here...

In ray tracing, you don't have this problem, because all is done per pixel, but lighting is still complicated (depending on your needs)

EDIT: babis is right. Try to put the light in front of the truck.

babis
08-16-2008, 12:43 PM
If you don't want to check shadows (which is pretty logical), just ignore it for now & focus on the rest. Don't expect to have a perfect scene before you delve into texturing.

gui24a
08-16-2008, 12:47 PM
I am happy to see your beautiful truck, but that does help us if you don't emphasize the lighting bug, I don't see it here...

In ray tracing, you don't have this problem, because all is done per pixel, but lighting is still complicated (depending on your needs)

The problem is simple:

Just look at the wheel splasher. It is not intended to receive direct light from the sun, since the truck's cabin places between them.

dletozeun
08-16-2008, 12:51 PM
So now your problem is about shadows?? As babis and I said, Opengl does not manage shadows, you have to do it yourself. There is many algorithms that intend to do that, shadow mapping looks like to be the easiest to implement (At least basic shadow mapping).

gui24a
08-16-2008, 12:52 PM
If you don't want to check shadows (which is pretty logical), just ignore it for now & focus on the rest. Don't expect to have a perfect scene before you delve into texturing.

How much time is OpenGL's shadows learning curve? I don't have any material to study, just tutorials bad explained. :(

Another thing I'm sad is in tesselation. My scene is composed purely by 4 vertex quads, this is ugly. I'd want to do some beautiful curves, even the quads I'd like to draw in a series of vertex to take better lighting approach. I read about tessalation and I just could not got how it works, it is much complicated. I tried to use NURBS but it is slow as hell and I can't put it in a display list without bugs.

gui24a
08-16-2008, 12:53 PM
Yeah, I'll research about shadow maps, I don't have many other choices.

Thanks.

babis
08-16-2008, 01:00 PM
nurbs - display lists - vertex lighting. I'd suggest you to forget the deprecated stuff and start checking VBOs, FBOs & shaders if you will be messing with GL for some time.

gui24a
08-16-2008, 01:03 PM
where can I find good stuff to learn about that?

babis
08-16-2008, 01:07 PM
Google! Ozone3D has a tut about VBOs, FBOs tut + an example class from GPGPU.org (you can also find 2 articles in gamedev), and you can start learning GLSL from Lighthouse3D. Avoid just-code tutorials at all costs.

gui24a
08-16-2008, 01:31 PM
Ok, thanks a lot!