Lighting does not work correctly for small models?
Lighting does not work correctly for small models?
I have a strange problem with lighting of small models. I searched for the problem in the forum, but could not find something, so here is my description:
Since I am using the unit "meter" in my game, most objects have only the size of about 2 units. Many models I am using use other units, so I have to scale them down. When I use lighting now, Irrlicht does not "smooth" the light dependent on the angle between the normal vector of the face and the light source - there are only two possibilities: 100% dark or 100% bright.
Is this caused by setScale? If yes, why? It does not make any sense to scale the normals too...?! If not, why does lighting not work for "small meshes"?
If you want to test the problem by yourself, it is very simple:
Just take the SpecialFX-Tutorial source file, then scale the room.3ds-node to 0.01f, 0.01f, 0.01f, and the camera node too (set it to position -0.50f, 0.50f, -1.50f). You will see: only 100% dark or 100% bright - no smoothing...
Any ideas?
Since I am using the unit "meter" in my game, most objects have only the size of about 2 units. Many models I am using use other units, so I have to scale them down. When I use lighting now, Irrlicht does not "smooth" the light dependent on the angle between the normal vector of the face and the light source - there are only two possibilities: 100% dark or 100% bright.
Is this caused by setScale? If yes, why? It does not make any sense to scale the normals too...?! If not, why does lighting not work for "small meshes"?
If you want to test the problem by yourself, it is very simple:
Just take the SpecialFX-Tutorial source file, then scale the room.3ds-node to 0.01f, 0.01f, 0.01f, and the camera node too (set it to position -0.50f, 0.50f, -1.50f). You will see: only 100% dark or 100% bright - no smoothing...
Any ideas?
Here are two screenshots. They are from the exactly same program. The only things that are different are the scaling of the room.3ds (first screenshot: 1f, second screenshot: 0.01f) and the camera position (first screenshot: -50f, 50f, -150f, second screenshot: -0.50f, 0.50f, -1.50f).
Correct "smooth" lighting
Only 100% dark or 100% bright
Correct "smooth" lighting
Only 100% dark or 100% bright
Re: Lighting does not work correctly for small models?
This is because the normals of the mesh are scaled too, when modifying the scale. And if your model has longer normals, it will simply get darker. That's not a bug in the engine, that's just how 3d engines work. However, there should be a new flag in the material structure which should make it possible that normals can be renormalized again, but that's a featues I would have to add to irrlicht.Andi|xng wrote:Is this caused by setScale? If yes, why?
You could work around this problem by not scaling your scene nodes but modifying the positions of the vertices in your meshes directly.
Re: Lighting does not work correctly for small models?
I can not understand that. I thought normal vectors are completely independent from the size of the model - they just give information about the orientation of the faces. And I think the size of the faces is irrelevant for the normals...niko wrote: This is because the normals of the mesh are scaled too, when modifying the scale. [...] That's not a bug in the engine, that's just how 3d engines work.
"that's just how 3d engines work"... Maybe (don't know), but I can not find any example where this makes sense... It has nothing to do with reality?!
Let's say we have a big mirror. We can break it into smaller sharbs as often as we like, all mirror sharbs will work as a mirror like before, they have all the same normal vector...
Re: Lighting does not work correctly for small models?
They need to get transformed by the same transformation matrix and so they get scaled too. But I'm going to add a feature to the next version where this problem will disappear if you like.Andi|xng wrote:I can not understand that. I thought normal vectors are completely independent from the size of the model
Re: Lighting does not work correctly for small models?
That would be great I've also heard from other people that have problems with this, so it would be really useful. Thank you, Niko.
I have a similar problem but i don't know if is the same...
if a put a light and 6 spheres around in all directions y get 2 spheres trough
X axis correctly illuminated and the others wrong. The light isn't work like point light to me, because the 4 spheres wrong illuminated recive light from other sides and not from the point light. I haven't web server so i can't upload the image samples.
if a put a light and 6 spheres around in all directions y get 2 spheres trough
X axis correctly illuminated and the others wrong. The light isn't work like point light to me, because the 4 spheres wrong illuminated recive light from other sides and not from the point light. I haven't web server so i can't upload the image samples.
You can mail me the screenshots ( andi.wenger@gmx.de ), then I can upload them.