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 / Lightmap affects an object? How?!

Author
Message
Ratmanxx
15
Years of Service
User Offline
Joined: 26th Oct 2010
Location: Hungary
Posted: 12th Feb 2011 19:28
Hi!

I need some help! I'm curious about how could I make an object affected by lightmap? So I have a player character, and when he is in a darker area, I want to see him darker by the 'shadows'. I don't know how this stuff called, so I decided to write to this forum.
I exported a model for testing from Gile[s] with lightmap and I was a little bit surprised, but It was lightmapped nicely in the example project, that I used to test it.
Just I don't like how the character doesn't affected by the lightmap.

Any solutions / ideas?
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Feb 2011 20:46
Hi there. Can`t you use just fog, or a direcctional light ?

cheers.

I'm not a grumpy grandpa
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 12th Feb 2011 20:52
For that you need to place lights in dbpro where the light sources are but have those light not effect your lightmapped level, only the player.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Feb 2011 01:51
Standard lightmaps are constructed for static objects and are inextricably linked to their geometry. For other objects in the scene do what Madscientist says.
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 13th Feb 2011 02:31
Would there be any way of checking the value of the lightmap under the player, and then coloring the weapon based on that?

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 13th Feb 2011 03:09 Edited at: 13th Feb 2011 03:09
@thenerd
Yeah there would, check the player's position in relation to the vertices of the level, check the UV coordinates of those vertices, check the color values of those UV coordinates on the lightmap UV map. Then Average the color values of the vertices of the face that the player is standing on to get a value. Then using that you can finally set the gun's ambience levels it recieves. But I find this would be a little... complex.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th Feb 2011 12:42 Edited at: 13th Feb 2011 12:54
The lightmaps are static light and doesn`t affect to the rest of the objects. There is a way to manage that, dividing the area in differents zones and manually checking if we are into this area. The color of the gun doesn´t change , but the light we put on top of the gun, and this light can change the intensity depending on the distance. We could put just hiding objects to change the light colour if the player collision....there are many ways.Here is a simple example.





cheers.

I'm not a grumpy grandpa
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 13th Feb 2011 14:05
Quote: "Yeah there would, check the player's position in relation to the vertices of the level, check the UV coordinates of those vertices, check the color values of those UV coordinates on the lightmap UV map. Then Average the color values of the vertices of the face that the player is standing on to get a value. Then using that you can finally set the gun's ambience levels it recieves. But I find this would be a little... complex."

It would be complex, but it could be useful for a number of things. I think this actually relates to a thread someone made about 3d UIs, where he had the problem of how to get the UVs out of a 3d coordinate. I might experiment with setting the object's ambient light based on the lightmap, I'm not sure what the results will be. It might look good, or not at all.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Feb 2011 16:15
Yes, I think Madscientist's solution is worth trying out too.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th Feb 2011 16:42
Quote: "Quote: "Yeah there would, check the player's position in relation to the vertices of the level, check the UV coordinates of those vertices, check the color values of those UV coordinates on the lightmap UV map. Then Average the color values of the vertices of the face that the player is standing on to get a value. Then using that you can finally set the gun's ambience levels it recieves. But I find this would be a little... complex.""


What about if the level has just four vertex in a single big face ?
we can probably calculate the color of vertex, but surely we have to make a grid of vertex in the hole floor to check every part of the floor. As we all knows, no always the color of the floor is the color that we reaches. So I think that could be done in many ways.

This litle example shown above, is just an idea of how we could do it in the easiest way, but perhaps the slowest way. We could put the challenge of a small example using diferents ideas.I am retired and I have all the time in the world to investigate and improve my knowledge




Cheers.

I'm not a grumpy grandpa
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Feb 2011 16:58
Quote: "I am retired and I have all the time in the world to investigate and improve my knowledge"


You are not alone.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th Feb 2011 17:01
I was waiting your answer...

Good luck !!

I'm not a grumpy grandpa
Ratmanxx
15
Years of Service
User Offline
Joined: 26th Oct 2010
Location: Hungary
Posted: 13th Feb 2011 18:00
Thanks for the answers, I was also thinking on the way that Chafari told us, that's far better than nothing. I was just tought the same method with an invisible collision model on the level (maybe more than one) to set the models coloring.

Now, I still have a question. Can someone explains how it works in games, like Quake 3 Arena?

"The character models are lit and shaded using Gouraud shading while the levels (stored in the BSP format) are lit either with lightmaps or Gouraud shading depending on the user's preference. The engine is able to take colored lights from the lightgrid and apply them to the models, resulting in a lighting quality that was, for its time, very advanced." - wikipedia

Is it possible to make it somehow in DarkBasic Pro?
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th Feb 2011 21:08 Edited at: 13th Feb 2011 21:18
@Ratmanxx
Thanks, I`m glad you like it. here`s another example. The code is a bit a mess, but I wanted just to show the concept.






Quake use it´s own program. I supose they use lightmaps and real time light.


cheers.

I'm not a grumpy grandpa
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 13th Feb 2011 23:22
After a few hours of experimentation, I found out a very simple method. I just made a 1x1 camera set to an image, and used blend mapping to apply it on top of the object. When the camera was positioned every loop under the player, the result was an easy effect of lighting. By no means is this perfect, but I thought it was a nice simple way of doing it.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 14th Feb 2011 01:41
@thenerd
Could you show us an example


Cheers.

I'm not a grumpy grandpa
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 14th Feb 2011 01:48
Here you go!

Just use the WSAD keys and the mouse to move around the level. It's a pretty primitive example, but demonstrates the idea.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 14th Feb 2011 02:50
@thenerd

That`s great !!. . I really like and is more accurate than my method. We never go to bed without learning something new .You have made my day thank you.

Cheers.

I'm not a grumpy grandpa
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Feb 2011 12:20
thenerd

Brilliant! Thanks. I'll definitely be studying that one.

Chafari

Quote: "I'm not a grumpy grandpa"


Neither am I now.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 14th Feb 2011 12:40 Edited at: 14th Feb 2011 12:45
@Green Gandalf.

Quote: "We never go to bed without learning something new "


I'm not a grumpy grandpa
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 16th Feb 2011 01:21
I'm glad you like my solution, it's not ideal though. I have a few thoughts: If you look closely, the shading on the polygons remains the same wherever the object is, because the dynamic lighting is still the default. The best solution would probably to use this system as well as the lightmap camera, so that it would be affected by the environmental light as well as details such as shadows. Another thing that I thought of doing would be to take the color gathered by the camera, and convert it to grayscale. This would eliminate bugs that happen when the object is too close to the edges of walls. Also, I wish there was a way to disable the main texturing of the level and only display the lightmap. If there was, I would use sync mask to have the camera only gather from the actual lightmap, rather than the full texture as it does now.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Feb 2011 13:52 Edited at: 16th Feb 2011 14:53
Quote: "Also, I wish there was a way to disable the main texturing of the level and only display the lightmap. If there was, I would use sync mask to have the camera only gather from the actual lightmap, rather than the full texture as it does now."


I'm sure you can do that with the set blend mapping on command which I suspect is all that DBPro lightmapping uses anyway. Just use the correct blend mode and texture stage.

Edit See attached demo.
Ratmanxx
15
Years of Service
User Offline
Joined: 26th Oct 2010
Location: Hungary
Posted: 19th Feb 2011 19:17
I like thenerd's method, but it's still not perfect. I would be curious how it works in other game engines, what kind of method they're using.
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 20th Feb 2011 19:06 Edited at: 20th Feb 2011 19:07
Use hardware lights, it's probably the most efficient way. I'm pretty sure UE (< v3.0) uses hardware lights in combination with lightmapping, and it works pretty well.



Support a charitable indie game project!

Login to post a reply

Server time is: 2026-07-17 14:00:02
Your offset time is: 2026-07-17 14:00:02