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>
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 :
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%
}