Jump to content

Lightmap tutorial


Guest Mauler

Recommended Posts

Guest Mauler

If you wish to host this tutorial elsewhere please let us know below..

 

I have finally gotten around to creating a simple tutorial on how to get lighting effects from 3DSMax 8 into Renegade, Some would call this "lightmapping"

when using this and some other tools TT have developed you too can get professional looking shadows, lighting effects... just one thing i should mention, this method is not dynamic lighting, but rather static baked in lighting

 

Let's begin

 

001.jpg

  • Open your completed level, textures are optional, but recommended that the level be completely textured before starting the process. Just easier to render and see the effect the lighting will have on the level

 

 

002.jpg

  • Here I have placed some lights and other atmosphere effects to the scene.

 

003.jpg

  • Let's render [F9] the scene and check out how the lighting looks, Everything looks fine, When you happy with the final product move on to the next step. **Remember to render often to check for lighting errors or glitches be sure to look at all surfaces etc..

 

004.jpg

  • Now that our lights are done, lets hide them and just keep the terrain I want to lightmap visible, First thing you want to do is clone all the terrain pieces you wish to apply the lighting to... In my case, it is the concrete boxes and ground. [Right Click > Clone]

 

005.jpg

  • Now both pieces are cloned simply move them to the side, Leave it there for now, we will work on that in a bit.. As you can see I've moved mine a bit off from center.

 

006.jpg

  • Now select the original two pieces and remove the materials from them [utilities Tab> UVW Remove>Materials Make sure "Set Gray" is checked]

 

007.jpg

  • With the materials off the original meshes, we need to combine them for the lightmap. [utilities>Collapse>Collapse Selected] This will make the pieces into one mesh.

 

008.jpg

  • Now that it is one mesh, we need to apply a UVW unwrap, Select the mesh [Modifiers>UV Coordinates>Unwrap UVW]

 

009.jpg

  • Now that it has applied a UV unwrap we need to flatten all faces for the lighting information. ** Before moving on set the "Map Channel" to 2, we will need to remember this for later

 

010.jpg

  • Under "Selection Modes" click on the third button to the left "Face Sub-object Mode" then select all faces in the scene [Ctrl+A] to select all, then we need to flatten, [Mapping>Flatten Mapping].

 

011.jpg

  • Once that is done just use the defaults that are displayed on my screenshot. Click "Ok" when done.

 

012.jpg

  • The modifier should auto-flatten to something similiar to what i got pictured above. Once that is done, move on to the next step.

 

013.jpg

  • Now we need to render the lighting information to a texture, [Rendering>Render to Texture]

 

014.jpg

  • This will provide a pop-up of the settings of the texture we will render, Set the Padding to 64, Object should "Use existing Channel" then set the channel to 2, we set this channel from earlier...

 

 

 

015.jpg

  • Continue down to "Add" button, Click on it and select "Lightingmap" after it will provide you with the ability to change the file name and type of the texture output [To change output location click on the " ... " ] **For lightmaps I tend to make them DDS with DXT-1 settings, and Use a 256x256 size

 

016.jpg

  • Once you are happy with file name and output location press "Render", You should see a pop up with the lightmap texture, something like my lightmap pictured above. Once rendered close the pop up windows

 

 

017.jpg

  • Now the lightmap texture is applied to the original mesh, At this point we need to detach the single mesh back into the orginal two pieces we started with.. [Right-Click on the mesh>Detach with the element tool] Once complete move on to the next step.

 

 

018.jpg

  • Now this is where the cloned copy of the original comes into play, We need to attach the cloned pieces to the lightmapped pieces. Ground>Ground, Concrete Boxes>Concrete Boxes... Once you attach the cloned copy to the lightmap meshes a pop up will appear [Pictured above] leave those default settings and press Ok.

 

fix001.jpg

  • Now that the pieces are attached together we need to re-apply the materials over the meshes, Once complete move to next step

 

 

fix002.jpg

  • Now the two pieces are retextured we need to get rid of the cloned mesh we made earlier [Mine was the top one] just make the mesh editable and select and delete the cloned mesh [Pictured above]

 

020.jpg

  • We are left with the one piece, Now we need to apply the lightmap texture we made earlier to the materials of the Ground and Concrete Boxes.. Go into the material editor [ M ] and apply the next step settings to the materials.

 

 

021.jpg

  •  Vertex Tab, Stage 1 Mapping should be set to 2
  •  Shader Tab, Pri-Gradient set to "Disable", Detail Color to "Scale"
  •  Textures Tab, Check Stage 1 Texture, And place the Lightmap texture you output earlier here, Click on "Clamp U" and "Clamp V"
  • Once completed close material editor and Export your scene into a W3D

Once all is complete and lightmap textures are applied to the mesh/meshes.. You will need to add a user defined parameter.. Right click, goto properties and goto User Defined tab... There you will see a text box add the line [ Prelit=true ] - everything in between the brackets.. And apply this line to all lightmapped mesh.. This is so that the Renegade vertex lighting system ignores these pre-baked light meshes

 

 

022.jpg

fix003.jpg

  • Here is my completed level with Lightmap applied in W3D Viewer...
  • Enjoy! and experiment!!

 

 

This is what the model looks like without a lightmap texture and using default vertex lighting instead

 

fix004.jpg
 
 

Hope you guys learned a bit from this... you can now go and create some cool looking levels with this method of lightmapping I've provided for you...It can get very complex for larger, more detailed levels, so you will need to dedicate quite sometime to do it right!

I've only covered the basics on this tutorial, but I'm sure you guys can experiment and achieve more... Good luck and please feel free to post any questions you might have about Lightmapping in this tutorial thread... :)

Link to comment
Share on other sites

Guest Mauler

... just one thing i should mention, this method is not dynamic lighting, but rather static baked in lighting

 

Shadows that draw on vehicles/Players are dynamic, and are created separately to a lightmap texture, so no this is not a tutorial for that..... Google up the meaning of "Lightmaps" and you will understand..what they do ... Performance is not really affected It's simply another draw call to put it simply.... 

Link to comment
Share on other sites

  • 1 month later...
Guest Mauler

I've come across a script that forgoes the part where you use "Render to texture" and the section of manually cloning and detaching the merged mesh!! The process is now streamlined to a few minutes... Will be updating and providing a Download for the script and install path for said script...

Link to comment
Share on other sites

  • 1 month later...

Mauler how much better is this than just using light points from LE and what are the differences? Becuase it seems easier to just use the LE light points.

Link to comment
Share on other sites

Lightmaps provide an addtional pass on the default texture that provides shadow, pre-calculated lighting that the vertex point lights cannot simulate.. Lightmaps can give you more control of the lighting atmosphere.. point lights in LE are not the same level as using lightmaps...they are used in unison of each other... lightmaps generate the terrain lighing effects and vertex point lighting provides dynamic lighting to dynamic objects..i.e characters, vehicles

 

*Well to be honest renegade doesn't have dynamic lighting, vertex lights are static.. but do provide lighting info to vehicles and characters, and some other props..

 

 

here is a fine example of the differences of vertex lighting vs. lightmap textured

 

vertex-lightmap.jpg

 

Another image of the difference... this time showing the default model vs lightmapped model - My sniper map C&C_Facility

 

facility_lightmap.gif

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for posting this Tutorial Mauler. Been looking for this for a while now.

As a general question, in my maps I generally put a noise texture down on my terrain to break up the tiling. If I were to put this on a second pass, what would I need to set it for?
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.