Page 1 of 1

dynamic lights

Posted: Wed Feb 27, 2008 3:09 pm
by Scripter
Im using a quake3 map(made one from scratch, having some trouble with lightmaps) and im using dynamic lights on it. Which seem to work but no really correctly.

code we use for the lights

Code: Select all

mLevelNode->setMaterialFlag( video::EMF_LIGHTING, true );
	mLevelNode->setMaterialType( video::EMT_LIGHTMAP_LIGHTING );
	mLevelNode->setMaterialFlag( video::EMF_NORMALIZE_NORMALS, true);

scene::ILightSceneNode* light = mSmgr->addLightSceneNode( 0 );
		irr::video::SLight l;
		l.AmbientColor	= video::SColorf(1.0f, 0.0f, 0.0f);
		l.DiffuseColor	= video::SColorf(0.6f, 0.6f, 0.6f);
		l.SpecularColor = video::SColorf(0.0f, 0.0f, 0.0f);
		l.Radius		= mLights[0].power;

l.Type = video::ELT_POINT;

			l.Direction = core::vector3df(  0.0f,
											-1.0f,
											0.0f );
			l.InnerCone = (float)mLights[0].innercone;
			l.OuterCone = (float)mLights[0].outercone;

we use that code to generate dynamic lights from the maps info, right now we have 4 lights placed out on the map.
Here are some screenshots
http://stefans.damnserver.com/screen1.jpg
http://stefans.damnserver.com/screen2.jpg

Here you can see how the light fligh around in a cirlce effect the walls very strange.

Anyone has any idea how to fix or another way to implement dynamic lights with Irrlicht.
thx[/img]

Posted: Wed Feb 27, 2008 4:13 pm
by JP
It's probably down to the lighting being per-vertex and your map's ceiling is just two large triangles which gives poor lighting results.

If that's the problem then it can be solved by using per-pixel lighting (write a shader for it or check the projects forum, there are probably some there) or by using a higher subdivision for your surfaces (i.e. more than 2 triangles)

Posted: Wed Feb 27, 2008 5:13 pm
by Frosty Topaz
If you don't need the lights to be dynamic lightmapping will be tons more efficient. What kinds of problems are you having with it?

Posted: Wed Feb 27, 2008 5:29 pm
by hybrid
First of all, direction and position are read-only in Irrlicht 1.4. You have to use the light scene node's position and rotation to specify those values. Moreover, direction is useless for point lights, just as the cone values.
What could be the problem is the default attenuation of the light, try to change the values to something like (0,1.f/power, 0) (in the SLight struct).
In case you use directional lights (spot or really directional) you have to rotate the local light vector (0,0,1) by the absolute rotation to get the actual light direction of the node.