Help needed with light-maps

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Help needed with light-maps

Post by Smivs »

Hi all,
I'm looking for some help and advice on light-mapping. From a starting point of total ignorance I'm trying to suss out emission and illumination maps. I've got emission maps OK (and have successfully used them) but my problem now is that I want to use an emission map and an illumination map on the same model (I am trying to give ships lit cockpits and portholes (emission map) and hull spotlighting (illumination map).
I've got both working independently, but when I try to use both, only the emission map seems to work, or just the illumination map if I reverse the order they appear in the code. My understanding of this stuff is fairly limited as I confessed above, so I suspect that my code might need correcting. I'm experimenting with the python from my Shipset with the following code.

Code: Select all

materials = 
		{ 
			"python_redux.png" = { diffuse_map = "python_SS.png";  
                                                                                                            
                         emission_map = "python_em-map_SS.png";
                         illumination_map = "python_illum-map_SS.png";
                                              };  
		};
The illumination map (white ellipses on a black background) also seems very bright, even when the ship is facing the sun. How do I reduce the effect? Do I just make the White Grey or is it not that simple.
TIA for any help/advice.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Help needed with light-maps

Post by Eric Walch »

Smivs wrote:
The illumination map (white ellipses on a black background) also seems very bright, even when the ship is facing the sun. How do I reduce the effect? Do I just make the White Grey or is it not that simple.
TIA for any help/advice.
According to this you can add a multiplier for the emission map but not for the illumination map. But making white a bit more gray will reduce the effect.

Displaying both maps at the same time is possible and is also used in the material test suite on cube 6. And this test runs okay with me.

Code: Select all

[materialTest.runTest]: Running test full:6 (diffuse_map + emission_map + illumination_map). 
[materialTest.runTest]: Running test full:7 (diffuse_map + emission_and_illumination_map).

And you can merge both maps by putting the illumination data in the alpha channel of the emission map as shown on cube 7.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Help needed with light-maps

Post by JensAyton »

Smivs wrote:
I've got emission maps OK (and have successfully used them) but my problem now is that I want to use an emission map and an illumination map on the same model (I am trying to give ships lit cockpits and portholes (emission map) and hull spotlighting (illumination map).
While this works and is fully supported, it’s not recommended unless you have a strong reason (such as wanting to make one of the maps a higher resolution than the other).

The suggested approach is to convert the maps into a single emission map. This can be done in two ways:
  • Oolite does all the necessary processing when you use illumination and emission maps in non-shader mode, but to make it save the new emission map you need to build it yourself and change “#define DUMP_COMBINER 0” to “#define DUMP_COMBINER 1” in OOCombinedEmissionMapGenerator.m. I appreciate that this is a tad inconvenient.
  • In a layer-based editor such as Photoshop, Acorn or GIMP: put the diffuse map in the bottommost layer, then the illumination map in Multiply mode, then the emission map in Lighten mode.
Smivs wrote:
I've got both working independently, but when I try to use both, only the emission map seems to work, or just the illumination map if I reverse the order they appear in the code.
This is highly unlikely. The order things appear in a dictionary should have no effect whatsoever. It’s more likely that you’re seeing a pattern that isn’t there. (are you holding down shift while restarting Oolite?)

The only reason I can think of for something like that would be if you were using a graphics card with only two texture image units. You can get your texture image unit count by running the material test suite, or with console.glFragmentShaderTextureUnitCount in the debug console.
Smivs wrote:

Code: Select all

materials = 
{ 
    "python_redux.png" =
    {
        diffuse_map = "python_SS.png";
        emission_map = "python_em-map_SS.png";
        illumination_map = "python_illum-map_SS.png";
    };
};
There’s nothing obviously wrong with that (except the lack of a namespace prefix on the texture names), but I can’t really say more without the files.
Smivs wrote:
The illumination map (white ellipses on a black background) also seems very bright, even when the ship is facing the sun. How do I reduce the effect? Do I just make the White Grey or is it not that simple.
That’s generally the best way. Using a modulate colour as Eric alluded to might preserve subtle detail better on some hardware in shader mode, at a very small performance penalty.

The material documentation is currently outdated. The modulate colour for emission maps is now emission_modulate_color, and for illumination maps illumination_modulate_color.

The best, most up-to-date example of this stuff is the material test suite.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Help needed with light-maps

Post by Smivs »

Eric Walch wrote:
Smivs wrote:
The illumination map (white ellipses on a black background) also seems very bright, even when the ship is facing the sun. How do I reduce the effect? Do I just make the White Grey or is it not that simple.
TIA for any help/advice.
According to this you can add a multiplier for the emission map but not for the illumination map. But making white a bit more gray will reduce the effect.

Displaying both maps at the same time is possible and is also used in the material test suite on cube 6. And this test runs okay with me.

Code: Select all

[materialTest.runTest]: Running test full:6 (diffuse_map + emission_map + illumination_map). 
[materialTest.runTest]: Running test full:7 (diffuse_map + emission_and_illumination_map).

And you can merge both maps by putting the illumination data in the alpha channel of the emission map as shown on cube 7.
Many thanks, I'll have a look. I have got the test suite but haven't run it yet as I've been busy trying to sort this problem out. :?
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Help needed with light-maps

Post by Smivs »

Ahruman wrote:

The suggested approach is to convert the maps into a single emission map. This can be done in two ways:
  • Oolite does all the necessary processing when you use illumination and emission maps in non-shader mode, but to make it save the new emission map you need to build it yourself and change “#define DUMP_COMBINER 0” to “#define DUMP_COMBINER 1” in OOCombinedEmissionMapGenerator.m. I appreciate that this is a tad inconvenient.
  • In a layer-based editor such as Photoshop, Acorn or GIMP: put the diffuse map in the bottommost layer, then the illumination map in Multiply mode, then the emission map in Lighten mode.
I really haven't got a clue what the first bit means but the second method looks like something I could try. I use Gimp. Do I save the resulting image as a .png or will it have to be a .xcf to preserve the layers?
Ahruman wrote:
Smivs wrote:
I've got both working independently, but when I try to use both, only the emission map seems to work, or just the illumination map if I reverse the order they appear in the code.
This is highly unlikely. The order things appear in a dictionary should have no effect whatsoever. It’s more likely that you’re seeing a pattern that isn’t there. (are you holding down shift while restarting Oolite?)
It struck me as odd as well. I do hold down 'shift' on re-starts.
Ahruman wrote:
The only reason I can think of for something like that would be if you were using a graphics card with only two texture image units. You can get your texture image unit count by running the material test suite, or with console.glFragmentShaderTextureUnitCount in the debug console.
This is why I've only just started looking at this. I don't have a graphics card, only one of those Intel Graphic Accelerator things on the (Asus) motherboard.
Ahruman wrote:
Smivs wrote:

Code: Select all

materials = 
{ 
    "python_redux.png" =
    {
        diffuse_map = "python_SS.png";
        emission_map = "python_em-map_SS.png";
        illumination_map = "python_illum-map_SS.png";
    };
};
There’s nothing obviously wrong with that (except the lack of a namespace prefix on the texture names), but I can’t really say more without the files.
Sorry to be dim, what's a namespace prefix?
Ahruman wrote:
Smivs wrote:
The illumination map (white ellipses on a black background) also seems very bright, even when the ship is facing the sun. How do I reduce the effect? Do I just make the White Grey or is it not that simple.
That’s generally the best way. Using a modulate colour as Eric alluded to might preserve subtle detail better on some hardware in shader mode, at a very small performance penalty.

The material documentation is currently outdated. The modulate colour for emission maps is now emission_modulate_color, and for illumination maps illumination_modulate_color.

The best, most up-to-date example of this stuff is the material test suite.
I'll have a good look at the Test Suite over the weekend. Thanks for the help...I may be back for more! :)
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Help needed with light-maps

Post by JensAyton »

Smivs wrote:
I really haven't got a clue what the first bit means but the second method looks like something I could try. I use Gimp. Do I save the resulting image as a .png or will it have to be a .xcf to preserve the layers?
Save it as PNG. Oolite has no use for layers – the point is to do the compositing work in advance, not provide a different way to tell Oolite to do it.
Smivs wrote:
Sorry to be dim, what's a namespace prefix?
When looking up files by name, Oolite doesn’t distinguish between different OXPs (or the game itself) – all names are in the same category, or “namespace”. If two OXPs have identically-named files, they will collide and only one will be used.

The way to avoid this is to prefix each name with something intended to be unique, such as your own name, thus establishing your own “namespace”.

In other words, your textures should have names like “smivs_python_em-map_SS.png”. The same applies to models, AIs, and global script identifiers like script names and mission variables.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Help needed with light-maps

Post by Smivs »

Ahruman wrote:
Save it as PNG. Oolite has no use for layers – the point is to do the compositing work in advance, not provide a different way to tell Oolite to do it.
OK, thanks, so how do I reference it in the code...an emission map is

Code: Select all

 emission_map = "whatever-its-called.png";
what should I call this multi-layered composite thing?
Ahruman wrote:
Smivs wrote:
Sorry to be dim, what's a namespace prefix?
When looking up files by name, Oolite doesn’t distinguish between different OXPs (or the game itself) – all names are in the same category, or “namespace”. If two OXPs have identically-named files, they will collide and only one will be used.

The way to avoid this is to prefix each name with something intended to be unique, such as your own name, thus establishing your own “namespace”.

In other words, your textures should have names like “smivs_python_em-map_SS.png”. The same applies to models, AIs, and global script identifiers like script names and mission variables.
Oh, OK, I've used a suffix... the "_SS" is for Smivs'Shipset. Hope that does the same job.[/code]
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Thing is smiv in years to come - tracing a dodgy something-or-other in an OXP - will anybody (including you) remember SS stands for smiv's ships - at least with your name at the front we'll be able to hunt you down... :wink:
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Help needed with light-maps

Post by JensAyton »

Smivs wrote:
Ahruman wrote:
Save it as PNG. Oolite has no use for layers – the point is to do the compositing work in advance, not provide a different way to tell Oolite to do it.
OK, thanks, so how do I reference it in the code...an emission map is

Code: Select all

 emission_map = "whatever-its-called.png";
what should I call this multi-layered composite thing?
It’s an emission map, as in “convert the maps into a single emission map”.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

DaddyHoggy wrote:
Thing is smiv in years to come - tracing a dodgy something-or-other in an OXP - will anybody (including you) remember SS stands for smiv's ships - at least with your name at the front we'll be able to hunt you down... :wink:
Yes, I'm looking forward to being haunted by my OXPs in years to come!
It's a good point though, and one I should take on board.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

OK, some progress. I've done the map now, and it's starting to work. The problem is the base texture isn't showing, so I've got the light maps working nicely on a white silhouette. :?
Is this because the backgrounds to the emission and illumination images are black?
Really appreciate the help, by the way. Thanks. :)
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Smivs wrote:
Is this because the backgrounds to the emission and illumination images are black?
No. They can only ever lighten the ship.

Any messages in the log?
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Ahruman wrote:
Any messages in the log?
No. Just had a look and there's nothing helpful there. It's getting late, so I'll have a look at this in the morning with a fresh mind.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Back again this morning and still no further progress. It seems that I can only get two elements working at any one time, but not all three (diffuse map, emission map and illumination map).
I'm starting to wonder if it's not me but the computer. As I mentioned before I only have an Intel Graphics Accelerator, not a pukka graphics card, and I think this may be the limiting factor.
Is this possible...am I wasting time trying to get the un-workable to work?
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Run, don’t walk, to the material test suite and compare it against the sample screen shots. The most interesting one is test six; compare it to the sample screen shot. If you can see the blueish spotlight effect, the glowing green ring (unfortunately not very obvious, but in shadow it should have a green tint) and the white 6, you’re seeing a diffuse map, an emission map and an illumination map all at once.
Post Reply