[SOLVED] broken lighting on models

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

[SOLVED] broken lighting on models

Post by B@z »

hey guys.
probably its not irrlicht related but i need your help.
I made a character, in the editor it had nice lighting on it, but in irrlicht the lights are kinda off.
probably its about the normals, but how can i achieve editor like lighting?

here two picture:
http://blud.freeiz.com/up/good.PNG
http://blud.freeiz.com/up/baad.PNG

if i have to change something in the model, then can u tell me what?
or if i need to use a shader then can u give me some example? (im not good with shaders, and i dont really have time for studying it atm)

this is probably because i have double sided triangles in my model. tried to remove, it looked better, but the performance drop (since i have to disable the backface culling) is not something what i like. and so, it wasnt smooth either

thanks~
Last edited by B@z on Mon Jul 12, 2010 10:15 pm, edited 1 time in total.
Image
Image
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

If you`re scaling your model, did you tried normalizing the normals?

Code: Select all

node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
If not, check your model.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Re: broken lighting on models

Post by Murloc992 »

B@z wrote:hey guys.
probably its not irrlicht related but i need your help.
I made a character, in the editor it had nice lighting on it, but in irrlicht the lights are kinda off.
probably its about the normals, but how can i achieve editor like lighting?

here two picture:
http://blud.freeiz.com/up/good.PNG
http://blud.freeiz.com/up/baad.PNG

if i have to change something in the model, then can u tell me what?
or if i need to use a shader then can u give me some example? (im not good with shaders, and i dont really have time for studying it atm)

this is probably because i have double sided triangles in my model. tried to remove, it looked better, but the performance drop (since i have to disable the backface culling) is not something what i like. and so, it wasnt smooth either

thanks~
I have faced similar problem with my wizard, but fixed it. How you do the double sided triangles? I mean do you duplicate them or what? If You do duplicate them, make sure they're at least 0.1 blender unit off the original position, if you only want to make inside space not culled.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

shadowslair: im not scaling the model, but tried out, not working. and check what?
murloc: well, in metasequoia, i can make double sided faces, but i guess its just duplicating. ill try to move the faces tomorrow, thanks
Image
Image
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

B@z wrote:shadowslair: im not scaling the model, but tried out, not working. and check what?
Not using Blender for various reasons. In Max I`d do STL check, check smoothong groups etc.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

How does the model look in shading mode in blender? Or in texture mode?
Have you tried using Strg + N (Recalculate Normals Outside)?
What mesh format are you using? You might want to try triangulating the mesh before exporting.

greetings
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

shadowslair: smoothing groups are fine. i never heard about stl check, but ill try to find something like that thanks

freetimecoder: in shaded mode, its similar to what i get in irrlicht, just more shaded, but same bad. recalculate normals simply killed my model, so didnt really work.
im using b3d, and tried triangulating, but the result is same

tried out something, whats said its similar to stl check. did not work
Image
Image
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

in shaded mode, its similar to what i get in irrlicht, just more shaded, but same bad
The problem is with your mesh, not with irrlicht. Some normals are flipped inside instead of outside, that causes the errors.
In editing mode you can display the normals via Mesh (F9) -> Mesh Tools More -> Draw Normals
They should be displayed as pointing outwards lines. Some will point inwards, you have to flip them (W->Flip Normals)

Usually Ctrl + N does that for you very reliable, what do you mean by "killed my model?"

Edit: hm at least that is what I think, but then again it should show holes in irrlicht, unless you disabled backface culling? Can you post a picture of your model in shading mode and edit mode with drawn normals?

greetings
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

no, u took me wrong. u think my model has a material setted to double sided. but no, i have double sided faces (probably it is just duplicated faces with different normals)
so i have both normals pointing outside and inside :D

http://blud.freeiz.com/up/solid.PNG
http://blud.freeiz.com/up/normal-1.PNG
http://blud.freeiz.com/up/normal-2.PNG
Image
Image
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

That explains alot ;) With that Recalculate Normals Outside cannot work.
If they are not necessary (e.g. for UV mapping) you should not use doublesided meshes like that (you encounterd one of the problems it brings already) You should remove the unecessary faces by selecting everything and use W -> Remove Doubles, and then recalculate the normals. In Irrlicht disable backface flipping for the mesh or the desired material.
If you do need a both side setup, first finish your model, and get rid of double sides as described above, then dublicate the faces and flip the dublicated's normals. You can attach the borders by using remove doubles but that would certainly result again in shading errors.

greetings
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

weell, just because the cloak double sided, i dont want my full model be double sided lol.
my full model poly count is 10550
if i turn off backface culling, then its same to 21100 poly. and that matters xD

but blender, and metasequoia too can handle it. i want to know how to handle it, maybe shaders could help?
Image
Image
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

Unless you do not want to have it shadeless or raytraced I dont think this would work.
So you could either try fixing the face normals or find the material within the mesh that is on the cloak and set its backface flag. That way not your whole model would be double sided.

greetings
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

hmm checking for material actuall could work. thanks (the problem is i have them all on same texture, but i can do something about that)
Image
Image
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Post by Murloc992 »

Well, also, you can do the coat double siding my way:

1. Make the coat look good even in smooth shading.
2. Go to edit mode in blender(I assume it's a different meshbuffer(than body and so on))
3. CTRL+L to select the coat
4. SHIFT+D, left click, S 0.99 stay on it selected
5. CTRL+SHIFT+N
6. ???
7. profit
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

thanks, that worked.
well i did a bit different (i use msq for modelling, there i duplicated the faces->extrude a bit, invert, and banzaaai)
still not perfect, but not that ugly. thanks for the help guys ^^
Image
Image
Post Reply