Light in BSP maps

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
monsterguden
Posts: 8
Joined: Tue Jan 29, 2008 12:19 pm

Light in BSP maps

Post by monsterguden »

Im trying to use dynamic lights in bsp map instead of the pre-rendered. The light im using works on everything in the world except the map.

Code for loading of map:

Code: Select all

	mMap = (IQ3LevelMesh*)mSmgr->getMesh( levelOptions.meshName.c_str() );

	// setup scene node for the level mesh
	levelNode = NULL;
	levelNode = mSmgr->addOctTreeSceneNode( mMap->getMesh( 0 ) );
	levelNode->setPosition( irr::core::vector3df( 0.0f, -100.0f, 0.0f ) );
	levelNode->setMaterialFlag(video::EMF_LIGHTING, true);
levelNode->setMaterialFlag(video::EMT_SOLID);
and the light:

Code: Select all

scene::ILightSceneNode* light3 = mSmgr->addLightSceneNode(NULL, core::vector3df(16.0f,272.0f,0.0f), video::SColorf(1.0f, 1.0f, 1.0f, 0.0f), 9000000000000000000000000.0f, 1337);
	irr::video::SLight l;
	l.AmbientColor = video::SColorf(0.0f, 1.0f, 0.0f);
	l.DiffuseColor = video::SColorf(0.0f, 1.0f, 0.0f);
	l.SpecularColor = video::SColorf(0.0f, 1.0f, 0.0f);
	l.Type = video::ELT_DIRECTIONAL;
	l.Attenuation = core::vector3df(0.0f, 1.0f, 0.0f);
	l.Direction = core::vector3df(0.0f, -1.0f, 0.0f);
light3->setLightData(l);
Last edited by monsterguden on Tue Jan 29, 2008 2:28 pm, edited 1 time in total.
monsterguden
Posts: 8
Joined: Tue Jan 29, 2008 12:19 pm

Post by monsterguden »

i got it! ;)

like 5 mins later, sorry for bad post.

the fix, the howto

levelNode->setMaterialType(video::EMT_SOLID);
monsterguden
Posts: 8
Joined: Tue Jan 29, 2008 12:19 pm

Post by monsterguden »

and here we go again...

when using emt_solid i got light, ambient light.
as usual the other stuff on the map is affected by diffuse and specular bot no effect at all to the map...

plx help.
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

This is because the BSP map loader, loads in the lightmap images that are created by the BSP complier. I'm not sure what you will have to do to remove the lightmaps (they might be stored in the 2nd material for the mesh), however, are you really sure you'd want to? BSP compliers usually run radiosity light calculations, which are a lot more realistic that current dynamic lighting.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You could walk through the meshbuffers and change from LIGHTMAP_* to LIGHTMAP_LIGHTING_* materials. This will keep the lightmap effects, but also enable dynamic light effects. You cannot do this on the whole mesh, though, because there could also be some solid meshes.
monsterguden
Posts: 8
Joined: Tue Jan 29, 2008 12:19 pm

Post by monsterguden »

When using EMT_LIGHTMAP_LIGHTING instead of solid, all light dissapears. Back to black...

levelNode->setMaterialType(video::EMT_LIGHTMAP_LIGHTING);
instead of
levelNode->setMaterialType(video::EMT_SOLID);
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe you should use a point light, or use a direction which is not exactly orthogonal to the walls (e.g. -1,-1,1). Moreover, the range seems pretty large (and is completely useless for directional light). Also try to enable AmbientLight in the scene manager (this avoids completely black textures, too).
monsterguden
Posts: 8
Joined: Tue Jan 29, 2008 12:19 pm

Post by monsterguden »

thx for all help, its up and running now. i will make a post containing our solution to the problem later in another thread so no one else has to go throu the process we just had to. like 8 hours of trial an error to get a simple light to work with a .bsp map...
monsterguden
Posts: 8
Joined: Tue Jan 29, 2008 12:19 pm

Post by monsterguden »

And here it is, a simple tutorial over how me and my team got it working... its ugly but it works, OK!? :twisted:

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=26006
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

I had a discussion with rogerborg ages ago. Go and read our discussion regarding his light manager. For example, your lights will bleed through walls unless you only draw the N faces visible to light L and facing it. A bsp tree may be helpful...
monsterguden
Posts: 8
Joined: Tue Jan 29, 2008 12:19 pm

Post by monsterguden »

sio2 wrote:I had a discussion with rogerborg ages ago. Go and read our discussion regarding his light manager. For example, your lights will bleed through walls unless you only draw the N faces visible to light L and facing it. A bsp tree may be helpful...
Ok, that sounds very advanced and i dont think thats something ill manage to do! (Cant find your old discussion...)

What about using another format, like irrEdit, can that solve my problem?
Post Reply