Lightmapping would be great

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Lightmapping would be great

Post by zarfius »

After using Ogre for a couple of years now I feel the main feature that I would like to see added is lightmapping. I know that lightmapping is not really a real-time rendering feature, but it still makes sense for the graphics engine to provide this functionality.

Dynamic lighting is easy to implement but is very limited. The documentation for the Light class even says "In the future OGRE may be extended for certain scene types so an alternative to the standard dynamic lighting may be used, such as dynamic lightmaps."

Lastly, there is an article on the wiki about how to implement lightmapping using Ogre, but it's pretty complicated and really needs to be studied in great detail to figure out how it works. The last time I tried I gave up and put it off for another time.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Lightmapping would be great

Post by koirat »

This article shows how to generate lightmap using ogre.

Usually you will generate lightmap outside of ogre and use this lightmap in you engine. It's very easy to use a lightmap you can do it even with a fixed function pipeline. Dynamic lightmap is a whole different story.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Lightmapping would be great

Post by zarfius »

The problem is that I want to build my scene out of a bunch of different entities placed around the world and then create the lightmaps. I realise that I can generate lightmaps in a modelling application and export them for use in Ogre, but I don't want to have to build me entire scene in the modelling app for the sake of generating the lightmaps.

I realise that this is how many people do it but in my case I'm building my own level editor. Everything is working really well except static lighting. Dynamic shadows look okay, but that limits the ability to create static geometry out of the many entities in my scene that don't move.

I'm not bothered about dynamic lightmaps, but when I saw it mentioned in the documentation I thought that it might still be a consideration to be implemented?

So to make it clear, I understand perfectly how lightmaps work but I would like to be able to generate them in my own level editor. The worst case is that I'll have to implement it myself which is fine, I was just hoping that maybe there's some better options.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Lightmapping would be great

Post by koirat »

Ok you made it clear. I was surprised that you ask such a question anyway.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Lightmapping would be great

Post by zarfius »

koirat wrote:Ok you made it clear. I was surprised that you ask such a question anyway.
I'm sorry I don't really understand what surprised you about the question?

Do you think a lightmapping feature doesn't belong in Ogre? What surprises me is that lots of commercial game engines still use lightmapping but I can't seem to find a single open source lightmapping API to help with implementing my own.

Perhaps I'm wrong? Maybe it's better to forget about lightmapping and use 100% pixel shaders instead? Are lightmaps on the way out?
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Lightmapping would be great

Post by jacmoe »

The two of you are both right and wrong. :)

Lightmapping is highly specific to whatever it is you're mapping in light.

The terrain component does indeed feature lightmapping.
Which proves the point that it 'belongs in Ogre'.
But it also proves that the lightmapping is specific.

There *could* be lightmapping in the BSP scenemanager, or the PCZ scenemanager.

It all depends on the application.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Lightmapping would be great

Post by koirat »

I was surprised that you asked such a basic question.(as i thought that you wanted info about using lightmap in Ogre ) I just wanted to help. I'm sorry.
I can't seem to find a single open source lightmapping API to help with implementing my own
You can be the first one.
But honestly what kind off light data are you going to put into your lightmap. Simple light like it's rendered in FFP with shading, Shadows like in texture or stencil shadows, or maybe soft shadows generated by ray casting, if you want something very advanced you can try radiosity (best looking) to do some global ilumination also you can add normal mapping to your light calculations. All of this calculations are very different from each other so this is probably why there is no open source API.

You will do what you want but reconsider it, is there a point in wasting so much time to do something that is already done and got very good results, take a look at blender for example.
It would be better/easier to do exporter/importer of your scene and do lightmap in blender, you can automate the whole process.

Are you trying to do a commercial engine ??
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Lightmapping would be great

Post by zarfius »

koirat wrote:I just wanted to help. I'm sorry.
I didn't mean any offence I just wanted to clarify the answer. You've done that now, thank you :)
koirat wrote:But honestly what kind off light data are you going to put into your lightmap. Simple light like it's rendered in FFP with shading, Shadows like in texture or stencil shadows, or maybe soft shadows generated by ray casting, if you want something very advanced you can try radiosity (best looking) to do some global ilumination also you can add normal mapping to your light calculations. All of this calculations are very different from each other so this is probably why there is no open source API.
To be honest I would take anything at the moment. I'm really just looking for something that works. I agree that there are a number of different implementations but that's not really a reason not to have any of them.
koirat wrote:You will do what you want but reconsider it, is there a point in wasting so much time to do something that is already done and got very good results, take a look at blender for example.
It would be better/easier to do exporter/importer of your scene and do lightmap in blender, you can automate the whole process.
I've considered lots of options and I'm always open to ideas. The reason I implemented my own level editor was to be able to add features like spawn points, trigger areas, setup physics data on dynamic objects, sound data, waypoints, moving platforms, doors and so on.

I suppose a custom exporter could be written to implement these features, but the work flow wouldn't be very smooth and it seems that the lighting problem is the only thing that's holding me back. If I can solve it I'll be very happy.
koirat wrote:Are you trying to do a commercial engine ??
Originally it was going to be commercial but I recently decided to make the project open source. There's still a lot to be implemented but I'm really enjoying doing it. The level editor is kind of my pet project and I hope that the Ogre community can benefit from it some day.
http://code.google.com/p/glueengine/
jacmoe wrote:Lightmapping is highly specific to whatever it is you're mapping in light.
Thanks Jacmoe. Currently I'm focusing on indoor areas but adding terrain support would be nice one day.
jacmoe wrote:There *could* be lightmapping in the BSP scenemanager, or the PCZ scenemanager.
So your saying that the scene manager should handle the lightmapping. I hadn't really thought about it like this. I was under the impression that the BSP scene manager is a bit out of date now? So perhaps it might be worth looking into the PCZ scene manager and seeing if lightmapping exists already or maybe it's a feature that could be implemented? I'm willing to put in the effort to implement it if I can figure out how.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Lightmapping would be great

Post by koirat »

I've considered lots of options and I'm always open to ideas. The reason I implemented my own level editor was to be able to add features like spawn points, trigger areas, setup physics data on dynamic objects, sound data, waypoints, moving platforms, doors and so on.
You can attach data to objects in blender. But surly dedicated editor is more user friendly.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Lightmapping would be great

Post by syedhs »

Lightmapping is just another data, like creating an entity. But as far as code is concerned and depending on which pipeline is chosen, the code for lightmap is already in there (within Ogremain.dll). Many lightmapped scene is working on different (probably second) texture coordinate, the first one being the diffuse texture itself. The pipeline I am talking about is if you used an 3DSMax exporter like Ofusion and Ogremax (I am not sure, but should be), then all has been taken care of.

The lightmap code usually is if you decide to build an world editor and wish to lightmap the scene within it. IMO, if you decide not to use 3DSMax/Maya/other established 3d modeller as the world editor is to have the scene exported to the format that the chosen 3d modeller app understand, lightmap there and exported back to the format your app can understand. But that is not an easy job. But the result will always be better than simply using your own lightmap code.

Or you can probably purchase a world editor that can do lightmap and export to Ogre mesh format, and can be customized via plugin so that you can customize it as your own. Or you can use the new Ogre terrain lightmap, and build an editor around it - and for this, Ogitor is already there.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Lightmapping would be great

Post by zarfius »

syedhs wrote:Lightmapping is just another data, like creating an entity. But as far as code is concerned and depending on which pipeline is chosen, the code for lightmap is already in there (within Ogremain.dll). Many lightmapped scene is working on different (probably second) texture coordinate, the first one being the diffuse texture itself. The pipeline I am talking about is if you used an 3DSMax exporter like Ofusion and Ogremax (I am not sure, but should be), then all has been taken care of.
I haven't used 3DSMax (because it's pretty pricey) but I'm aware of how other modelling applications (such as DeleD) do lightmapping including the resulting material files from the exporters. The problem is that I can't find an affordable modelling app that allows me to correctly lightmap my scene without lots of painful work arounds.

I'm not complaining, I'm just looking at my options and trying to choose the best one. If there is lightmapping code somewhere in Ogre I'd be interested to have a look at it. Any idea where?
syedhs wrote:The lightmap code usually is if you decide to build an world editor and wish to lightmap the scene within it. IMO, if you decide not to use 3DSMax/Maya/other established 3d modeller as the world editor is to have the scene exported to the format that the chosen 3d modeller app understand, lightmap there and exported back to the format your app can understand. But that is not an easy job. But the result will always be better than simply using your own lightmap code.
Yes, this certainly is an option and if it turns out to be a better one than writing my own lightmapper I may do it. It's not the greatest solution though because it creates more work in the pipeline. At the moment I can export lightmapped level geometry from DeleD but once I place more static objects around the level the lightmaps don't look right anymore because the new objects either don't cast or recieve shadows properly. I'm not looking for a perfect option, just one that could be considered acceptable.
syedhs wrote:Or you can probably purchase a world editor that can do lightmap and export to Ogre mesh format, and can be customized via plugin so that you can customize it as your own. Or you can use the new Ogre terrain lightmap, and build an editor around it - and for this, Ogitor is already there.
I've looked around at lots of different world editors available and unforunately the only ones that work well have restrictive licensing like Valve Hammer, Unreal Ed or 3D world studio. All of these a good at lightmapping but tend to be tied to the game engines they are designed for or limited in functionality. There's also the open source ones like GtkRadiant but it's old and clunky and doesn't seem to work on my machine. Last I checked Ogitor wasn't very useful for making levels in the real world, nice scene's yes, but nothing practical. I'm sure that will change over time.

Before I go I'll point this topic to another one I found on the Ogre forums where sinbad himself once said:
sinbad wrote: from http://www.ogre3d.org/forums/viewtopic. ... 43&start=0
One of the bullet points on my 'todo one day' list is a decent global illumination system based on a book I have but it would need to be linked with a world format of some kind, since solving indirect lighting can't be handled well with unstructured polygon soups. I had planned to do it as part of the latter stages of WorldMinion although I never got to that stage due to time constraints (it's GPL now).
It's just a shame he never got around to it.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: Lightmapping would be great

Post by Zonder »

Ogre is a rendering engine surley rendering baked shadows should be a feature?
There are 10 types of people in the world: Those who understand binary, and those who don't...
dudeabot
Gnome
Posts: 334
Joined: Thu Jun 28, 2007 2:12 pm
Location: Brazil
x 5
Contact:

Re: Lightmapping would be great

Post by dudeabot »

ta da! http://www.larabie.net/ogre/LightBakerSrc.rar(from Falagard), you owe me this one ;D

ps: this works, ive tested in some point at the past, but needed to make it compatible with last ogre, but if i remember well there are not many changes to be done
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Lightmapping would be great

Post by zarfius »

Good to know that it works. I'll keep it handy for when I get around to implementing it into my editor.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Lightmapping would be great

Post by zarfius »

Another option could be OgreFSRad

http://www.horza.de/OgreFSRad.shtml

It's old and is only at version 0.02.1, but seemed to work back in the day. It's also command line driven with the dotScene format so I could export my scene and allow it to do it's thing then import the result back. Alternately, I could port the code to C# so that I can make and changes required and integrate it fully into the editor.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: Lightmapping would be great

Post by Zonder »

You would be better wrapping it or using the exe. The performance in c# won't be good enough in complex scenes
There are 10 types of people in the world: Those who understand binary, and those who don't...
User avatar
zarfius
Gnome
Posts: 367
Joined: Wed Jan 03, 2007 12:44 pm
Location: Brisbane, Australia
x 13
Contact:

Re: Lightmapping would be great

Post by zarfius »

Zonder wrote:You would be better wrapping it or using the exe. The performance in c# won't be good enough in complex scenes
I don't want to get into a C++ vs C# argument but you might be surprised how fast C# can be. Most of the benchmarks I've read put it only 5% slower in most cases.

Regardless of that, I'm experienced in both C++ and C# and I agree that for any time critical code it may be worth implementing it in C++ and writing a wrapper for use in the editor. When the time comes I'll be sure to do some benchmark testing of my own.
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: Lightmapping would be great

Post by Zonder »

I use c# all day long and yes it is quick but some languages are better suited to some things when it comes to number crunching c++ is better. But then again it's a while since I benchmark things my self so would be interesting :)
There are 10 types of people in the world: Those who understand binary, and those who don't...
Post Reply