Lighting Problem

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
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Lighting Problem

Post by handless »

hello,
I'm using .x models, with OpenGL. When I add a lightnode to the scene, I get a strange problem. The lighting seems to shade each polygon, instead of shading the entire model. Ive tested many methods of lighting using irrlicht, but haven't seemed to find a good one that solves the problem.

Heres a screenshot of what I mean.

Image

Heres my code:

Code: Select all

	// Circle_House
	scene::IAnimatedMesh* orval_circlehouse = smgr->getMesh("models/Orval_CircleHouse.x");
	scene::ISceneNode* orval_circlehouseNode = 0;
	
	if (orval_circlehouse)
		orval_circlehouseNode = smgr->addOctTreeSceneNode(orval_circlehouse->getMesh(0));

	orval_circlehouseNode->setRotation(core::vector3df(0,0,0));
	orval_circlehouseNode->setScale(core::vector3df(1,1,1));
	orval_circlehouseNode->setPosition(core::vector3df(5000,0,5000));
	orval_circlehouseNode->setMaterialFlag(video::EMF_LIGHTING, true);



	 // Add Lighting
	scene::ILightSceneNode* light; 
	light = smgr->addLightSceneNode(smgr->getRootSceneNode()
        ,core::vector3df(5000,1000,6000),video::SColor(255,255,255,255), 1000.0f);

	scene::ICameraSceneNode* camera = 
		smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
	camera->setPosition(core::vector3df(5000,2000,6000));
	camera->setFarValue(1000); 
Any help would be great :?
ASD

Post by ASD »

You must increase polygon count of the model. Wall must consist not of 2 polygons, but at least of 20 polys. System gets light value in each vertex of the polygon and interpolate it in all surfase of the polygon
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Post by handless »

I fail to see how that would help :?

If you increase the poly count on the model, the lighting still shades each polygon seperately. Is there a way to set the lighting to shade the entire model?

Heres what I mean:

Image

I split the wall up into several different polys..... shades each one... not the whole...

Also, I can't get my floor lit, It only lights up when the light is closer to it than other parts of the map.. and even then, the other parts don't light up... Irrlichts ligthing seems really really buggy to me... Is there a way I can fix this?
Guest

Post by Guest »

think about it really.... if u point a flashlight at a wall during the night, not everythings gonna light up. im supposing ur trying to simulate the effect of the sun, but think about how gigantic and powerful that is... there is light enuff from that to light up everything... but if u put a light, even a bright one, close to that building, ur not gonna get the same effect. is it buggy...no i dont think so. the per polygon thing... does seem kinda strange.
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Post by handless »

How is that relevant to my question? :?

I would like to simulate global sunlight, yes, but thats not what I'm asking.

I wish to know how I can get a more realistic ligthing effect, than this per-poly lighting. Irrlicht's ligthing probably isn't buggy, could more likely be the way the lighting was scripted.

The reason I say it is buggy, for example: When I put a lightNode near the ground, and near the corner of the cube, it seems to ignore the floor, and render the cube. I have to adjust its intensity to over 10,000 for the floor to be halfway lit.. Which in return doesn't light the cube anymore.

What I need to know is how to by-pass using Irrlicht's lightNodes, or maybe tweak them so it lights the entire scene, rather than each poly......

I can post more screen shots showing this problem if you like?
AlexL
Posts: 184
Joined: Tue Mar 02, 2004 6:06 pm
Location: Washington State

Post by AlexL »

You may try lighting your scene using Irrlicht's per-pixel lighting, see tutorial.11, and that should get rid of your problem. If that solution won't work for you, take a look at one of the many lightmappers that can be used with Irrlicht. Hope this bit of information helps you out with your problem :)
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Post by handless »

Thanks, AlexL. The per-pixel lighting works much better. It still has some kinks it seems with OpenGL, but it will work just fine for now! Thanks for referring me to the tut. :D
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Post by handless »

OK, I got another problem now... :cry:

Isn't this supposed to be the other way around.. :?

The billboard shows you where the light is supposed to come from. But the lighting actually makes things dark, and everything else is lit....

Image

Anything suggestions on how to fix this? Please!

Thanks
- Jesse
AlexL
Posts: 184
Joined: Tue Mar 02, 2004 6:06 pm
Location: Washington State

Post by AlexL »

Hrmm that is odd, I don't really know what to say about this. Aside from look your code over and make sure everything is in place and setup correctly :? I'll make a lighting test and play around with that for a few, and see if there's anything I can suggest you to do. But until then, maybe ask someone with better Irrlicht knowledge?
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Post by handless »

I was able to fix the problem :)

All I did was discard the

Code: Select all

setMaterialType(video::EMT_NORMAL_MAP_SOLID); 
And adjust the light intensity. Seems to work fine now!

Image
Post Reply