Lightmap Question

dbrock

11-03-2008 19:02:56

We've generated a light map in max for one of our levels (following the tutorial on the ofusion website). The entire level is one mesh, using multiple materials.

So I'm not sure how I would go about applying this light map to our level mesh, would it just go within' one material? Or on each material?

The tutorial doesn't specify any information about the material, it's mostly about the light map generation itself, and not how to apply it.



Thanks

Evak

12-03-2008 04:43:01

When you build your material in ofusion, you choose an Ofusion material, then Ofusion technique in the material dialoge, Ofusion Pass, in the first technique slot. Now your at your pass where you can layer textures.

In each slot you can put a Ofusion Texture Unit, too many features here to explain.

Put your lightmap in one slot, and your diffuse map in another and see what happens. You can blend between layers using various blendmodes, the more popular ones are mentioned in the ofusion help.

It seems complicated at first, but the purpose is to give you maximum flexibility. Hope that helped a little.

dbrock

12-03-2008 05:30:46

I'm familiar with the material system somewhat with ofusion, but I'm just wondering, since the mesh basically was textured by selecting faces and applying certain textures, i can't just drag the lightmap texture to the overall mesh, it would just overwrite all the textures we applied to begin with.

I haven't tried adding a new texture unit to one of the materials and applying the lightmap to it to see if it works, i figured i'd ask first to save some headaches. I'm the programmer, not the artist, so I have to forward the information to them heh.

We were originally going to use Gile for lightmaps since they're simple, and the export process was very easy, the material files were created for you, etc. But we ran into a snag where some lights wouldn't illuminate certain faces. The project is too far along now to go back and re-map, so we're onto different alternatives.

The Gile materials would do the diffuse texture first, and the lightmap second with an alpha_blend mode, so I'll try it using that same method and see what happens.

Evak

12-03-2008 05:50:23

hmm, if you have 3dsmax 2008 this might help. I was messing with lightmaps a long time ago and still have a test scene which I rared up. Has the materials intact. so you can see how they were constructed in 3dsmax.

My materials have tiling diffuse textures with a second UV channel containing the lightmaps. 960k



lightmap example:



http://www.flow3d.org/AD/Lightmap.rar

I'm familiar with Giles, used to use it a little when I made games with Blitz3d. My lightmaps are set up in a way that should be compatible with how Giles works.

dbrock

12-03-2008 07:04:33

Thanks for that! Unfortunately, I don't have 3dsmax 2008, is there any chance you can save the max file for max 9 compatibility? We've got the educational version at school.

Evak

12-03-2008 16:01:29

unfortunately I don't use max 9 anymore and its not installed. But it looks likethe lightmap goes in the texture unit below the diffuse, on a second UV channel.

One thing to watch out for is that Ogre starts at UV channel 0. So if you use UV2 for lighmaps, UV2 is acually 1 in Ogre materials.

I didn't use any blendmodes in the screenshot earlier, just had the diffuse in UV Map channel 0 texture unit 1, and Lightmap in UV map channel 1 texture unit 2.

Giles supports multiply mode that can be used to make a sort of bloom effect and enhance shadows which can look nice. Not sure what the blendmodes are, I mostly use shaders now.

dbrock

12-03-2008 23:42:52

Believe me, once this truck load of a game project is over with, I can spend more time learning about shaders, but as of right now, we're so struck for time it's unreal! 2.5 weeks remaining to get this project done :x.

Thanks a lot for the input, you've been a great help. I'm going to see about getting my hands on 2008 :wink:.

dbrock

13-03-2008 22:32:24

I got myself a hold of 3dsmax 2008 and was able to load up your scene, but the moment I bring up the material editor, the application crashes &.& - very strange!

Lioric

15-03-2008 16:40:49

It might be the CG lib file if you are using the CE version, search this forum for "CG.dll" and "CG.bak" for more details

dbrock

16-03-2008 00:47:38

I renamed the cg.dll to cg.dll.bak and the cg.bak to cg.dll to see if it would fix the problem, and it did not =[.

Evak

16-03-2008 08:25:11

Hmm I don't know. I'm using Ofusion Pro, the only other thing I could think of is that I saved the max file with the ofusion viewport enabled. I noticed that sometimes ofusion doesn't like loading scenes between versions with the viewport already enabled.

I resaved the .max file here 72k. You will have to turn on the ofusion viewport yourself for this one. Maybe it will work this time. Otherwise I don't know.

http://www.flow3d.org/AD/lightmaptest2.rar

dbrock

17-03-2008 16:16:46

Well it was a worth a try, thanks for the effort. The new max file crashes on startup now. And I've tried it with both cg dlls.

Evak

17-03-2008 20:55:02

hmm, that is a strange problem. I only have one computer with 3dsmax on, so I can't test my files and see if they work on another PC here.

dbrock

18-03-2008 04:55:19

I think I figured out how to make it work without using an ofusion material. Think it would be possible to just use a second texture unit with an ofusion material (rather then the self illumination map) on the proper channel with the lightmap loaded.

Evak

18-03-2008 05:07:23

If its any use, this is the material file that is created from the LM scene in my posts. It's a pretty simple fixed function material.

CorridorPlasterWall
{
technique
{
pass
{
ambient 0.7 0.7 0.7 1
diffuse 0.7 0.7 0.7 1
specular 0.25098 0.25098 0.25098 1 75
emissive 0.803922 0.803922 0.803922 1

texture_unit
{
texture_alias Map #14
texture cementwall.png
}

texture_unit
{
texture_alias Map #15
texture LightingMapCorridor.PNG
tex_coord_set 1
}
}

}

}

dbrock

18-03-2008 05:08:44

tex_coord_set 1

Thats the UV channel: 2, right?

Evak

18-03-2008 05:12:45

Thats the UV channel: 2, right?
yeah it is UV channel 2 in 3ds max.

Lioric

19-03-2008 03:54:15

If you are using the CE version, then the issues with the scene when opening the material editor is because scenes created with the Pro version cant be loaded in CE version

But as noted, simply add a new texture channel with your lightmap (this channel must use it specific UV set to optimize texture space and reutilization of the texture images), and then if you need different effects for the lm use its texture unit blend modes

dbrock

19-03-2008 04:05:47

Yep thanks. I think I've got this lightmap business figured out. Some faces weren't receiving any light, but I'm sure thats a geometry issue ( we noticed the problem when using gile ). So I built myself a test scene just to be sure, and everything seemed to work as expected. Thank you both.