Newbie lighting help--"faceted" look...yuck.

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
EricDB
Posts: 8
Joined: Wed Nov 09, 2005 1:47 am

Newbie lighting help--"faceted" look...yuck.

Post by EricDB »

Okay, I've got a simple program that loads my model, and an FPS camera so I can inspect it. I put a light in, that orbits the model in a circle, so I can see some lighting effects. The problem is that everything looks faceted...like the lighting is done per-poly and not per-vertex, maybe? Here's a screenshot:
Image

And here's the part of my code where I include the goblin model and the light:

Code: Select all

	// Add the goblin model:
	scene::IAnimatedMesh* goblinMesh = smgr->getMesh("../../../media/models/goblin.3ds");
	if (goblinMesh) {
		scene::IMesh* tangentMesh = smgr->getMeshManipulator()->createMeshWithTangents(goblinMesh->getMesh(0));
		scene::ISceneNode* goblin = smgr->addMeshSceneNode(tangentMesh);
		goblin->setScale(core::vector3df(20, 20, 20));
		goblin->setMaterialTexture(0, driver->getTexture("../../../media/textures/goblin.bmp"));
		goblin->setRotation(core::vector3df(0, 90, 0));
		goblin->getMaterial(0).EmissiveColor.set(10, 10, 10, 0);
		tangentMesh->drop();
	}

	// Add the light:
	scene::ISceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0, 10, 0),
		video::SColor(255, 255, 255, 0), 2200.0f);
	if (light) {
		// Position the light above the model:
		light->setPosition(core::vector3df(0, 130, 0));
		// Attach a billboard:
		scene::ISceneNode* bill = smgr->addBillboardSceneNode(light, core::dimension2d<f32>(60, 60));
		bill->setMaterialFlag(video::EMF_LIGHTING, false);
		bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
		bill->setMaterialTexture(0, driver->getTexture("../../../media/textures/particlered.bmp"));
		// Make it go in a circle around the model:
		scene::ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(core::vector3df(0, 0, 0), 130, 0.003f);
		light->addAnimator(anim);
		anim->drop();
	}
How can I get a nice smooth Gouraud-shaded look? I confess I don't really understand the business with the tangent mesh; I just copied that out of the per-pixel lighting tutorial. I suspect my problem is there. Thanks for any help.
Guest

Post by Guest »

I never had problems like this. How does your model look in your 3D-app? Maybe you simply did not apply smooth to it. I have done this with Blender and it always works.
EricDB
Posts: 8
Joined: Wed Nov 09, 2005 1:47 am

Post by EricDB »

I'm using Wings3D, and it looks nice and smooth in there:
Image

I found some posts on the forum saying that .3ds models have this problem with their normals not being interpolated for each poly they touch. I downloaded Deled and created a sphere, then exported it as a .X file, and I get the same probem. :(
Guest

Post by Guest »

you do not use bumpmaps so why do you even need a tangent mesh? also, did you set the EMF_LIGHTING flag for the model to true? otherwise it is not affected by any light
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

and try recalculating the normals as well.
Image
Post Reply