Ugly shading

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Jallenbah
Posts: 12
Joined: Thu Aug 14, 2008 12:10 pm
Location: Vector3df(20.6, 4, 19.2);

Ugly shading

Post by Jallenbah »

I made a sword using blender, and it seemed to turn out fine, the texture mapping stayed with it fine too.

My problem is that the shading looks terrible when i use a light with it
Image

As you can see, it's like it only lights up individual faces. Will i be able to make this look nicer with a shader or something? Or will i have to subdivide all of my faces?

Thanks
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

which model format are you using? the normal seems flat.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Try using the mesh manipulator (from smgr) to recalculate the mesh's normals, that could be part of the problem here.

Or it could be just the limitations of per vertex lighting when you have very few polys in which case you could sub-divide the polys or use per-pixel lighting (which is probably how blender lit it) by using a shader.
Image Image Image
Jallenbah
Posts: 12
Joined: Thu Aug 14, 2008 12:10 pm
Location: Vector3df(20.6, 4, 19.2);

Post by Jallenbah »

I recalculated the normals like you said, and it seemed to do the trick.
Image

It's flat shading as you can see, but a shader can soon fix that! Thankyou very much!

Oh yeah, the code:

Code: Select all

irr::scene::IAnimatedMesh* mesh = smgr->getMesh("../media/testSword/shortsword.x");
	smgr->getMeshManipulator()->recalculateNormals(mesh);
torleif
Posts: 188
Joined: Mon Jun 30, 2008 4:53 am

Post by torleif »

You might want to pick a format with better normal storage. You don't really want to recalculate all the normals every time you load a mesh
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

no problem recalculating the normals when you load a mesh, it's a pretty quick process and you'll only really load meshes during a loading phase so it wouldn't affect your gameplay.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The .x format should store per-vertex normals, so it seems that they are either wrongly exported, or interpreted incorrectly by Irrlicht.
Post Reply