PDA

View Full Version : [APP] I dug up my old Lightmap extraction application for Mental Ray Lightmapping



jahrain
January 7th, 2008, 06:18 AM
Due to several requests, I decided to dig through some old back up disks and find that old lightmap extraction tool I started a long time ago and release it to the public. I never finished it. But its in a usable state. I was planning on adding the feature of extracting and placing scenery objects and such on the map for accurate texture baking, as well as setting the shader properties of each surface to reflect the actual bsp itself. I never got around to doing that, so all I have here is just a modded version of my bsp extractor that extracts the bsps with the UVs from the lightmaps.

Its up to you to figure out what all you can do with this tool.

Link to file (http://jahrain.com/stuff/bsp_lightmap_extractor.rar)

Also, read the readme before asking anything.


Hek BSP lightmap extractor
by Jahrain

NOTE: THIS TOOL IS UNSUPPORTED AND INCOMPLETE.

I am releasing due to several requests. What this does is extract the map BSP geometry from BSP tags with the lightmap UVs applied to them after radiosity has already been run. With this, you can import the geometry into an application such as Maya, or 3ds max and use the texture baking feature export your own lightmaps for a map. Lighting can be more customizable with this tool, as well as much high quality and resolution than HEK's radiosity.

Instructions:

Extraction:
Load up your scenario_structure_bsp tag into the app via File -> open.

Click Convert!

Wait for it to finish processing the file, then save the .obj file.

Lightmap baking:

NOTE: I will not go into detailed instructions for this. I assume the user of this tool already knows how to use the texture baking feature of what ever application this will be baking lightmaps. If you don't know how, google for tutorials.

First, load up your original lightmap bitmap tag in guerilla.

Take note of each bitmap size and their index. The obj file is grouped according to its corresponding lightmap index. When you bake the lightmaps, you want the size of each lightmap bitmap to be consistently scaled. If the size of one of the original bitmap is 64x128, in the texture bake options, set it to that same size, or any proportional power of 2 size if you want higher resolution lightmaps. BE SURE TO USE A CONSISTENT SCALE FOR EACH BITMAP!!! Make sure each individual group has its own texture baking set and name them by their its size and lightmap index.

Next, set up the lighting in the map to be consistent with your skybox. Add individual lights, or illuminated surfaces as well so that they may also emit light onto the map.

Place any scenery models you have in the map onto the geometry as well so that they may cast shadows.

Batch bake all your texture bake sets, then apply them to each surface to test how they look.

Compiling bitmaps:

Create a large blue (0,0,255 or 0000FF RGB color) sheet document in either mspaint of photoshop (just an empty document, with a pure blue background). Its size should be large enough to have each bitmap placed on the blue sheet with at least 2 pixels in between and around the edges. For example, if you have 4 bitmaps, each of 128x128, your blue sheet should be at least 524x132 to fit all of the bitmaps with a 2 pixel thick border.

Next copy paste each bitmap file onto the blue sheet. Order them so that the top left most bitmap is the first index, and the bottom right most bitmap is the last index. IT IS VERY IMPORTANT THAT YOU ORDER THEM BY LIGHTMAP INDEX OR ELSE THEY WILL NOT BE APPLIED PROPERTLY TO YOUR BSP!!! Its best to just line the up vertically in on your blue sheet regardless of size. MAKE SURE EACH BITMAP HAS AT LEAST 2 PIXELS OF BLUE INBETWEEN AND AROUND THE BOARDER OF THE BLUE SHEET OR ELSE IT WILL NOT COMPILE PROPERLY!

Save the blue sheet into what ever bitmaps folder you have for the map.
Using tool, compile the bitmap. It should create a single bitmap, just like your lightmap bitmaps. You may want to use 16bit uncompressed for the format so you don't have lossy lightmaps. Also, set the usage to Lightmaps. Be sure to recompile the bitmap.

Replace your old lightmap bitmap tag with your new one, or change the reference in the structure bsp tag.

Load your map in sapien to test how it looks. If anything is off, back track until you find the issue. The most common mistake is not ordering your bitmaps properly in your blue sheet. Also, ensure that your bitmap count in the bitmap tag matches the old lightmap bitmap. If any is missing, that’s not good. If it crashes sapien, then you probably didn't compile it correctly. If most things look good, but there is a black jaggies or lines on the lightmap texture seams, go back to your baking options and enable color bleeding.


I WILL NOT PROVIDE ANY FURTHER SUPPORT FOR THIS APPLICATION. DO NOT USE THIS TOOL OR METHOD FOR LIGHTMAPPING UNLESS YOU KNOW WHAT YOU ARE DOING!

demonmaster3k
January 7th, 2008, 07:31 AM
idunno jahrain sounds nice, but doesn't this belong in the releases section?

jahrain
January 7th, 2008, 08:09 AM
Oh yeah, forgot about that section... Anyways, I really wouldn't like to call this an official release. Its just something I dug up. If the mods see it necessary, it can be moved.

Bad Waffle
January 7th, 2008, 08:40 AM
i think i'll screw around with this tool. Thanks.

Kornman00
January 7th, 2008, 10:58 AM
moved w/ redirect :)

SuperSunny
January 7th, 2008, 06:03 PM
Thank you!

Con
January 7th, 2008, 08:07 PM
awesome, I was wondering what ever happened to this.

Invader Veex
January 7th, 2008, 10:11 PM
Oh goody. *happyface*

kenney001
January 7th, 2008, 10:50 PM
this is exactly what I needed. +rep...

kenney001
January 8th, 2008, 12:36 AM
I used texture baking for the first time, and within 20 minutes of downloading this:

http://i62.photobucket.com/albums/h94/vote1sanches/raytracelightmap.jpg

raytraced shadows.......this could be exciting to play with...

Botolf
January 8th, 2008, 01:20 AM
So, would there be a way to get this to work in conjunction with gmax?

The blurry shadow crap Sapien gives me fills my heart with sorrow.

p0lar_bear
January 8th, 2008, 08:06 AM
So, would there be a way to get this to work in conjunction with gmax?

The blurry shadow crap Sapien gives me fills my heart with sorrow.

I don't think gmax has mental ray.

Botolf
January 8th, 2008, 09:56 AM
True, but there are ways to render in gmax, I'm just curious if there's a specific addon that would support something like this.

demonmaster3k
January 8th, 2008, 10:15 AM
one question jahrain
do you need this app to export your own lightmaps for texture baking for models that you made (and are ready to compile) or is there another way

Syuusuke
January 8th, 2008, 05:13 PM
I used texture baking for the first time, and within 20 minutes of downloading this:

[pic was temporarily kidnapped]

raytraced shadows.......this could be exciting to play with...

That looks cool, anyone wanna run that through a few other maps :D

jahrain
January 8th, 2008, 06:19 PM
Here was an example I posted long ago when I announced this tool.

This is what it should look like after you baked the textures (Maya).


oh, btw, heres my lightmaps i generated for Bloodgulch.
http://img159.imageshack.us/img159/4121/maya2007053105320956jo3.jpg
http://img129.imageshack.us/img129/3199/maya2007053105322487ln9.jpg

Notice how sharp the shadows are, and also the quality of lighting on th scene. I'll get this ingame for a better idea of what the final product will look like compared to the best you could get from sapien.
And this is ingame:

Ok heres what it looks like ingame. Btw, this in CE, not Halo 2, my H2EK Sapien doesn't work for me, but it works the same way.

Heres Bloodgulch's lightmaps which were generated in sapien
http://img356.imageshack.us/img356/7928/sapien2007053106064990ou3.jpg


And heres a comparison shot of what I did with Mental Ray
http://img458.imageshack.us/img458/9669/sapien2007053106024895ee7.jpg
notice the shadows almost match the detail of the vehicles on the scene


heres some more:
http://img115.imageshack.us/img115/6879/sapien2007053106031732zg9.jpg
http://img115.imageshack.us/img115/8788/sapien2007053106035881gd9.jpg



http://img473.imageshack.us/img473/8456/sapien2007060101305658no3.jpg
http://img473.imageshack.us/img473/3524/sapien2007060101320055zg8.jpg
http://img525.imageshack.us/img525/1928/sapien2007060101324945xq2.jpg
http://img526.imageshack.us/img526/6408/sapien2007060101334156ex6.jpg
http://img525.imageshack.us/img525/8853/sapien2007060101334853ns6.jpg
http://img167.imageshack.us/img167/4575/sapien2007060101353950vo1.jpg
http://img502.imageshack.us/img502/2825/sapien2007060101360595br2.jpg



Oh and this is what the lightmaps bitmap that I had to compile looks like:
http://img123.imageshack.us/img123/3758/lightmap1copyou6.th.jpg (http://img123.imageshack.us/my.php?image=lightmap1copyou6.jpg)
Beware, this is extremely huge; click it after you open it to blow it up to full size (about 2100 x 9500 pixels).

paintballakid5
January 9th, 2008, 10:50 AM
yes i'm just getting into Technical parts of mapping, what ecxactly are Lightmaps?

kenney001
January 9th, 2008, 10:55 PM
nvm

SuperSunny
January 10th, 2008, 06:57 PM
This, btw, will also work for any other renderer, such as Vray. It all depends on use.

LlamaMaster
January 11th, 2008, 10:11 PM
This, btw, will also work for any other renderer, such as Vray. It all depends on use.
:awesome: I was just about to ask if it would work with Vray.

Jay2645
January 17th, 2008, 01:03 AM
Wow, thanks!

Bad Waffle
January 26th, 2008, 10:52 PM
doh, doesnt work on vista :(

EDIT: googled the name of the ocx file that i was missing, dropped it in win32, voila it worked