Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Material with lightmap

bagg
Registered User
Quote
2010-12-25 10:29:47

Hi Niko.
Merry christmas and happy new year.

I have a custom mesh and i am trying to put the light map material on it.
The lightmap is created with the 3d studio max baked textures and i tried 256x256 size images with png and jpeg formats but it seems that copperlicht is not loading it (i can see it black).

Here is the part of the code i am using.

// set the texture of the material

Gpbuff.Mat.Type = CL3D.Material.EMT_LIGHTMAP;
Gpbuff.Mat.Tex1 = engine.getTextureManager().getTexture("sometexture.jpg", true);
Gpbuff.Mat.Tex2 = engine.getTextureManager().getTexture("sometexturelightmap.png", true);

Can you please help me?

Thanks.


niko
Moderator
Quote
2010-12-26 08:30:55

Hm, does it find the file at all? Maybe you've mistyped the url or some letter?


bagg
Registered User
Quote
2010-12-26 20:16:07

No i didn't because when i am setting the lightmap as texture to tex1 it's loading it ok.Is it possible that this mabe a bug?


niko
Moderator
Quote
2010-12-27 16:29:56

Hm, could be. One possibility is that your texture maybe is no power-of-two texture. If it isn't, try scaling it to something like 128x128, to see if it works then.


bagg
Registered User
Quote
2010-12-27 17:31:24

It's not working.Maybe you must check it out if there is a bug

Thanks


niko
Moderator
Quote
2010-12-29 07:59:28

I tried it out, and found the material is working, but I think I found what your problem might be: You need to set a second texture coordinate for the lightmap. When you are using the Vertex3D structure to describe your 3d model, use the TCoords2 member of it to set a texture coordinate for the light map as well.


bagg
Registered User
Quote
2010-12-29 08:45:23

I did it and i can see the lightmap but the coordinates of texture 2 must be wrong (i used the same as tex1).Can you please tell me how can i get the right texture coordinates for the lightmap?

Thanks.


niko
Moderator
Quote
2010-12-30 07:49:43

I'm also using the same coordinates, like here:


createVertex = function(x, y, z, s, t)
{
var vtx = new CL3D.Vertex3D(true);
vtx.Pos.X = x;
vtx.Pos.Y = y;
vtx.Pos.Z = z;
vtx.TCoords.X = s;
vtx.TCoords.Y = t;
vtx.TCoords2.X = s;
vtx.TCoords2.Y = t;
return vtx;
}


works perfectly for me. Maybe your lightmap texture simply is too dark?


bagg
Registered User
Quote
2010-12-30 09:10:26

I will make some experiments with 3d studio max.
Another thing i wanted to ask you is how can i make a texture tiled?
For example if i have a face 100x100 and i want a tile 10x10 to give as texture the tile and the tile will be repeared 10 times in width and 10 times in depth?

Thanks.


niko
Moderator
Quote
2010-12-30 09:49:27

Simply set the texture coordinate so that the texture gets repeated that often. If you have a quad starting with the texture coordinate (0,0) in the left upper corner and with (1,1) in the lower right corner, the texture will be repeated exactly once. Make it (2,2), it will be repeated twice. And so on.


csp-games
Guest
Quote
2022-01-01 12:40:11

I just had the same problem. using test.jpg as diffuse and actionsign.jpg as lightmap. (from the tutorial example 3)

diffuse tex1 appeared to be completely black, and under the text and arrow of tex2 no blending was visible. I then increased brightness of tex2 by 50%, et voila! Works now, tho it seems the range that can be used is 128 to 255, due to seemingly tex2 being blended using "/2 multiply" (or something), and not just "add" as I would have expected. So the lightmap can darken or brighten the tex1 texels, depending on whether lower or higher than 127,127,127.

Hey Niko how about to release the b3D loader as an open source extension to Copperlicht - if we don't have to reinvent the wheel, this may get a Greta von Thunberg certificate ^^


just_in_case
Moderator
Quote
2022-01-02 06:29:34

Hie, @CSP-Games, Dieter, hope you are doing good. Glad to have you back to the forums :) Happy New Year :))


csp-games
Guest
Quote
2022-01-07 17:59:24

Hey Howdy ^^ Happy New Year to you too! Excuse the delay, I'm on a submarine mission in a sea of Api documentations.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact