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 Professional Discussion / Applying shadows on universe

Author
Message
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 3rd Jan 2014 01:30
Hello community!

Does anyone knows how can i apply shadows on a level made in fps creator and loaded into db pro as static object?


Thank You again awesome community!

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 02:12 Edited at: 3rd Jan 2014 02:13
We've got GAMEFX COMMANDS that comes withe Dbpro,but instead of shadows, what this method do, is add lights to the scene .



I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 3rd Jan 2014 13:25
oh i understand thanks for the response chafari!

Alex Matei CEO
www.alexmatei.com
RonsWare
15
Years of Service
User Offline
Joined: 5th Sep 2010
Location: Netherlands
Posted: 3rd Jan 2014 14:20
U can make lightmaps with programs as Blender, Carthograpy shop and Deled.
Works fine.

They are all free.
You make a DBO file and load it with the lightmaps.

Cheers Ron

Programming is learning
RonsWare
15
Years of Service
User Offline
Joined: 5th Sep 2010
Location: Netherlands
Posted: 3rd Jan 2014 14:37
Here are two screenshots of the engine i am working on.
The lightmaps are made with Deled.

Screen one:


Screen two:


I believe this is what you are looking for

Cheers Ron

Programming is learning
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Jan 2014 17:24
Dark Lights is also a lightmapper.

Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 3rd Jan 2014 17:27 Edited at: 3rd Jan 2014 17:28
Nice screens, Ron!
I'm also interested in learning more about lightmaps...

Can someone tell me if there's a difference between a lightmapped texture and a baked texture?
I gather they're both used for worlds with a static light source, but other than that..?

D.D.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 18:38
Dark lights is one of the best lightmapper I have found for Dbpro. Probably there are better out there for other engines but into Dbpro I will use Darklights.

As RonsWare commented, Blender, Deled etc...are good enough and free.
We shouldn't forget Mapscape, that is not only lightmapper but also a 3D Editor.

There are so many others , but the thread was :

Quote: "DBPro / Applying shadows on universe"

I've been squeezing the program, and it is able to give real good results using the some tricks.

Blender, is a 3D Editor "THE BEST" and is free. We can do every kind of objects in there, even we could do some games directly into Blender.

Quote: "Can someone tell me if there's a difference between a lightmapped texture and a baked texture?
"


Lightmapping use a different textures that the engine blend with the original texture and we can scale texture...let say a wall or any other surface.

What I have found out about baked texture:
This kind of lightmapping do more or less the same, but once we have baked our final texture, we can no scale into Darkbasic as both shadow and textures are in the same texture.

Of course, that we could scale texture into Blender and bake texture again, but most people use Blender and other 3D Programs just for modeling.

If we use "Lightmapping", we will be able to scale texture on the fly into whatever engine we use.

I'm not a grumpy grandpa
RonsWare
15
Years of Service
User Offline
Joined: 5th Sep 2010
Location: Netherlands
Posted: 3rd Jan 2014 19:20
I use at this moment lightmapping just for static objects.
They increase realisme in your world.

Chafari is absolutly right about Blender, it's the BEST free Editor.
And he is also right about people not using the lightmapping that this
program offers.

For everybody interrested in how to do that with Blender here is a short tutorial

http://www.youtube.com/watch?feature=player_detailpage&v=LL5QiLspUvY

@Derek Darkly Thanks

Cheers Ron

Programming is learning
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 3rd Jan 2014 19:26 Edited at: 3rd Jan 2014 19:34
Quote: "Dark lights is one of the best lightmapper I have found for Dbpro. Probably there are better out there for other engines but into Dbpro I will use Darklights."



Is there a practical way to generate lightmaps with DBP native commands, or would this be too much work?
The DBPro example isn't commented and is a little advanced for my current understanding.

If possible, could someone provide a tiny example - perhaps a single static cube with a single light in the corner?
I just want to see the basic mechanics of how lightmaps can be generated and exported.

D.D.
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 3rd Jan 2014 20:01
Thanks all for the responses!


But i have another question...Why when i make the lights in FPS Creator and export the level in DB PRO i can't see them as placed in FPS?

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 20:09 Edited at: 3rd Jan 2014 20:19
Quote: "Is there a practical way to generate lightmaps with DBP native commands, or would this be too much work?"


Yes it is possible, Dark lights was made with Dbpro.I made my own lightmapper that works fine. Take a look to this easy example that works just for the floor, but you can get the idea and implement it for the walls.





Edited

Quote: "But i have another question...Why when i make the lights in FPS Creator and export the level in DB PRO i can't see them as placed in FPS?"

Could you post your level to test ?


@RonsWare Thanks for the link

I'm not a grumpy grandpa
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 3rd Jan 2014 20:28
Quote: "Dark lights is one of the best lightmapper I have found for Dbpro."

It produces the best light maps I've ever seen, IF you only use it on extremely simple levels. I can't even lightmap a level with 13k faces (in modern games, this is less than the amount of faces used on a single character model) without it crashing.

New sig coming soon..
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 20:34
Quote: "It produces the best light maps I've ever seen, IF you only use it on extremely simple levels. I can't even lightmap a level with 13k faces"



@wattywatts I don't mean you don't know the program Darklights, but we have to learn to work with it. We can instead of trying to render 200 light, split the level in so many parts we need and load them separately. And yes, Darklights make a very nice lightmaps even with radiosity.

Cheers.

I'm not a grumpy grandpa
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Jan 2014 20:36
MateiSoft Romania wrote: "Why when i make the lights in FPS Creator and export the level in DB PRO i can't see them as placed in FPS?"

You need to ensure that the lightmaps are in the same folders as the FPSC project. There is a sample code on the forum which will load the FPSC universe, including the lightmaps.

Search for it, and run it, and it should work fine.

wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 3rd Jan 2014 20:45
Quote: "We can instead of trying to render 200 light, split the level in so many parts we need and load them separately."

No offense taken my friend, this is good advice but unfortunately only works in certain situations. I still use darklights on occasion but it really depends on what sort of project I'm wanting to tackle.

New sig coming soon..
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 20:55 Edited at: 3rd Jan 2014 20:55
Quote: "No offense taken my friend"

Not at all but you gave us a data about 13k faces and that is less than nothing.

The level in this image has five lights and is more than 200k and works great.




I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 3rd Jan 2014 20:55
Quote: "Take a look to this easy example that works just for the floor, but you can get the idea and implement it for the walls."


Great sample code! I'm starting to understand.

And I see the shadows are drawn with the DOT command using collision checks with INTERSECT OBJECT... very slick.



D.D.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 21:00
@Derek Darkly
I'm glad you like it

I'm not a grumpy grandpa
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 3rd Jan 2014 21:03
Quote: "The level in this image has five lights and is more than 200k and works great."

Well that's extremely odd.. I haven't been able to go beyond 13k with even 1 light. It works fine up until the actual render, then "Darkbasic pro project has stopped working". Frustrating!

New sig coming soon..
RonsWare
15
Years of Service
User Offline
Joined: 5th Sep 2010
Location: Netherlands
Posted: 3rd Jan 2014 21:07
@chafari VERY NICE, great example

Maybe great for my stencil shadow project

Cheers Ron

Programming is learning
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 21:08
Quote: "I haven't been able to go beyond 13k with even 1 light"


Could you show me your object "level" to test here ? thats really wierd

I'm not a grumpy grandpa
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 3rd Jan 2014 21:27
Yes of course, this is the object I was just testing with to try to remember how many poly's my limit was. (It's just a makehuman export).

New sig coming soon..
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 21:33 Edited at: 3rd Jan 2014 21:49
@Wattywatts

Testing...I will report you back.


I'm back

I nearly figured out when I saw that it was a human character. Lightmappers are more like for static object and of course, you could do a static bust, but in that case you could reduce you polygons model...this what happens when trying to render Darklights



I'm not a grumpy grandpa
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 3rd Jan 2014 21:56
Thanks for trying, I may understand the problem now.. Too many polys per limb?

New sig coming soon..
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 22:04
Quote: "Too many polys per limb?"


Imagine 21841 polys even my bigest level are no more than 1000 poygons...that's why I told you that we need to learn how it works...sorry if it was arrogant, it wasn't my intention.

Do what's right, come what may !!

Cheers.

I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 3rd Jan 2014 22:41 Edited at: 3rd Jan 2014 22:42
@Chafari

Another question regarding your earlier example...

Is there a way to tweak the code to save the light gradient cast on the floor into the lightmap?
I noticed only the shadows are rendered in the image and not the gradient.

D.D.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jan 2014 23:13 Edited at: 4th Jan 2014 00:15
@Dereck Darkly

Yes, we can create the gradient colour with just another function, that compare the distance from ray to collision to make a variety of gray colours or whatever colour we need. I will put soon an example for you.

Edited

Here's an update for make a small gradient to the shadows. We have to do the same with the rest of the floor "the lights" .



I will try to update again . Cheers.

I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 4th Jan 2014 02:53 Edited at: 4th Jan 2014 03:01
I ran your code and got some weird stuff:


Then I tried to just point the camera squarely at the floor and capture the image manually:



(SEE ATTACHED PIC - my capture was off by about 1 pixel)

D.D.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2014 12:14
@Derek Darkly

Yeah ...I know what you mean...that happens because we are playing with so short distances, any way, we had better making a mask for the light... somthing like this:

And then just place the mask behind the image before capturing the final image to blend.

Something like this:


This was just some test I made years ago when no shadow shading exist and that would be of course just for static lightampping.

If you are interested in lighting levels, you could have a look to the method of SET VERTEXDATA DIFFUSE, that give us a nice effect.

Cheers.

I'm not a grumpy grandpa
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2014 14:53 Edited at: 4th Jan 2014 15:09
New update to make gradient in the lightmap genarated with this snippet. We have to play with the values to get differents results.







I'm not a grumpy grandpa
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 4th Jan 2014 15:36 Edited at: 4th Jan 2014 15:36
If you are willing to spend money, Dark Lights is a great solution. It does take a lot of work to properly implement though. A few tricks I've learned when using dark lights:

1) As a general rule you never want to lightmap using dark lights in your main engine - it uses up a lot of resources and it's slow. It's designed to be done once in an editor once and then saved, that's the point of lightmaps. You shouldn't even have to start up dark lights in your main program.

2) Never lightmap an object that has already been lightmapped in dark lights. If you've already generated a lightmap and want to regenerate it, create code that reloads all your objects right before dark lights lightmaps them. This avoids the problem of the lightmapper messing up UV coordinates and texture layers, because it expects the main texture to be on layer 0. if an object has already been lightmapped, the main texture will have been moved to layer 1 so the lightmapper will "get confused" and you'll encounter bugs.

3) Don't lightmap objects that have a modified FVF - any other vertex format besides the default can produce a lot of bugs. I've encountered a problem where Dark Lights removes all the polygons on objects that have a modified FVF.

4) By default, Dark lights saves to "lightmaps\<n>.png" and there is no command to change this folder. Use the "set dir" command before lightmapping to change your active directory, giving you more control over where the lightmaps are saved.

5) In order to save a lightmapped object, you have to save three things:

- The lightmap texture for the object (you can identify this with LIMB TEXTURE NAME)
- The regular texture for the object
- The modified object itself.

Dark lights generates modified UV coordinates on texture layer 0 and 1, for the lightmap and diffuse texture. In order to apply the lightmap back on the object, you have to save the object using "save object". In my engine, I actually save four things: The three resources above, and a text file containing their file names to make it easier to load.

When I load the object, I do this (pseudocode):



Before using the object, I convert it to a mesh and back to a new object. Since I used "set dir" before to change the folder dark lights saved into, the texture filenames saved in the dbo are no longer correct. I convert the object to a mesh to remove the texture data that has been saved inside the DBO. Meshes keep the proper UV coordinates, which is what we're looking for.

Then, I texture the new object with the proper textures and set a blend mode of MODULATE2X (5). This might be different depending on whether your scene is indoor or outdoor. Just set blendmode parameter of the SET BLEND MAPPING ON command to be the same as LM SET BLEND MODE. And that's it! you're done!

I've had a lot of success with dark lights, it's allowed me to create scenes with both indoor and outdoor lighting. It's hard to set up the saving and loading, but once you do it properly your game will look amazing and the performance gain is well worth it.

Here's a screenshot from my engine showcasing directional sunlight and point lights:



Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 4th Jan 2014 15:43 Edited at: 4th Jan 2014 16:18
What kind of results are you getting, Chafari?

I don't know if I'm saving the image correctly.
(See Attachment)

Quote: "If you are interested in lighting levels, you could have a look to the method of SET VERTEXDATA DIFFUSE, that give us a nice effect."


That sounds promising.
Didn't even realize it existed!

Yes! That's very cool.
I can see how we could hand-paint a room and simply save the object with no lightmap image required at all.



D.D.
MonoCoder
20
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 4th Jan 2014 16:28 Edited at: 4th Jan 2014 16:31
Chafari, I liked your shadowing example, and I hope you don't mind but out of interest I modified one of your posted codes (your 2nd-to-latest, iirc) to run at realtime speeds.



It does use imagekit, advanced2d and sparky's collision, though, so this is a useless post to anyone lacking them
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2014 17:55 Edited at: 4th Jan 2014 18:01
@thenerd
Great tuto !!

@MonoCoder
I don't mind, and thanks for your new version, we can learn all of us one from each other


@Derek Darkly
Not sure why you get that image.
I simple add this line to save image:

Quote: "save image "ima.jpg",1"

and I get this image...





Quote: "I can see how we could hand-paint a room and simply save the object with no lightmap image required at all.
"


We can paint vertex of the whole level ant it looks like lightmapped...is easy and works fast ..!!

I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 4th Jan 2014 18:45 Edited at: 4th Jan 2014 18:59
Quote: "Not sure why you get that image"


Aha! It was because I saved as .PNG and it added a transparency.
JPG works fine.



I see that the pixel color for the gradient is chosen by the 3D distance from the light.
Very simple, yet so very clever!

I wish I was smart enough to think up this stuff!

D.D.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2014 22:01
Quote: "I wish I was smart enough to think up this stuff!"


I'm not that smart....things that you learn when you're bored and I'm older than the mountains

I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 4th Jan 2014 22:06
Quote: "I'm not that smart....things that you learn when you're bored and I'm older than the mountains"


LoL.. I just turned 40. I'm definitely on my way up the mountain and over the hill.

Speaking of mountains, are you guys expecting some volcano trouble in the Canaries?

D.D.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Jan 2014 22:15
When we go pass 50's, life goes quick but I like my age ...too old to reveal

Quote: "Speaking of mountains, are you guys expecting some volcano trouble in the Canaries?
"


Nobody knows for sure. Scientists do not succeed one...we expect a volcano on Hierro island. I live in Lanzarote Island..the most volcanic. In my life, nothing happened.

Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-06 10:35:12
Your offset time is: 2026-07-06 10:35:12