About Lightmaps

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

About Lightmaps

Post by greenya »

Hello!

I have got 2 questions about lightmaps in 3d graphics.

1.
How light maps are done for an object on a certain map?
The object cast shadows on more that 1 object (like, floor, walls, other objects). So if i understanding correctly -- we need to load floor, walls, .... into editor with our target object and render shadows (lightmaps). BUT then we will get static lightmap -- so if we need to reuse some object in other game levels -- we need calculate all possible shadows (lightmaps) for all objects.
So we have 1 object mesh, 1 texture, but 10 lightmaps for each instantiation of the object. Deeply i think this is wrong, but i want to know the answer and how this done in now days games?

2.
How it is possible to cast lightmaps on dynamic objects. There are a lot f games that implements this. I'm saying about using only lightmaps (pre calculated soft shadows) --- when the moving object gets into the shadow of some another object -- it receives completely proper shadow projection (not some highlighting of the full mesh, NO -- because there are also visible soft shadow's edges) -- and this looks like projective shadows ------ HOW this is done?

P.S.: Second question is more interesting, because if it solves -- we do not need to pre render 10 cases of shadow of the object for each game level.

Please, share the info if you know something about it.
Thank You.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

1- Lightmaps are baked into the 2nd texture coordinates of mesh before exporting, which means objects must be duplicated. I don't think it's possible to split this data
2- I think a mixture of using pixel shader shadows on dynamic meshes, and also some kind of lighting regions (cube or sphere maps) to change the ambient lighting. I don't think it's read from the lightmaps, though I could be wrong.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Re: About Lightmaps

Post by BlindSide »

greenya wrote: 2.
How it is possible to cast lightmaps on dynamic objects. There are a lot f games that implements this. I'm saying about using only lightmaps (pre calculated soft shadows) --- when the moving object gets into the shadow of some another object -- it receives completely proper shadow projection (not some highlighting of the full mesh, NO -- because there are also visible soft shadow's edges) -- and this looks like projective shadows ------ HOW this is done?
Are you abosolutely sure it wasn't shadow mapping?

Here is a screenshot of my dynamic shadowmaps, the quality is very similar to lightmaps so its easy to get confused:

Image

Cheers

(Maybe its possible to project lightmaps using a cubemap to have a dynamic lightmap effect? This is usually used for good ambient lighting.)
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

Sorry for my English and my possible misunderstanding, but i just wanted to show certain what i mean. I have create 3min video of doom3 play -- this going to show what do i mean:
http://www.youtube.com/watch?v=ojuMr8l0JVA

little description:
0 - i load savepoint
1 - i turned on stencil shadows ( i showed it with the volumes casted from objects around )
2 - i turned off light ( from the second try :-) -- sorry ) ( anyway, stencil shadows are gone )
3 - and then -- i started to move the box -- it receives lightmap shadow ( it is the shadow of the some metal net ( it is also clearly visible on the floor ) ). BUT floor is a static object (never get movement) , but not the box,

SO, my question is:
how the box receives correct lightmap shadow since it moving object (so the light map not pre-rendered) :?:

Thank You!
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Its just a projected texture. Very similar to shadow maps (But without a depth test).

Read up on projective texturing to get an idea on how this technique is achieved.

This is me using projective texturing to simulate window light shining on a table:
Image

See how the colour of the transparent windows is projected onto the floor and the table? Even if the floor or the table moves, it will still be projected correctly, its fully dynamic.

Here is the basic procedure:

In shaders:
Create a camera pointing at the object. Use the projection matrix of the camera as texcoords for the texture, by multiplying with the vertex position then dividing by the w coord.

Fixed function (OGL):
Create a new material renderer, use texgen to generate EYE_LINEAR coords using the projection matrix of the camera multiplied by a projection matrix:
f32 projMat[] = {0.5f, 0, 0, 0, 0, 0.5f, 0, 0, 0, 0, 0.5f, 0, 0.5f, 0.5f, 0.5f, 1};

Cheers, I hope I've shed some light on the issue.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply