Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Light Mapping in DBC Demo

Author
Message
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 1st May 2009 19:31 Edited at: 22nd Jun 2009 12:44
June 22,2009
I've added a tutorial for creating a simple light mapped environment created in Blender and exported to 3ds for use with DarkBASIC Classic.

I chose Blender because the method was actually quite a bit simpler than LightMap Maker. And the resulting media is much smaller bytewise. Though if the time is spent with Light Map Maker to properly set the environment up, the results are quite amazing.

The tutorial is still a bit rough here and there, but I said I'd make one so here it is. Thanks to Zero G Scott for proof reading and catching a few major blunders that I still refuse to admit to.

Blender Light Mapping to DBC

May 1st 2009 (attachment included)
I'm still playing around with the method and idea but thought I post an example of light mapping in DBC. The effects are quite dramatic.

A year or two ago, I downloaded some free light mapping software called Lightmap Maker by AwingSoft. I played with it a bit back then but couldn't figure it out and I just sort of forgot about it. Recently, I pulled it out again to give it a go. This time I was able to produce some great results in my opinion. Here are a couple of small screenshots (small for loading speed) of a church type room. The thing to notice are the shadows that the pillars cast on the walls, the highlights of some of the smooth stones in the wall, and the highlights and shadows around the stairs.





I'll attach the demo as a download. Press 'M' to toggle the display of the menu.

Controls:
Up arrow - move forward
Down arrow - move backward
Rotate x,y - mouse
G - change ghosting method of the light map
E - toggle church textures and leave light map only
L - turn light map on or off
W - wireframe on or off
Shift - increase light map intensity (0-255)
Control - decrease light map intensity (0-255)

To really understand just how much better the scene looks with the light map, press the 'L' key to toggle the light map on and off.

Enjoy your day.

Attachments

Login to view attachments
Not_Maindric
16
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 2nd May 2009 02:58
Wow, impressive, I did not even know that was possible in DBC... Shoulda played with it more before DBPro. xD

Yodaman Jer
User Banned
Posted: 2nd May 2009 18:01
I've also invented a technique (I was actually going to post a tutorial about it a while back but got really busy), but it's time-consuming, space-consuming and not nearly as good as this.
I've also messed with Light Map Maker, it is pretty nice, and free too! That's always a good thing.

The one thing that prevents me from using it for all of my projects is that DBC has horribly slow polygon collision, which is required to use after light mapping a level like the one you have in your demo. Other than that, the light mapping capabilities of the software are pretty outstanding.

I've just updated my site! Please visit!

Link102
19
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 2nd May 2009 21:17
Very nice. mind sharing the source? I'd really like to use this. Fullbright sux

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th May 2009 06:01
Quote: "Wow, impressive, I did not even know that was possible in DBC"

Thank you!

Quote: "I've also invented a technique "

I remember reading some of your ideas. Quite Clever actually! Your ideas actually got me thinking about how this might be done within DBC itself without having to use an external app to modify the textures.

Quote: "The one thing that prevents me from using it for all of my projects is that DBC has horribly slow polygon collision, which is required to use after light mapping a level like the one you have in your demo"

I understand what you are saying. The poly count in this particular model is pretty high; and I'm not sure if it's a factor of Lightmap Maker itself. I'll have to test that. But some of the collision overhead can be avoided by using Sparky's collision dll, or by use static collision boxes to "fence off" entire areas with a single box as opposed to polygon collision checks.

Quote: "Very nice. mind sharing the source?"

Right now I'm still testing out the ideas. I'm trying to come up with more efficient ways to do this, finding ways to rely more on the material settings in DBC 1.20, and working on light/shadowing due to normals/polygons (I have an idea for texture bump mapping inside DBC, but haven't tried it yet).

Enjoy your day.
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 6th May 2009 01:37
Fantastic Latch! Clever use of object layers

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th May 2009 03:13
Thanks, SFSW!

I think you posted something very similar to this a while back where you demonstrated how to use the specular setting to create a bump mapping and radiosity type effect. This interior light mapping is the same concept.

Enjoy your day.
Yodaman Jer
User Banned
Posted: 7th May 2009 02:12
@Latch:

The program ran pretty slow, between 28-33 fps on my system. I thought I'd just point it out. I got it to run at about 55 fps at one point by turning off the Environment (removed the textures).
I've had similar issues with speed and texturing in my programs, usually for me it's caused by using textures over 256x256 in size.


Quote: "But some of the collision overhead can be avoided by using Sparky's collision dll, or by use static collision boxes to "fence off" entire areas with a single box as opposed to polygon collision checks."


I've never used Sparky's. I downloaded it and never 'installed' it, but I should definitely check it out at one point. I am considering moving on to a different programming tool, however...

Other than the program running slowly, this is definitely the first step towards creating fancy levels in your future games, and also helping the wider DBC community with lighting questions.

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 7th May 2009 15:08
nice scene but man are those square pillars ugly!

I don't get this, how is it doing that? is it editing the textures or what?
I heard something about using dark lights, is that to make shadows?

OBese87 - bringing you the world of today, tomorrow.
Yodaman Jer
User Banned
Posted: 7th May 2009 20:24
I ran it again and this time it ran at a pretty consistent 58 fps, until I switched it to render in wireframe. Then it dropped to about 23.

I also noticed that when I turned off the light map, the poly count went down to about 1800, and when I turned it on again it went back up to about 3000. I guess that's because you're using object layers?

Anyway, definitely keep working on it. Who knows, maybe you'll figure out a function or code snippet (or even a program) to light map a DBC level!

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th May 2009 01:29 Edited at: 15th Jun 2009 12:43
It went slower in wire frame? That should be the opposite. Check you setup.ini file. There should be a line that reads

blitflipmode=

Make sure it reads

blitflipmode=1

and

vbcreate=0
vbusage=0
3doverlay=0

On my AMD running at 1.5 ghz (single core) it'll run at about 115 fps in 32 bit and at about 144 in 16 bit. Though the example is coded to only run in 32 bit at a 60 fps cap. The 16 bit version looks fine actually... Hmmmmm

Quote: "I don't get this, how is it doing that? is it editing the textures or what?"

2 textures overlayed.

Quote: "I heard something about using dark lights, is that to make shadows?"

I forgot about that. For dynamic shadows, I could use dark lights. Though they would only be shaped like the type of light they are. A spot light, point light, or directional light. A dark light does the opposite of a regular light. Instead of emphasizing a particular color, it de-emphasizes it; essentially abosorbing it.

But for shadows and dark lights, you need polygons so the lighting isn't flat shaded. Here's an example of a dark light shadow effect using two spheres. The first sphere has a red light attached to it going down a hallway. The second sphere has a dark light attached to it. The idea was to block out the light in the hallway around the dark sphere. I used some of Kelebrindae's matrix functions to create the hallway so that the walls had multiple polygons.



Enjoy your day.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Jun 2009 13:17
So... How's this coming along, Latch? I would love to use this method in my game. Could you tell me how you did it?

TheComet


Make the path of your enemies easier with Waypoint Pro!
arbiter chewbacca hybrid
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 14th Jun 2009 16:42
there's a dbc demo


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
Zero G Scott
16
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 14th Jun 2009 22:12
Go on Latch....tell him how its going.../snickers
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Jun 2009 11:51 Edited at: 15th Jun 2009 12:45
@ZGS
All I have to say to you sir is "giant sumo wrestling statues?"

@TheComet
The method I used for the demo is a bit expensive (in terms of polygons and textures). As I've been messing around trying to understand other ways of getting levels light mapped in DBC, I'm starting to get a fairly good handle on doing it with Blender. And the blender 3ds exporter does a fine job in outputting a DBC compatible file without animation.

As time permits over the next few days, I'll try to put together a tutorial and example using Blender 2.45 which should work for 2.48 and above. I'm sure there are other 3d modeling applications that can lightmap a scene. Light mapping is the process of rendering lighting information onto textures so those textures can just be applied to your model. So for example, if the floor of your room had a brick texture, light mapping would mix any of the lights and shadows created by lights with your brick texture and create a new texture that is a combination of the two. This is also called texture baking. You then texture your object with the new texture and it appears to be responding to the lighting in the room.

The main reason I posted the light mapping demo was to hopefully motivate people into trying things that are supposedly not able to be done in DBC, or at least remove some of the notions of limitations in DBC.

Enjoy your day.
Zero G Scott
16
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 15th Jun 2009 23:46
Hey thats not what you told me, it was something that included the words "what a disaster" if I remember correctly.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Jun 2009 01:51
@Zero G Scott

That's yesterday's news, man. You gotta keep up on the times as technology changes every few seconds! One man's disaster is another man's fiasco, er a, I mean triumph.

Enjoy your day.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 22nd Jun 2009 12:46
Added a light mapping tutorial to the top post.

Enjoy your day.
Zero G Scott
16
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 22nd Jun 2009 20:18
Finally! Nice job Latch!
Yodaman Jer
User Banned
Posted: 23rd Jun 2009 01:08
Latch,

That is a really awesome tutorial! I'm definitely going to try this out!


Click to go to our website!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Jun 2009 02:34
Thanks!

Enjoy your day.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jun 2009 01:00
Awesome job, Latch! I will be looking forward to using it in my game! Thanks for your effort and time.

TheComet


Make the path of your enemies easier with Waypoint Pro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Jun 2009 22:02
You're welcome.

Enjoy your day.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jun 2009 22:14 Edited at: 25th Jun 2009 22:15
Hey, Latch! I am having a problem:

Quote: "Use the up/down arrow to change the View port Shading to Textured."


I did that, and all that did is change the "(1)plain" in the bottom left corner in 3d view to "(11)plain", but in your screen shot the plain is textured with the new "baked" image. Is that correct?

TheComet


Make the path of your enemies easier with Waypoint Pro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Jun 2009 23:24 Edited at: 26th Jun 2009 00:12
When I refer to the up/down arrow , I don't mena the arrow keys on the keyboard. I meant a drop down button on a control with 2 arrows, one pointing up and one pointing down. These are all over the place. So in the tutorial when I write up/down together like that, that means to click on the little icon next to the control. I think I took a screen shot of the little control in the Tutorial. Maybe I should change that wording.

EDIT

I also realized I didn't add the textures to the tutorial. They are available now.

Enjoy your day.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jun 2009 23:53
Ah, ok! Awesome tutorial, Latch! I really appreciate your efforts!

TheComet


Make the path of your enemies easier with Waypoint Pro!
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Jun 2009 00:24
Sorry for the double post, just making sure you read this. It seems the textures you save after baking are corrupt. The model loads with DBC, but doesn't texture. I can open the textures with paint or gimp, and they are in bmp format, but the model won't texture in DBC... Only after converting them to png and then back to bmp they worked. Why could this be?

TheComet


Make the path of your enemies easier with Waypoint Pro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Jun 2009 10:31 Edited at: 26th Jun 2009 11:28
Interesting. One other person told me that the textures don't show when they load the models into DBC. They even sent me their files and it worked fine for me. It must be the way Blender saves bitmaps. So saving it as png and then converting it to bmp works?

I've had no problem no matter how many times I've run it. I even tested the model in irrlicht and it loaded up. I'll either have to write that conversion suggestion of png to bmp, or see if I can see a difference in the Blender bitmap format. I'll see what I can find out...

EDIT
@TheComet
Can you try something please? As you go through the tutorial and you get to the section where you are about to save the light mapped textures, try this before saving them:

1. Press F10. This will open the scene panel, the same control panel that has the BAKE button on it.

2. Look for a pane heading that reads Format

3. In that window pane, there should be a little drop down control that reads jpeg. Use the drop down arrow next to jpeg to change the image format to BMP.

4. Look further below that for an RGBA button. Click that instead of the default RGB.

5. After these changes, save the baked image as described in the tutorial.

Can you load the model and it is textured in DBC?

Enjoy your day.
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Jun 2009 18:49
I did exactly what you said 2 times now, and it still didn't load. Only after converting it to something else and then back to bmp made it load. Really weird stuff...

Also, I have a few questions:

1) What is complicated on unwrapping uv textures with complex shapes? Could you tell me how I should do it, because my levels are quite complex.

2) I don't know if you know AC3D, but is it possible to do something like this with it?

3) In your demo you are able to set the light mapping intensity. How did you do that?

Thanks,

TheComet


Make the path of your enemies easier with Waypoint Pro!
arbiter chewbacca hybrid
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 29th Jun 2009 16:52
So what you're saying is if you export a model you made in blender (which naturally has light mapping anyway) that it will have light mapping in DBC? If so thats amazing because I have no Idea how to save a model in blender as 3DS. when it naturally saves as a blend. file... so please tell me.. please I beg you.Please,with a cherrie on top.


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Jun 2009 17:20 Edited at: 29th Jun 2009 17:21
Latch wrote a tutorial about how to do it. Basically, you make your level, you position your lights, and then you select each surface and "bake" the textures. That allows you to save the texture with the light mapping on them. Then you re-texture the surface with that texture, and load it into dbc, and it will display the baked texture.

Tell you what. Read through THIS. You can find a link to this site in the top post.

To export to 3DS, go to "fileexport3D studio".

TheComet

EDIT: Hows it going, Latch? I haven't heard from you for almost a week now. I'm starting to get worried...


Make the path of your enemies easier with Waypoint Pro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Jun 2009 19:36
@TheComet
Only been 3 days! Beleive it or not, I actually like to step away from the computer sometimes on the weekends!

In answer to your questions:

1) There are a ton of tutorials written for Blender on how to unwrap meshes. In short, the basic process is to create seams which are like "cuts" in the edges of the mesh. You then unfold the 3d mesh into a 2d layout based on those cuts. If the shape is complex, say, like a horse, then you have to be careful where you mark your seams.

2) I'm not real familiar with AC3D. If it doesn't handle light mapping as part of it's command or menu set, then there might be a plugin or something for it. Check with AC3D's support or forums. Truespace is free, I'm sure that'll have baking and light mapping.

3) With Blender, you'd have to get into ambient occlussion to create a lighted map of the scene. You then layer textures and objects and increase or decrease their lighting colors, intensity, material settings and so forth until you get a combination that looks like you want. That's beyond the scope of the tutorial. But for a Demo of the basic method, take a look at:

http://forum.thegamecreators.com/?m=forum_view&t=129557&b=6

Quote: "It seems the textures you save after baking are corrupt. The model loads with DBC, but doesn't texture. I can open the textures with paint or gimp, and they are in bmp format, but the model won't texture in DBC... Only after converting them to png and then back to bmp they worked. Why could this be?"


I still don't know why this is. Are you using a laptop? What version of Windows?

And here's something else to try:
In the tutorial, instead of saving the files as BMP, choose or leave the default setting as TGA (Targa), as I believe that is a lossless format. Once you have your baked images saved in TGA format, create a DBC script that reads



Now, associate these new bmp textures, not the tga textures, with the materials as described in the tutorial (steps 44-46). However, instead of just selecting the new baked texture name from the list, you will have to load in the new image. Do this by clicking on the little folder icon underneath the drop down arrow icon in the image load box. This is so when you save your model, the newly created .bmp textures you converted in DB are assigned to that model. If this works, I can just incorporate the steps into the tutorial and it should work for everyone that has DBC.

And another little something to try, while following the tutorial, instead of saving the filenames in Blender with and underscore "_" , don't use it. floor_lp.bmp becomes floolp.bmp , nwall_lp.bmp becomes nwalllp.bmp

It may not make any difference; but just give it a shot. Also, can you attach an image that DOES work. Perhaps one of your converted images of the floor or the walls. I want to look at the file header and see if there is any real difference. Thank you.

Enjoy your day.
arbiter chewbacca hybrid
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 29th Jun 2009 21:48 Edited at: 29th Jun 2009 21:54
Wow I do everything on a netbook... and you all complain of slow processors, graphics cards and having no ram.

Edit: what happened to quirkyjim did he die or something? I haven't heard from him in a long time , He was a good programmer and active member of the forums then what happened?


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Jun 2009 22:08 Edited at: 29th Jun 2009 23:00
Quote: "Only been 3 days! Beleive it or not, I actually like to step away from the computer sometimes on the weekends!"


Sorry for that. I know what it's like when you have had too much computer... Or if you have other plans.

To my answered question's answer:

That sounds pretty complicated... I'll need some time to figure it all out. AC3D does support lighting, but no shadows or baking. So I'll have to do it with blender. Truespace is REALLY weird to operate... I couldn't even make a cube. Thanks for the link, that is pretty impressive. I'll have to look through it on Wednesday (We are going to an amusement park tomorrow).

Quote: "I still don't know why this is. Are you using a laptop? What version of Windows?"


I have a laptop:

System:

Microsoft Windows XP Professional
Version 2002
Service Pack 3

Manufactured and supported by:

HP
Intel(R) Pentium(R) M processor 1.60GHz
589 MHz, 512 MB or RAM

Quote: "And here's something else to try:
In the tutorial, instead of saving the files as BMP, choose or leave the default setting as TGA (Targa), as I believe that is a lossless format. Once you have your baked images saved in TGA format, create a DBC script that reads"


Ah, yes! I'm sure that will work. I did that with my recent games to lower the size of the game. I saved the images to PNG files, and when running the game it would load the images and save them to bmp files for the levels. And that worked.

I don't have time right now to remove the "_" and try it, but I'll tell you in 2 days (Wednesday). I also can't upload the corrupt images yet, because I need to bake them again (they were replaced by the working images).

Thanks a bunch, Latch!

@ Chewbacca

I don't know. Maybe he went to the Dark Side? (DBP)

TheComet


Make the path of your enemies easier with Waypoint Pro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Jun 2009 16:55
Digging into the Blender output bmp file a little more, I discovered there's a tiny problem in the header that D3D in DBC (direct x 3d) just won't forgive. You can load the bitmaps into 2d just fine, they just won't automatically texture on a model in DBC when you load it. You'd either have to manually texture the model after it was loaded or you have to convert the images (but I think we knew that already).

I've updated the tutorial with a recomendation and a method for converting the bmps appropriately. Thanks to TheComet and Zero G Scott for discovering the missing textures on the loaded light mapped models and for testing some scenarios so I could track down the cause by the process of elimination: my machine wasn't affected.

Enjoy your day.
arbiter chewbacca hybrid
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 2nd Jul 2009 18:07
Srry but I've finally found the Demo version of UNREAL ENGINE 2 it's basically the same as unreal engine 2 just with no liscense so you can't sell any games,animations etc. but unfortunatly it can't run fast on some netbooks.


Vista is a paradox created by Bill Gates to force the noble pc gamers of america to console I am here to change that. [link]www.kdlproductions.webs.com[link]

Login to post a reply

Server time is: 2024-05-01 12:29:19
Your offset time is: 2024-05-01 12:29:19