In my project i need to scale an planar object (2 polys, right) by 15 units. Done this, i enable lighting on the plane and on two objects (one static, one animated), and add a light.
Result: the objects have their lighting, but the plane is totally black. When the plane isn't scaled, lighting works well.
I tried to both enable and disable normals-normalization for the plane, but no result.
I'd like to understand if it's an Engine bug or if i have to write some line more.
Lighting help?
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Re: Lighting help?
Irrlicht`s default lighting is per vertex. Easiest way in your case would be to simply use a plane with more tris, to get more vertices to be lit in order to get a nice result. The more, the smoother the lighting will be. The other option is by using shaders and per pixel lighting.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Re: Lighting help?
With the other option being the fastest, easiest to implement, and can easily be made into more advanced lighting shaders.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Lighting help?
If the normals are correctly normalized, the original scene should also work without problems. Even with just two triangles.
Re: Lighting help?
Ok, thank you for your answers, i'll give you a feedback tomorrow.
@shadowslair : I have to keep my code as fast as possible for my future uses, so i think i'll try @Lonesome Ducky 's tip before.
@hybrid : IDK, i'm sure i used irrlicht's integrated Normals Normalization function ( it was setMaterialFlag - EMF_NORMALIZED_NORMALS , wasn't it? )
@shadowslair : I have to keep my code as fast as possible for my future uses, so i think i'll try @Lonesome Ducky 's tip before.
@hybrid : IDK, i'm sure i used irrlicht's integrated Normals Normalization function ( it was setMaterialFlag - EMF_NORMALIZED_NORMALS , wasn't it? )
Re: Lighting help?
I think the problem shadowslair was referring to was that the vertices are beyond the light and so are dark, even if the middle of the triangles should be fully lit.hybrid wrote:If the normals are correctly normalized, the original scene should also work without problems. Even with just two triangles.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Lighting help?
Yes, this can indeed happen. When I thought about this scenario yesterday, I wrongly assumed that just a scale would keep at least one corner of the plane at the original place. This is not the case, though, so it could also happen that the light is just not affecting the vertices anymore.
To explain this in a little more detail:
Assume these sketches as the scene before and after the scale, the start being the light. The light strength is always measured at the vertices (plane border in the picture) and interpolated acrss the plane. In the scaled version, the light might be too soft at the vertices. So the interpolation gives only a very shallow light effect. If you make the plane a little more detailed (in the picture, one traingulation would be enough, but this depends on teh position of the light), it would work again. For pixel shaders, the lighting equation can be calculated for each pixel, so the correct value can be used.
To explain this in a little more detail:
Code: Select all
* *
|---| |----------------|
Re: Lighting help?
I think you properly understood my problem, and i like you did, i'm going to try these solutions right now, wait 10 minutes and i'll tell you.
Re: Lighting help?
Ok, i solved my problem, in fact in the end without the Gourard shading the result is almost the same, so i cut the plane in different sectors.
And i've enabled NormalizedNormals, and everything goes well now. (Gourard shading is enabled) Thank you anyway!
And i've enabled NormalizedNormals, and everything goes well now. (Gourard shading is enabled) Thank you anyway!