Jump to content

Quick And Dirty Lightmapping In Leadwerks


Guest Red Ocktober
 Share

Recommended Posts

Guest Red Ocktober

after looking at the latest image from the upcoming Leadwerks 3 editor of a lightmapped scene, and also because of the limited capabilities of the machine i'm currently forced to use ( my main dev machines are down and out for the count and i'm using an antique system with a gefore 6200 era video card), i decided to see if i could do some lightmapping in Leadwerks 2.5 in hopes that i could find a way to get a scene up and running that wouldn't drag my system's performance down to that of a slide show...

 

point lights are great in LW, they provide really decent lighting and shadows, but they also inflict a noticeable performance hit when they are used in even the simplest of scenes... especially if more than one point light is used ... paradoxically, point lights appear to degrade performance at a higher degree than the use of complex geometry...

 

using lightmaps seemed as if it would provide a means of circumventing this while providing an alternative way of getting some similar lighting and shadowing effects... so, i decided to try out a lil quick and dirty experiment using only the low cost tools i already had available... no texture baking, no complex logic...

 

below is the results of the first experiment...

 

LeadwerksLightmapping2.jpg

the textured cube was lightmapped in Giles, exported as two .x files (.x and the .x_lmap) and then merged together in UU3D and exported as a Leadwerks .gmf...

 

next, two .mat files were written up to correspond to the two mat file entries in the model viewer, one each for each mesh merged in UU3D... the .mat file for the lightmapped mesh part was inspired by something i did a ways back (the Mercury space capsule with the transparent placard) on the idea that i could get a lightmap effect by using the identical meshes spit of by Giles and making a mask out of the lightmap image used by the lightmap mesh it produced, and setting the blend to alpha, similarly to how i did the flag and United States placards on the spacecraft model...

 

the circular light (simulating a flashlight pointing at the cube), and the lighting on the top of the cube (simulating an omni light abive the cube), are entirely the results of the lightmap... no Leadwerks lighting contributed to the effect...

 

the terrain in the screenshot is lit normally by the single directional light (subdued and darkened)...

 

these initial results turned out better than i expected... not great, but definitely something worth pursuing... and this almost doubled the frame rate on the antiquated system i'm currently using when compared to the same scene with a single point light...

 

 

--Mike

Link to comment
Share on other sites

Guest Red Ocktober

this new fangled hi tech cloud stuff... i must be getting too old to understand how to use it... or maybe it was due to the fact that i was up all night on this d@mned computer biggrin.png

 

how 'bout now... is it visible?

 

--Mike

Link to comment
Share on other sites

Guest Red Ocktober

more lightmapping experiments with a mesh i had from done in 3DRAD...

 

same technique as above... again, i'm degrading the abilities of Leadwerks to see how stuff runs on low end systems (like the one i'm relegated to for the forseeable future)...

 

the subject machine for these is a Dell Optiplex something or the other with a GeForce 6200...

 

 

Dungeon scene with no lights... (atmosphere in scene though not needed) 17 fps in editor... 19 fps in lua app...

 

LeadwerksLightmapping5.jpg

 

LeadwerksLightmapping6.jpg

 

 

Dungeon Scene with 1 point light... just one point light... brought the same exact scene down to 5 to 6 fps in editor... about same in lua project... Though it looks a lot better than the scene with no lights, the performance hit is significant on low end systems, with just a single point light in the scene...

 

LeadwerksLightmapping3.jpg

 

 

LeadwerksLightmapping4.jpg

 

it appears that a single point light will degrade performance more than that the addition of more complex geometry...

 

Dungeon Scene with no lights, atmosphere added with contrast, brightness, and saturation turned up...

 

LeadwerksLightmapping7.jpg

adding an atmosphere doesn't seem to cause any performance hit at all...

 

so there it is... for those targeting low end...

 

i guess L3 will perform even better since a lot of L2 capabilities haven't been included...

 

--Mike

  • Upvote 2
Link to comment
Share on other sites

Guest Red Ocktober

from Giles, you get 2 meshes if you export as .x files...

 

i loaded them both into UU3D (loaded the .x merged the .x_lmap)...

 

saved as .gmf which saves the hierarchy... when loaded into model viewer

you can see the different sub meshes and .mat file entries...

 

just write up the material files to correspond...

 

the .mat file for the lightmapped sub mesh typically would look like this...

 

texture0="abstract::Lightmap01.dds"
blend=alpha
depthmask=0
zsort=1
overlay=1

 

this blends the lightmap output image (masked transparent image) with the textures below...

 

hope that helps... like i said, it's a quick and dirty approach smile.png

 

--Mike

Link to comment
Share on other sites

What do you mean when you say "saved from UU3D to gmf using hierarchy and sub meshes" ? ... You mean you actually get two meshes inside the .gmf from UU3D, not just one mesh with 2 surfaces each having it's own .mat ??? I was under the impression sub-meshes were not possible with UU3Ds gmf exporter..

 

Have you considered making a second uv channel for the baked lightmap texture in giles (i'm assuming that's what it's for) and using one of the leadwerks *_gi shaders ?

 

 

- edit:

Just trying out Giles, somehow all my .obj's came in flat as paper, is this normal or am I doing something wrong?

Link to comment
Share on other sites

Guest Red Ocktober

i didn't say that i "saved from UU3D to gmf using hierarchy and sub meshes"...

 

i didn't change any settings in UU3D... i simply loaded the x. mesh (that Giles output), then loaded the lightmap .x mesh (that Giles also output), then saved as .gmf... (no bones and anims) that's it...

 

before you save from UU3D, ya gotta make sure the material names match the mesh group names in UU3D... (no extensions and no spaces in the names)...

 

these names will be what you see in the model viewer when the hierarchy is exploded... (ie Surface 1-> Material->algaebricks.mat) they're what i used to name the .mat files (one each for each separate texture) when i created em...

 

here's the files (for the first lightmap experiment above... the cube):

 

https://docs.google....dit?usp=sharing

 

download, and unzip the folder to your Leawerks/models folder, then open up the Leadwerks editor and add a tmix2 object to the scene...

 

 

the files are as follows:

 

trimix.x and trimix_lmap.x -- output from Giles

 

load each one into UU3D (merge the second one) and look at the groups and materials box...

make sure the material names match the mesh group names... no extensions and no spaces in the names...

 

tmix.gmf -- saved from UU3D as .gmf

 

i hope this helps show what i'm doing here...

 

--Mike

Link to comment
Share on other sites

ah... ok i think what was confusing for people was that you said:

saved as .gmf which saves the hierarchy... when loaded into model viewer

you can see the different sub meshes and .mat file entries...

In actuality, UU3D just makes it one mesh with two separate surfaces and the lightmap surface material uses 'zsort' to place it on top. Still looks nice and in this case it might be better to only be 1 mesh.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Well, i think you could actually extract a second lightmap for dynamically switching them e.g. if a lightning strikes or the classic "lightstyles" e.g. wave + flickering lights - however, doing the light setup in the lightmapper, exporting the light positions used (for pointlights in le, doing specular highlights) and generally organizing / sorting parts of a model from a level and its lightmaps ... seams to be a tedious and quit annoying workflow imho.

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

Guest Red Ocktober

because you put it in there... and i don't know how to disable it...

 

because... the scenes you see above run at 20 + fps without any lights... and 5 to 6 fps when a single point light is added... 23.8 fps from a lua interpreted app run from script editor... with an atmosphere added...

 

because of the hardware i'm stuck with at the moment every frame per sec counts...

 

because the deferred renderer amy still come in handy in given situations...

 

but mainly because Leadwerks 3 is still a sugar plum, dancing in my head...

 

maybe after xmas in February, and i get to play around with 3's built in lightmapper, i'll be able to abandon all this...

 

 

--Mike

Link to comment
Share on other sites

Guest Red Ocktober

yeah to that Chris...

 

in the meantime... here's another shot of no lights (with atmosphere) running at an astounding happy.png 28+ fps from a BlitzMax executable...

 

LeadwerksLightmapping8.jpg

 

 

--Mike

Link to comment
Share on other sites

Guest Red Ocktober

thx for the linky... looking at it now...

 

yeah, that sounds like it should be good enough for ocean 3... i mean seeing as everything else graphics related appears to have been degraded...

 

thanks again Shad...

 

--Mike

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...