Lightmaps for Doom

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.

Lightmaps for Doom

Postby Post » Sun Oct 18, 2020 2:25 pm

First of all - hello there! It's been quite a while since i posted anything here, on this forum. Like about ten years :) But anyways, lets get to the topic. I've managed to bring lightmaps to GZDoom.
Here's shadows from this cube thingy:


And here is some lava ambient light


Light nicely reacts with environment, producing light on the ceiling, but not much on the floor. Attentive observers would also find a bug on this screenshot.


Looks decent to me :) If handled properly, this could produce very nice lighting on your maps. One thing before we dive in, this tutor is pretty advanced, i think. This technique requires you to know not only how to place 3d models inside a doom builder, but also navigating and using Blender for a specific task of baking maps. This technique is about exporting your level into 3d package, baking lights to a texture and bringing that back in Doom, broadly speaking. With that out of the way - how is it done? Well, here's how:

  • First of all, i believe you gotta use Ultimate Doom Builder, since only this thing can export level sectors as OBJ file.
  • Second, you select all sectors that you want to bake lightmaps for
  • Then you export your selection to OBJ format, using file->export->Selection to Wavefront obj... Tick "Export Textures" checkbox in export dialog box.
  • Now you fire up your blender, or any other 3d package that can handle baking various maps. I'm a blender user, so the rest of tutor will focus on blender side of things
  • Import your geometry by clicking this. Rename it to something like "source"


  • Nice! It would look kinda like this. If not, check shading settings


  • Then you duplicate your geo, and scale so it would be slightly smaller then your source geo. You can do this using alt+s.
  • Rename it to something like "target". Remove any materials from your target geo, then add a new one, call it "bake"
  • While this material selected, go to UV editor, add a texture, call it "bake"
  • In shader editor, add your bake image to shader input. Do not deselect the image input, that's important! Result should look like this:



  • Put some lights in your scene! I put mine inside this cube with holes in it, purely to take a look how it would bake something detailed.
  • If you want to achieve that lava ambient light, grab your source geo, navigate to material that you want to emit light. Edit material in shader editor to have this configuration:


  • Switch blender to cycles render engine


  • Get into rendered view mode, then adjust your lights and materials to a desired look.
  • Render preview could be a little noisy, unless you have a RTX with hardware deniosing. Yeah, neither have i :)


  • Alright, time to bake some maps!
  • First select your source geo. Selection order does matter!
  • Then grab your target geo
  • Navigate to this menu and set the checkboxes accordingly and hit that "bake" button! Baking process is a bit messy in blender, it requires user to do a few specific steps to get it right, i'll put some Blender-related tutorial links in the end of this post, this stuff is a bit out of scope of this tutor.


  • When the bake is done, navigate to your image or UV editor, select your bake texture and save it somewhere when you can access it.
  • Now we need to export our geo from blender. Before i export anything game-related, i usually apply any transforms by pressing ctrl+a and hitting "apply all"
  • Select your target geo and export it using file->export->Wavefront OBJ
  • Here are my export settings. Works just fine:


  • Now let's get it into doom builder! I would humbly skip the details, there are quite enough tutorials on how to do this
  • Alright, we're almost there :)
  • Place your model into things mode, make sure that your model fits level sectors nicely, then adjust it's settings. I found out that additive blending is looking quite nice, especially on darker sectors. For extra brightness you can tweak lightmap levels in photoshop for example.
  • Alright, now hit that green triangle and behold!

That tutor was quite long, i suppose. Hope you went through without any trouble! If otherwise, here a few helpful videos for you:
Blender fundamentals:



Baking stuff in blender


Bring your 3d models to Doom Builder


Lastly, i would share some thoughts about what oddities that i encountered during that whole process. First of all, Ultimate Doom Builder has a strange export or import algorithm. Geo that i export back to UDB tends to be slightly squashed in vertical axis, i would suggest eyeball the scale in blender so it would fit level geometry better. It requires some back and forth but it's worth it. Second thing you may consider is scaling. I baked 512x512 lightmap and it was pretty ok for the room i did, but 1024 would be better. So if you would like to bake maps for a whole level, you might consider breaking level geometry into pieces and treating them separately. Or you can to a trick: bake fancy shadows to a plane and put it under your light sources where necessary. In conclusion, i hope that this technique would be somewhat helpful to modders and mappers looking for certain quake-ish kinda look to their creations. Well, that's all folks! For now at least :)
User avatar
Post
 
Joined: 11 Jul 2005

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest