Lightmaps have only one color
Lightmaps have only one color
Hi, I have created a small tool to create my own lightmaps for my own map format. The created lightmap textures look good but when I load this textures and add it as a lightmap the whole texture is lighted by the same color.
Example:
A lightmap for a piece of wall is blue on the left side and becomes more green every pixel to the right. When I use the lightmap on a texture, the texture is lighted only with the same blue.
The lightmap is smaller then the texture and I use a different color format:
Texture: 64x96 Pixels, A8R8G8B8
Lightmap: 8x12 Pixels, R8G8B8
Is this the problem?
I have added the lightmap texture to the material as the second material texture (index 1) and the normal texture as index 0. The material type is EMT_LIGHTMAP.
Here you can see what I mean:
On this picture you can see 4 pieces of a wall with the same base texture and 4 different lightmaps. The lightmaps are all colored in one color but the texture of the lightmap isn't.
Thanks for help.
Example:
A lightmap for a piece of wall is blue on the left side and becomes more green every pixel to the right. When I use the lightmap on a texture, the texture is lighted only with the same blue.
The lightmap is smaller then the texture and I use a different color format:
Texture: 64x96 Pixels, A8R8G8B8
Lightmap: 8x12 Pixels, R8G8B8
Is this the problem?
I have added the lightmap texture to the material as the second material texture (index 1) and the normal texture as index 0. The material type is EMT_LIGHTMAP.
Here you can see what I mean:
On this picture you can see 4 pieces of a wall with the same base texture and 4 different lightmaps. The lightmaps are all colored in one color but the texture of the lightmap isn't.
Thanks for help.
No idea? Here is the code for adding the lightmap texture:
PixelData is a static array of bytes containing the pixel data in R8G8B8 format.
Code: Select all
irr::video::ITexture* TextureManager::AddLightmapTexture(word Index, word Width, word Height, byte* PixelData)
{
irr::video::IImage* Image = irrVideoDriver->createImageFromData(irr::video::ECF_R8G8B8, irr::core::dimension2d<irr::s32>(Width, Height), PixelData, false, false);
if(Image)
{
char LightmapName[16];
sprintf(LightmapName, "Lightmap%04d", Index);
irr::video::ITexture* Texture = irrVideoDriver->addTexture(LightmapName, Image);
if(Texture)
{
Image->drop();
return Texture;
}
Image->drop();
}
return 0;
}
PixelData is a static array of bytes containing the pixel data in R8G8B8 format.
I can check if you like.
But please, ZIP small example with main.cpp, diffuseMap and lightMap that you using -- so i can test it.
p.s.: possible it is a driver bug, so it is good practice to check any visual artifact on more that one machine.
p.p.s.: you can use http://filebeam.com/ to share the ZIP.
But please, ZIP small example with main.cpp, diffuseMap and lightMap that you using -- so i can test it.
p.s.: possible it is a driver bug, so it is good practice to check any visual artifact on more that one machine.
p.p.s.: you can use http://filebeam.com/ to share the ZIP.
1. if you using OpenGL -- you must use textures with sizes of power of 2, if you use direct x -- it is not a "must" but it is a good practice.
it is better to change texture coordinates of vertices so part of the textures not used at all then using non power of 2 sized textures.
2. if you cannot give an example-project -- please, supply your maps (diffuseMap and lightMap).
it is better to change texture coordinates of vertices so part of the textures not used at all then using non power of 2 sized textures.
2. if you cannot give an example-project -- please, supply your maps (diffuseMap and lightMap).
1. Yes I know but the basic textures are also non-power-of-two textures and work fine. I have testet some texture sizes. Important are only dimensions that are multiples of 4. I use DirectX9 btw.
2. As I said before the lightmap textures are ok. I have saved them as bitmaps and checked the colors. With lightmap textures I mean the color data and dimensions of the texture. It is also possible that the texture creation is the bad boy. I don't know if lightmaps should have an alpha channel or some important properities. At this time they are only RGB-Textures which represents the overlay colors for the texture. 1 Pixel in the lightmap should be 8x8 Pixels on the texture. Or should lightmaps have the same size than the textures?
2. As I said before the lightmap textures are ok. I have saved them as bitmaps and checked the colors. With lightmap textures I mean the color data and dimensions of the texture. It is also possible that the texture creation is the bad boy. I don't know if lightmaps should have an alpha channel or some important properities. At this time they are only RGB-Textures which represents the overlay colors for the texture. 1 Pixel in the lightmap should be 8x8 Pixels on the texture. Or should lightmaps have the same size than the textures?
The problem seems to be the format a lightmap is used by irrlicht. I have tried A8R8G8B8 and add one 0xFF-Byte to every color-triple. Nothing changed, so it was the alpha byte.
Then I changed a few bytes in the middle of the data and nothing changed in the game.
But when I change the first 4 bytes to 0xFFFFFFFF (white) there is no white lightmap but the blue light appears more brighten on the walls. This is confusing me. How a lightmap texture should be passed to the irrlicht engine? How should it's data look like?
Next confusing thing is that textures which haven't got a lightmap will be white when I set the first 4 bytes to white in another lightmap.
When I pick a green color for the first 4 bytes the texture will be green but with blue light upon it (when there is blue light next to the quad). I don't understand this.
Then I changed a few bytes in the middle of the data and nothing changed in the game.
But when I change the first 4 bytes to 0xFFFFFFFF (white) there is no white lightmap but the blue light appears more brighten on the walls. This is confusing me. How a lightmap texture should be passed to the irrlicht engine? How should it's data look like?
Next confusing thing is that textures which haven't got a lightmap will be white when I set the first 4 bytes to white in another lightmap.
When I pick a green color for the first 4 bytes the texture will be green but with blue light upon it (when there is blue light next to the quad). I don't understand this.
I have played a bit and i guess it is a bug of Direct3D renderer.
Here i posted it -- http://irrlicht.sourceforge.net/phpBB2/ ... p?p=145313
Here i posted it -- http://irrlicht.sourceforge.net/phpBB2/ ... p?p=145313
I don't think this is the problem because with OpenGL I get the same results and I can see the lightmap but only the first pixel seems to be the color for the whole lightmap texture.
I found the following line in the irrlicht code:
Looked like this means that only the first pixel is used for modulation but when I comment this out I get the same results.
I found the following line in the irrlicht code:
Code: Select all
pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
Looked like this means that only the first pixel is used for modulation but when I comment this out I get the same results.