Lighting issue

Started by
3 comments, last by Dbof 12 years, 7 months ago
Hello!
I'm pretty new to this forum and I already have a few questions to ask.

I'm trying to light a scene correctly. My attempt is to have a closed room (cube) and light it from the inside, so you have to put the camera inside the room to see something.
Before I realized I had to flip the normals, I could only light the room from the outside.
The problem I'm encountering now can be seen in this picture: http://i.min.us/ib0xXBIBEvY3LV.jpg
The light in the middle of the screenshot (which is a sphere) contains a point light:
light.Type = D3DLIGHT_POINT;
light.Position = pos;
light.Range = 1000.f;
light.Diffuse = Diffuse; //White
light.Specular = Specular; //White
light.Ambient = Ambient; //Really dark (0.05, 0.05, 0.05)

light.Attenuation0 = 0.f;
light.Attenuation1 = 0.01f;
light.Attenuation2 = 0.f;


I created the cube with Blender and flipped the normals, so that the walls are lit from the inside of the cube. As you can see, when the light is outside of the cube, the cube's walls, which are not in the light's shining range, are lit.
Any idea how to fix this issue?

Hope I was clear enough.. Thank you in advance!
Advertisement
I'm not exactly sure what your saying your problem is, but do you mean that the walls on the inside are not supposed to be lit because the other walls are supposed to be in the way of the light? If this is the case, you will have to do some sort of shadow implementation so that the light is blocked from shining the inside of the cube when its outside of the cube. An easier fix than actually learning about shadows would be to test the lights position to see if its inside or outside of the cube, if its inside then apply the lighting to the cube, if its outside, don't apply lighting to the cube.

Otherwise (I can't really see what you mean be your picture), do you mean that you can see through the walls? you could turn off backface culling so that both sides of triangles are rendered. That way you wouldn't see that the inside of the cube is lit up if the camera and the light is outside the cube, and you could redraw the cube (slightly larger), with flipped normals, so that the outside of the cube is lit up when your on the outside.

The last thing which is why I don't know for sure what your problem is, is because you said "range". Your range is "1000", so that means any geometry within 1000 units of the light will be lit up, and that cube certainly looks within 1000 units (unless your using a massive scale).

hope that helps, if not, try to explain in more detail
Thanks god someone answered. Ok, I really thought it was clear.
Once again.

I want to create a scene with a cube. This cube should not be visible/lit. Imagine a military bunker which is only lit from the inside and has thick walls, so the light can't be perceived from the outside. The range is not important for now, everything should be affected by light for now.
I thought by inverting the normals of my cube, so their direction go into the cube, It would be possible to light the cube from the inside only.

This is the cube (which has a little window):
http://dbof.redio.de...kidsnapper2.jpg

The sphere above the cube is the (only) light source (point light)
http://dbof.redio.de...kidsnapper3.jpg

When the light is near the top, but outside of the cube, the top is dark, while the rest is lit, which is very unrealistic, because there should not be any light shining on the sides:
http://dbof.redio.de...kidsnapper4.jpg

When the light is moved near another wall, which was theoretically not hit by the light, it becomes dark:
http://dbof.redio.de...kidsnapper6.jpg

And this is my problem. I do not want the light to affect the cube if it is outside of it. As you can see, it is very unrealistic that the side walls are visible when the light rays are not supposed to light them.
Now any ideas? I hope I get a faster answer this time :)

And this is my problem. I do not want the light to affect the cube if it is outside of it. As you can see, it is very unrealistic that the side walls are visible when the light rays are not supposed to light them.

If the normals are flipped (they point on the inside) then from what I see the results are ok.

Kidsnapper4 clearly shows the top isn't affected because the normals are flipped but the lit face normals are actually pointing at the light.
You need a shadowing system or if you need a quick trick just check if the light is outside the cube. When it's outside just set one parameter of your light equation to zero.

[quote name='Dbof' timestamp='1314778699' post='4855792']
And this is my problem. I do not want the light to affect the cube if it is outside of it. As you can see, it is very unrealistic that the side walls are visible when the light rays are not supposed to light them.

If the normals are flipped (they point on the inside) then from what I see the results are ok.

Kidsnapper4 clearly shows the top isn't affected because the normals are flipped but the lit face normals are actually pointing at the light.
You need a shadowing system or if you need a quick trick just check if the light is outside the cube. When it's outside just set one parameter of your light equation to zero.
[/quote]

Oh, this means when the normals are at an angle of less than 90 degrees from the light, they are automaticly lit?
Probably did not consider it, thank you. I am going to check what I can do against.

This topic is closed to new replies.

Advertisement