3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2 3 4

Author Topic: Tutorial : Lightmapping with Gile(s)  (Read 7800 times)

« on: May 22, 2011, 03:42:51 PM »
Lightmapping tutorial practical example

Requires :
- Giles(s) 2.0 beta4 - for rendering lightmap/AO maps
- Modeler (I guess any would do, for setting up your lightmapped scene, must support "save selected" or "export selected"
- RadImp (not required but would probably be faster, you could also use install skinmesh from 3DRaD)

First, lightmapping is done for static objects only, like terrains, buildings, and other static props.
You could also lightmap a local dynamic object but it would only be local on itself, like details on itself.

Decide if you want to make an AO scene or a lighted scene (sun) or many lights..

Pure AO :


Sunlight+AO :



Well lets start :

1. Open your modeler and add some models

The trick to sucessfully lightmapping is to position/scale/orient your scene in your modeler and
then export the complete scene and all your objects you want diffrently shaded in rad as seperate skinmeshes.

Ok I added :

1. A small terrain with texture
2. A Ball with texture
3. A man with color



2. Export your entire scene as "LM_scene.x" (or as .obj and convert to .x as I do in Silo)

3. Export each object seperate

Now you probably want to use different shaders on all these objects, normalmap/envmap etc.. inside 3drad (if not skip this step)

Export each object as a seperate object (terrain as one, ball as one and man as one):



You might think : But I already have this object as skinmesh in 3DRad ready to go.
Well but you need to export it as seperate anyway to avoid artifacts when lightmap is applied.

4. Start Gile(s)



Load your complete scene with textures and all from step 2

From menu : File->Open


 
5. Add a SUN

Lets setup a sunlight scene :

From menu : Editors->Lighting Method Wizard

Make sure settings are like this :



CLICK APPLY

6. Create a sun

Now you can place a light (in this example I use an Omni light to be a sun)

   1. Click on Create Tab
   2. Click on Omni
   3. Click somewhere on you map (doesn't matter where just place it)



7. Position the light

   1. Click on the Model Tab
   2. Click on Omni00
   3. Check Infinte (we're making a sun)
   4. Set position with and nice 45 degree angle to it (2500,2500,2500)



8. Render settings

From menu : Render->Render Settings

   1. GI Renderer : Ambient Occlusion
   2. Check enable shadows
   3. Check Enable Anti-Aliasing



CLOSE window using the x at top right.

9. Render your light(s)

From MEnu : Render->Render

Wait a while till it's fisnished.



10. Now export..

From Menu : File->Export->Export  (make sure Auto export Lightmaps is checked)

   Choose DirectX Mesh (.x) and click Save

   Choose you lightmap format

   Click ok on the next dialog.


3DRad part now :


13. Import the following from previous section.

you should now have 4 models to import

   1. A terrain exported from your modeler in 3.  <terrainmesh>
   2. A Ball exported from your modeler in 3. <ballmesh>
   3. A Man expoerted from your modeler in 3. <manmesh>
   4. A lightmapped scene exported from Gile(s) <lightmapmesh> (you only need <name>_lmap.x and the lightmap texture).

   Use RadImp or install custom skinmeshes for all 4 (have skip shadowmesh ticked)

14. Open 3DRad and load each skinmesh model
   <terrainmesh>
   <ballmesh>
   <manmesh>

    Also set the appropriate shader you want to use on each model. Apply normalmaps or whatever you need.
    No need to adjust anything else like Depth-sorting, No Z buffer. Just leave em default.

    BUT!! Make sure you don't move/scale/orient any model as it will screw up lightmapping.
    If you are unhappy with anything you need to redo the scene from scratch in your modeler.

15. Copy lightmap

    Open <3DRad>\3DRad_res\SkinMesh\data\<lightmap mesh>\
    Copy the texture and rename it to userTextureA.dds  (doens't matter if it's bmp/jpg/wahtever)



16. The Lightmap mesh

Last load your <lightmapmesh>, set shader to 0032_user_lightmap and Mode - Shadow-Map



17. And a script

Add a small script and link it to the <lightmapmesh>

Code: [Select]
void Main()
{
   iShaderFloatSet(OBJ_0,"cEmissive",0.45);

}



Congrats you have a lightmapped scene!

TIP1 : If your lightmap seems to disappear when editing in rad or adusting shaders, just reload <lightmapmesh> (highlight it and click R)

TIP2 : If you think it gets to dark you can adjust the script emissive setting, but you could also make all meshes emissive since the lightmap will shade them anyway.

TIP3 : You can adjust gamma on individual skinmeshes by scipt when using user_ shaders like this :

Code: [Select]
void Main()
{
   iShaderFloatSet(OBJ_XX,"cColor",2,2,2); //increase gamma by 100%
}
« Last Edit: May 23, 2011, 01:03:30 PM by shadmar »

fourdee

« Reply #1 on: May 22, 2011, 06:15:03 PM »
Legend!

Will also try this tomorrow :D

Thanks Shadmar, you help so many of us by spending your time on these great tutorials!
« Reply #2 on: May 22, 2011, 08:41:35 PM »
Looks very interesting.. I will have to give it a go tomorrow.

And thanks for making the tutorial. :)
« Reply #3 on: May 22, 2011, 10:32:35 PM »
Looks very interesting.. I will have to give it a go tomorrow.

And thanks for making the tutorial. :)
Me too :)
I ❤ Boxing
« Reply #4 on: May 23, 2011, 12:56:52 PM »
Thanks!

It should be complete now, just fire away if you get any troubles.
Don't try this your on your first 3DRad day :)

« Reply #5 on: May 23, 2011, 04:22:58 PM »
This is awesome, thanks! But one thing, Giles didn't spit out a lightmap texture for me. Must everything be UV mapped?

Mickey
« Reply #6 on: May 23, 2011, 10:14:30 PM »
Phewww! I finally got it working. :)

But a couple things, I noticed people mentioned in other posts and I had briefly attempted before. I wasn't given the option to save any light map images, and the shading wasn't very good. Such as there'd be no shadow at all and only affecting the faces of objects. In your tutorial I did not notice it saying anything about creating the light map in the editor, and once I did that I was able to produce a light map. Second, when I was trying to apply the shading in 3D Rad it wasn't working at all, which I was trying to apply to a complicated scene, so thinking I was maybe doing something wrong. I simply created a plane and a cube producing a shadow, but still no effect in 3D Rad. Then it came to me wondering if the mesh was reading the userTextureA.dds file at all, and so I opened up the file and it was still directed at Lightmap 00.jpg which I saved as. Duh, this was stupid on my behalf, but I didn't see it in your tutorial as well. Whether or not it's suppose to be a no brainer or what, I don't know; despite I thought I'd bring it towards your attention if the tutorial needs correction? :)

But anyways, THANKS again and especially since I've gotten it working it's great ha ha.

Mickey
« Reply #7 on: May 23, 2011, 11:48:32 PM »
My first try was an epic fail.. Giles hung up on me when I tried to load my 40k polygon level..

So, on my second try, I took my semi-truck out of my level and Giles did a great job. :o

Maybe I have too many textures.. there is over 100 64x64 - 128x128 textures in my level.  :-\
« Reply #8 on: May 25, 2011, 08:46:32 AM »
Quote
Then it came to me wondering if the mesh was reading the userTextureA.dds file at all, and so I opened up the file and it was still directed at Lightmap 00.jpg which I saved as. Duh, this was stupid on my behalf, but I didn't see it in your tutorial as well. Whether or not it's suppose to be a no brainer or what, I don't know; despite I thought I'd bring it towards your attention if the tutorial needs correction? :)

Ah you need the Systemshader_shx addon installed to use 0032 shader. You can DL on the addon page.
The shader reads the userTexureA.dds, you mesh should point to the original lightmap as exported by Giles, so you shouldn't need to change anything in the .x from Giles

My first try was an epic fail.. Giles hung up on me when I tried to load my 40k polygon level..

So, on my second try, I took my semi-truck out of my level and Giles did a great job. :o

Maybe I have too many textures.. there is over 100 64x64 - 128x128 textures in my level.  :-\

100 textures? different ones in one mesh ? That I would think would be insanely slow to render as a shader needs to do a pass for each texture. Might be Giles having a problem there, I don't know.

The truck looks nicely mapped :)
« Reply #9 on: May 25, 2011, 08:49:21 AM »
good tut Shad... THANKS...

as usual, your models combined with your shaders look stunning...


--Mike
« Reply #10 on: May 25, 2011, 03:44:42 PM »
Quote
Then it came to me wondering if the mesh was reading the userTextureA.dds file at all, and so I opened up the file and it was still directed at Lightmap 00.jpg which I saved as. Duh, this was stupid on my behalf, but I didn't see it in your tutorial as well. Whether or not it's suppose to be a no brainer or what, I don't know; despite I thought I'd bring it towards your attention if the tutorial needs correction? :)

Ah you need the Systemshader_shx addon installed to use 0032 shader. You can DL on the addon page.
The shader reads the userTexureA.dds, you mesh should point to the original lightmap as exported by Giles, so you shouldn't need to change anything in the .x from Giles
I do have the Systemshader_shx add-on installed, so that is really weird because it doesn't work unless I rename it in the .x file. I'll have a look at it and see if I missed something. :)

Edit:
Alright, it's because I simply renamed my exported texture to userTextureA.dds, rather than copying it and then changing name hehe. ;) Of course both work, with no different effects, if my computer knowledge is correct? ;)
« Last Edit: May 25, 2011, 04:06:00 PM by Mickey »
« Reply #11 on: May 29, 2011, 03:45:57 AM »
Nice tutorial!
But...
I believe I have some problems. It's hard to explain, so here are some pictures.
In the first one the shader is set to 0032_user_lightmap.
In the second one the shader is set 0000_default.
Mode is set to 'Shadow map' in both.
Do you know what the problem is?  ???

By the way, amazing! You got so many views after a week!
« Last Edit: May 29, 2011, 03:47:37 AM by RobertooMolvadoo »
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #12 on: May 29, 2011, 03:53:52 AM »
Only the shadowmap mesh is to use 0032 and mode shadow-map, the rest of the sinmeshes can use whatever shaders you want to shade them with.
« Reply #13 on: May 29, 2011, 03:57:22 AM »
I know. And I did.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #14 on: May 29, 2011, 04:22:56 AM »
This is weird. I tried something else. This is an old mine that I created in GoogleSketchup. See pictures.
For this one the lightmap model is set to default shader and shadow-map.
And for this one it works.
« Last Edit: May 29, 2011, 04:26:59 AM by RobertooMolvadoo »
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
Pages: [1] 2 3 4