3dmax has great light mapping

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Zot
Posts: 15
Joined: Thu May 15, 2008 8:41 pm

3dmax has great light mapping

Post by Zot »

Hello, I know there are posts about lightmapping, but pretty much all the posted links are missing, and posts are a few years ago anyway.
Here's what I want to do:-

1. Bake some nice lightmaps in the comprehensive 3dmax 2008 render-to-texture functions.
2. Export in .x format or whatever is the best for irrlicht.
3. Display them in the mesh-viewer, or anywhere in Irrlicht.

There are many options in Max, one being which channel to use, also it seems to be making tga's for the textures, is that O.K. or is it best as jpeg, or whatever.

Thanks for any help.

Zot.
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

I have successfully loaded light mapped scenes from 3ds max 7 using the my3d format. Not sure if the max exporters will work with 2008.

my3d Homepage

When I first started using my3d, I had some troubles figuring out how to set up 3ds max right. here is a short little tut:

You need 2 map channels. One is for the diffuse map, and the other is for the lightmap. When you do render->texture and your lights are all set up choose LightingMap to generate a lightmap. Then, you need to make sure you do not use an existing channel and overwrite the diffuse uvs. Under "Mapping Coordinates" then "Object", make sure that the radio button that says "Use Automatic Unwrap" is selected and on the right you choose a map channel different from your diffuse channel. You should keep map channel 1 for your diffuse map, and 2 or higher for your lightmap.

Before you export to my3d, in the material applied to that object, you need to have your lightmapped generated by 3ds max in the self illumination map spot box. then, you need the color check box checked, and just leave the box to the right of it as black. You also need to make sure that the self illumination map (the lightmap 3ds max generated) is set to the correct map channel, and vice versa for the diffuse map.


When you export, choose to save the lightmaps as standalone (lightmaps embedded never work for me). You have to create a folder where your my3d model is that is called "Lightmaps" and you need to copy your lightmap there, or already have it there and have the material link to it at that location (that's what I do).

All you have to do to load the my3d model is:

Code: Select all

	scene::IAnimatedMesh* my3dMesh = smgr->getMesh("media/my3dmesh.MY3D");
	scene::IAnimatedMeshSceneNode* my3dNode = smgr->addAnimatedMeshSceneNode(my3dMesh);
One more thing, you do not have to patch Irrlicht to make it load my3d as said on the my3d website linked above. The loader is now integrated in the newest version so you don't have to worry about that.
Zot
Posts: 15
Joined: Thu May 15, 2008 8:41 pm

Post by Zot »

Thanks for your comprehensive reply. The exporter is not compatible with my new 3ds max (2008), it throws an error at boot up - so I'm a bit stuck.

My main reason for a renderer is for a post fx job, and I'll like to give the client a real-time show-real of a beautifully rendered room as a back drop to my effects. So it looks like many light sources, and high-res textures/lightmaps in Irrlicht will do the trick nicely.

It sounds from your answer that using Max is not the usual way of doing things anyway, is Blender more suitable?
I can't use the irrEdit program for many reasons, including placing many lights in the right position is a real arse with it! :roll: The irrmesh files became incredible slow as well.

So what's the best route to take to get these nice light-maps in please?

Cheers,
Zot
Zot
Posts: 15
Joined: Thu May 15, 2008 8:41 pm

Post by Zot »

O.K. Now. I've spent many hours looking into this, and I've got at a little further!
I've created a room, with two simple objects in it, and each has a different material mapped to it.
I can use the Gile[s] engine to import max models.
I then light the scene.
Export from Gile[s] as '.b3d' or 'my3d'
Now when I load into MeshViewer the '.b3d' file has the correct textures but no light-maps.
If I load the '.my3d' file the textures are completely crapped out, with UV's on the walls that move with the camera movement! And the two room objects with no texture at all.

Is the Giles[s] my3D exporter up to scratch yet, or do I just stick with b3d?

And is the mesh viewer O.K to use, I thought it was it worked with the temple.my3D used in the depth blur demo?
The trouble is that there are so many different formats, and file layouts, I guess.


Thanks again,

Zot.
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

sounds from your answer that using Max is not the usual way of doing things anyway, is Blender more suitable?
I don't know where you got that, 3ds max has a great interface for making lightmaps and can do them really well. Blender is a software that is free, and there's no doubt in my mind that it's an inferior product. 3ds max is one of the prime choices for 3d modelers in the gaming industry. If I were you, I'd figure out what you're doing wrong in Gile[s], or find out what you're doing wrong when exporting to b3d. Getting 3ds max 7 just so you can export to .my3d is probably not a good idea.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

3ds max is very cool. blender is awesome.. but if you good/use max use max. if that makes sense.

With max, the lightmaps once rendered to texture arent pinned down, specially if you have UV maps applied. this means in most older formats (x etc) it doesnt store the "modifiers" too well and some stuff gets lost in translation.

Using irrlicht, first use the irrEdit tool to test your meshes, then you can apply the textures by hand and test if it worked. if it has worked, you can use the empty scene of your model, save it as irr and use it in game without a problem see? that way you make it work in irrlicht no problem.
The modifiers you can collapse to one editable poly/mesh etc and then try again cos sometimes its missing things as i said..

The other consideration is that you are confusing the fact irrlicht doesnt work with 3ds natively (this is not a hit on irrlicht, its logic). this means irrlicht doesnt necessarily know exacly what it is you are doing with the meshes and stuff inside max, and you are hoping the export makes it "ready" for irrlicht. there are a few steps to ensure it working (as i have made it work numerous times) you just gotta check that you are speaking the same "language" between irrlicht and max.

I like the obj format, it works really well. and i think the 3ds format works fine too because you can still simply store all textures and what not in the obj material files and irrlicht opens it smoothly without too many problems.

Anyway, im rambling. it works with 3ds and irrlicht. its just how
MikeP
Posts: 25
Joined: Fri May 16, 2008 1:51 pm

Post by MikeP »

Hello

I've been trying for hours and hours to get what I'm producing in 3DSMax7 in Irrlicht but all I get are black meshes. That's very frustrating because I have a stupid little tool to make fast maps called Maplet, there's a button called Lightmap which generates it, then I export in .B3D .. then import in Irrlicht and I get the correct result. But I want to use Max since obviously I'd like to make better stuff than what Maplet is producing. The problem is whatever I'm doing I simply can't even get a stupid Cube textured.
What I'm doing :
- create a mesh (a cube !) , create a light casting shadows, nothing else (actually I added a cube as ground that I mixed with the other and converted as Editable mesh.. well, nothing complicated)
- applying a material (nothing fancy.. I tried with composed multi-material (common for games....) but since it wasn't working I thought.. ok let's start by simply using a standard one with a texture I picked in the max\maps folder
- render-to-texture > output > lightmap, letting the autounwrapp assigning a different canal than diffuse
- export as My3D > I tried both embedded / non embedded textures , nothing works
- getMesh/AddAnimatedMesh in Irrlicht

>>> ALL BLACK no textures :-(

I didn't understand that part in frostysnowman explanation :
Before you export to my3d, in the material applied to that object, you need to have your lightmapped generated by 3ds max in the self illumination map spot box. then, you need the color check box checked, and just leave the box to the right of it as black. You also need to make sure that the self illumination map (the lightmap 3ds max generated) is set to the correct map channel, and vice versa for the diffuse map.
"In the material applied..." ... in the Material editor ? (M)
"your lightmapped generated by 3ds..." ? since you said "before export to my3d" ... what should I understand... the map isn't generated yet?!
"self illumination map set to the correct map channel and vice versa" .... uh? a little more detailed please? thanks :P

I'd be glad if anyone could enlighten me (hehe ..I still have some humor) on this because this is driving me crazy that I can create in 2 minutes with a few clicks a lightmapped room with Maplet/Irrlicht and I can't do it with 3DSMax/Irrlicht (yet).

Thanks!
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

First, try this if you haven't already:
node->setMaterialFlag(video::EMF_LIGHTING, false);
This must be done if you do not have dynamic lighting in the scene.


Before you export to my3d, in the material applied to that object, you need to have your lightmapped generated by 3ds max in the self illumination map spot box. then, you need the color check box checked, and just leave the box to the right of it as black. You also need to make sure that the self illumination map (the lightmap 3ds max generated) is set to the correct map channel, and vice versa for the diffuse map.

When I say "in the material applied to that object", I am reffering to the material that is assigned to your object that you are planning to export. Then I tell you, to take the lightmap you generated, and set it as the illumination map in the top level of your material (if I had more time right now, I would send you a picture). Once the lightmap is set to be the illumination map, you need to check the check box next to the illumination slot to make sure it is enabled (it's easy to find). You also need to make sure, that the map channels are set correctly to your diffuse map and your illumination map. To do this, click on the slots where your diffuse map and your illumination map (your lightmap) is and it will switch dialogs to show the map independant stuff. In this dialog, there will be a selector for which map channel is assigned to the map you are currently looking at. You need to change this to be the right map channel. For me, the diffuse map is 1, and the illumination map (which is your lightmap) is 3.




Stay tuned, later today I'm going to make a tutorial post on the forums that is more clear and concised and has pictures on how to export properly to .my3d from 3ds max. I'm kind of busy right now :)
MikeP
Posts: 25
Joined: Fri May 16, 2008 1:51 pm

Post by MikeP »

Thanks frostysnowman, I'll wait for your tutorial, I think I'm far from being the only beginner having troubles with this.

I found that :
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7494

and I also discovered in a bitplane's FAQ that it's better to put a light in your scene if you want to see something (or like you said disabling the light flag ..same (now I remember) as in Irrlicht's examples) , this might look super noob but I don't care I prefer to post and say it since others will definitely face the same troubles :D

but if I could see something, that was looking super weird and the texture was moving while I was moving the camera, I know I've read something like this in this forum but couldn't find it again yet.

What's making it hard for beginners now is the jump 1.3 > 1.4 , a lot of things changed and , from a point of view of someone that joined perhaps 2 weeks ago, 75% of the informations here are outdated and not working* and it's a real pain to find out how to turn into 1.4 what was valid in 1.3.
For example, I found that in afecelis's tutorial :
smgr->getStringParameters()->setParameter(scene::MY3D_TEXTURE_PATH, "./data/");

and still didn't find how to say that in 1.4 , and I guess I more than need it to get things working correctly...

Anyway, it's nice of you to take time making a fresh tutorial :)
I'll still be working on this though, maybe I'll succeed one day



P.S : * I started building a console-type class but then I discovered a quake-like one here.. unfortunately, again, it's outdated (I think it had 4 years) and doesn't work anymore on 1.4 (I think it was IrrConsole by M_Trix .. a link I found on Irrlicht's homepage :/ ) It was looking nice... sad
MikeP
Posts: 25
Joined: Fri May 16, 2008 1:51 pm

Post by MikeP »

mesh : nothing fancy, just a cube over another, compound boolean, and converted in Editable mesh

Code: Select all

#include <irrlicht.h>
#include <iostream>
#include <stdio.h>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

int main()
{
	IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(800, 600),32, false, true, false,0);

    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    gui::IGUIEnvironment* env = device->getGUIEnvironment();
    driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

     smgr->getParameters()->setAttribute(scene::MY3D_TEXTURE_PATH, "./data/");
     scene::IAnimatedMesh* mesh;
     mesh = smgr->getMesh("./data/testbox.my3d");

    scene::ISceneNode* test_scene = smgr->addOctTreeSceneNode(mesh->getMesh(0));
    test_scene->setPosition( irr::core::vector3df(0,0,0) );
    test_scene->setScale( irr::core::vector3df(2,2,2) );
    test_scene->setRotation( irr::core::vector3df(0,0,0) );
   test_scene->setMaterialFlag(video::EMF_LIGHTING, false);

	test_scene->setMaterialFlag(video::EMF_LIGHTING, true);
	 
    scene::ISceneNode* skyboxNode = 0;
	skyboxNode = smgr->addSkyBoxSceneNode(
	driver->getTexture("./data/rocky_up.jpg"),
	driver->getTexture("./data/rocky_dn.jpg"),
	driver->getTexture("./data/rocky_lf.jpg"),
	driver->getTexture("./data/rocky_rt.jpg"),
	driver->getTexture("./data/rocky_ft.jpg"),
	driver->getTexture("./data/rocky_bk.jpg"));

	SKeyMap keyMap[8];

	keyMap[1].Action = EKA_MOVE_FORWARD;
	keyMap[1].KeyCode = KEY_KEY_W;

	keyMap[3].Action = EKA_MOVE_BACKWARD;
	keyMap[3].KeyCode = KEY_KEY_S;

	keyMap[5].Action = EKA_STRAFE_LEFT;
	keyMap[5].KeyCode = KEY_KEY_A;

	keyMap[7].Action = EKA_STRAFE_RIGHT;
	keyMap[7].KeyCode = KEY_KEY_D;

    scene::ICameraSceneNode* camera = 0;
    camera = smgr->addCameraSceneNodeFPS(0,80.0f,300.0f,-1, keyMap, 8);
    camera->setFarValue (50000.0f) ;
    camera->setFOV(1.1f);
    camera->setPosition(core::vector3df(0,50,0));
    camera->setTarget( core::vector3df(0,0,0));
    camera->setRotation(core::vector3df(0,0,0));

    device->getCursorControl()->setVisible(false);

	f32 text_rot=0;

    int lastFPS = -1;
    while(device->run())
    {
        driver->beginScene(true, true, video::SColor(255,0,0,0));
        smgr->drawAll();
        driver->endScene();

		  int fps = driver->getFPS();

        if (lastFPS != fps)
        {
                   lastFPS = fps;
        }
    }

	// kill device

    device->drop();

    return 0;
}

Image
I've read I should put Diffuse in Target texture location.. true? there's also Auto-illumination in there...

Image
is this what I should do ? the lightmap are created in TGA , important? not important?

Image
canal texture set to 3 for the autoillumination texture

Image
canal texture set to 1 for diffuse texture (standard material with a bitmap)

Image
my3D export options as in the other tutorial...

Image
awesome result in Irrlicht...
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

Post Reply