Lights and Lightmaps

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
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Lights and Lightmaps

Post by kklouzal »

Hello again, I have two questions about lighting.

First off lights themselves, I'm creating my mesh with 3DS Max which allows you to place lights. Does anyone know of a way to get the positions of lights that were created in 3DS Max so I can create light scene nodes at those positions? The only thing I could think of was to create bones with a LIGHT_ prefix then for each bone on the mesh with that prefix create a light, but this seems over-kill.

Second are lightmaps themselves, I'm applying the mesh's texture to material 0 and assumed you could apply the lightmap texture to material 1 but this seems to have no effect. Could someone please explain how to properly apply the lightmap texture?

Thank you very much for your time.

EDIT:
Is there really even a need to use a lightmap? Does it have the potential to improve the visual quality of a mesh? I was looking at the E_MATERIAL_TYPE's and it gave me the impression that using a lightmap would interfere with dynamic lighting, is this true? The same goes for a bump and normal map, do these have the potential to improve visual quality and are there any downsides?
Dream Big Or Go Home.
Help Me Help You.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Lights and Lightmaps

Post by CuteAlien »

Don't know about the export toolchain from 3DS Max. But probably you will have to use some trick like your bones. Or some invisible object which you can find again in Irrlicht. Or maybe lights have a special texturename which you can find.
It might work if you export as collada - but no guarantees (I can't try as I don't have 3DS Max).

You were more or less correct. Mesh-texture is in texture 0 and lightmap-texture is in texture 1. Then you use one of the lightmap materials. If it make sense to use lightmaps is hard to tell in general. Depends on your level. For an example with lightmaps and dynamic lights using the fixed function pipeline (no shaders) you can check that h-craft racer from Irrgheist in my .sig below. It uses lightmaps on the tracks (you can see the bright spots below all the lights) + dynamic lights. They do mix - but obviously don't have really correct lights.

For better light solutions you will need shaders. Also as soon as you want to work with more than 2 textures the default-materials in Irrlicht won't be sufficient (they are all 1 or 2 texture combinations). So if you want for example lightmap + bumpmap you will have to create your own materia. In which case you should use a shader. Or a more common combinations might be texture+lightmap+detailmap+bumpmap (or normalmap).

As soon as you start writing shaders you have complete freedom...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Lights and Lightmaps

Post by The_Glitch »

It's really easy to use 3ds max and make light maps. You can export it to any format as long as they support multiple uv coordinates with 3ds max or Irrlicht. Also a common mistake people make is that you have to make a separate uv set in 3ds max and bake the lightmaps then. You would set this data to uv map channel 2. Remember 3ds max starts with 1,2,3 etc... C++ starts with 0,1,2,3. So If you load your mesh in irrlicht and set lightmap and it doesn't work you most likely made the error above.


As for the lights I'm not to sure in your case... as I use shaders and I just position my lights in Irrlicht to the position that looks best when I made the shader before loading in Irrlicht.
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Lights and Lightmaps

Post by kklouzal »

Thank you both for the replies, I've never written a shader before, I know I'll have to eventually, maybe I should start sooner than later, however I was hoping I could make a custom SMaterial and attach the texture,light,detail,normal map then apply the SMaterial to the scene node instead of going the shader route since we only need basic lighting but hoped to improve the visual aesthetics a bit by applying a few different maps to the mesh.
Dream Big Or Go Home.
Help Me Help You.
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Lights and Lightmaps

Post by The_Glitch »

PM me If you need some pointers or help. Also are you using direct3d or opengl?
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Lights and Lightmaps

Post by kklouzal »

I'm just using D3D at the moment but plan to have support for both.
Dream Big Or Go Home.
Help Me Help You.
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Re: Lights and Lightmaps

Post by Adversus »

I use 3d studios max to build the lightmaps for the level geometry. Just use render to texture and put it on channel 2 then use the lightmap material type in irrlicht.

You can export the lights from max using the b3d exporter however it only works for max 9.

The thing you will want to do is modify the solid material to scale it by 2 otherwise your in-game lighting will only "remove" lighting ie an object lit at full white will appear normal. By using the scale you can brighten it so what I do is scale all the lights down by 0.5. That means at full white it will be doubly as bright so now you should be able to use multiple lights. If you don't do that everything will either apear unlit (many lights added together give white) or too dark.
Noiecity
Posts: 159
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

Re: Lights and Lightmaps

Post by Noiecity »

CuteAlien wrote: Thu May 22, 2014 9:58 am Don't know about the export toolchain from 3DS Max. But probably you will have to use some trick like your bones. Or some invisible object which you can find again in Irrlicht. Or maybe lights have a special texturename which you can find.
It might work if you export as collada - but no guarantees (I can't try as I don't have 3DS Max).

You were more or less correct. Mesh-texture is in texture 0 and lightmap-texture is in texture 1. Then you use one of the lightmap materials. If it make sense to use lightmaps is hard to tell in general. Depends on your level. For an example with lightmaps and dynamic lights using the fixed function pipeline (no shaders) you can check that h-craft racer from Irrgheist in my .sig below. It uses lightmaps on the tracks (you can see the bright spots below all the lights) + dynamic lights. They do mix - but obviously don't have really correct lights.

For better light solutions you will need shaders. Also as soon as you want to work with more than 2 textures the default-materials in Irrlicht won't be sufficient (they are all 1 or 2 texture combinations). So if you want for example lightmap + bumpmap you will have to create your own materia. In which case you should use a shader. Or a more common combinations might be texture+lightmap+detailmap+bumpmap (or normalmap).

As soon as you start writing shaders you have complete freedom...
Thanks for the info
**
If you are looking for people with whom to develop your game, even to try functionalities, I can help you, free. CC0 man.

Image
**
Post Reply