Game Development Community

Lighting in TGB?

by Ahmed Kandeel · in Torque Game Builder · 04/09/2011 (11:33 am) · 24 replies

Hey guys, I was just wondering if this was possible in TGB as opposed to TX?
http://www.garagegames.com/community/forums/viewthread/121197

I did do a search by the way... honest!
Page «Previous 1 2
#1
04/12/2011 (6:52 am)
Ok I've been looking for the past two days to find a sensible way of lighting a scene and still have very few answers. There doesn't seem to be a 2d engine under the sun that can do this, excuse the pun. And yet I see it in games made using TGB like Insanely Twisted Shadow Planet, or Lava Mortus.

Light maps don't seem to be a possible solution, since I don't want the light to bleed through all layers. I want shadows and certain things causing shadows, others not.
Similarly I believe this rules out particles.

I'm completely at a loss at what to do. Do you think it would be possible to take the lighting system from TorqueX and convert it for use in TGB?

Thanks for all the help!
#2
04/12/2011 (5:07 pm)
With heavy modification, most anything can be made to work. How well is another story. Why don't you try a simpler approach first? You could just create a lightmap system for the scenegraph that would account for all lightmaps currently in the scene and overlay / blend it with the scene. This is a rather quick approach and can give you some decent effects. Though yes, it's not 100% correct, it's something more than nothing and used right can look really good. You can create a system that would allow you to mask the areas you don't want it to bleed light into/through, etc.. So I don't see why you would rule out lightmaps.
#3
04/13/2011 (7:24 am)
It's what most are using. A black screen, punch holes, draw it every frame after all objects.
#4
04/14/2011 (8:46 am)
Right, you can even setup occluding polygons for it to take into account, so that it won't allow the bleed through.
#5
04/14/2011 (9:43 am)
Cheers for the advice guys. I've come to my senses and believe that lightmaps are the way forward. I assume they could be made to change as time progressed, in a similar way to sprites? Smally, do you by any chance know any good articles to explain what occlusion is. Just checked the Wikipedia article, but as always, it goes in too deep too fast.

Thanks once again, for your help!
#6
04/16/2011 (10:07 pm)
The simplest definition of 'Occlusion' is "Blocking something". Such as 'Ambient Occlusion' is used to block Ambient Light in nooks, and crannies to give better depth & realism in 3D environments.
#7
04/17/2011 (9:46 am)
Not sure if this helps?.
TGB/Resources/Dynamic Shadow
Looking for information on lighting myself.
Have you found any good info or posts?.
#8
04/18/2011 (7:41 am)
Thanks for the definition Lonnie! In addition that article on Dynamic Shadows with code will come in great use. Although, I may not have shadows for buildings, shadows for the main characters are more than likely! Cheers guys!

I did find a website claiming to have made an addon for TGB that did dynamic shadows, but it appeared that development had stopped.

http://www.nxsware.com/
#9
04/18/2011 (7:48 am)
Argh, that is pretty deep C++ there! It'll take me some time to work out what's going on!
#10
04/19/2011 (8:44 am)
I tried to make is so that it doesn't require *too* many changes.

In ::renderObject, you'll need to find your t2dSceneWindow and t2dSceneGraph. For most people the t2dSceneWindow is "sceneWindow2D". You'll have to name the scene graph in the level editor and then you can use that here.

Also in ::renderObject, you'll need to write code to determine which objects get shadows. In my case, anything in Group #2 is picked (which is the group I assigned to all of the pillars in my game).

Finally in ::processObject, you'll need to define the light source's location and the polygons for the objects. You just call ::renderShadow with the light source and the polygon.

In my case, the t2dLightMap was moved so that it centered on the player and the player was the light source. That means that "getPosition()" got the source of the light. Also, my pillars were identical and so I created 24-sided polygons to represent the pillar. (Actually, in my real game, I create 3 polygons to represent multiple features of the pillar, but that's not important for this example.)

You'll note that this is not a generic lighting example. It can only handle one light source. I needed a simple/fast way to do one effect.
#11
04/20/2011 (9:06 pm)
Sorry about the delay, been super busy here. I'll get something worked up since, I'm in need of the same thing for a project I'm working on. Once I have it somewhere near complete, I'll ping you back. Should be in the next two to three weeks. But I'll let you know asap. I'll probably post it as a resource as well. Still need to input the other one for adding a tool to the editor lol..
#12
04/21/2011 (5:52 am)
Well my project won't be starting till the beginning of July. So you have plenty of time :).
#13
04/21/2011 (5:01 pm)
LOL Thx, I'll take that under advisement
#14
05/14/2011 (8:36 pm)
it's been a bit but, Ahmed, what kind of license for TGB Do you have? Is it binary or pro because I don't see any w/ your profile and anything I give out will require source changes.
#15
05/17/2011 (2:32 pm)
Hi,

I'm looking for ways to use lighting in tgb myself.

Ronny, you said:

Quote:It's what most are using. A black screen, punch holes, draw it every frame after all objects.

This is exactly what i'm looking for, but i can't figure out how to punch holes in this black screen, any ideas?

Of course i know how to punch a hole in a static image, but i want my player to hold a flashlight and be able to punch holes dynamically.

Thanks
#16
05/19/2011 (11:03 am)
You can do that with a blend as outlined in the following post.

Transparency through foreground semi transparent dark layer.
#17
05/22/2011 (9:23 am)
Sorry I took so long to reply Smally. I'm going to purchase TGB soon, hopefully at the really cheap price it is now! I would have been so screwed with the pricing a couple of years back! So source code access won't be an issue.
#18
05/22/2011 (10:50 am)
Thanks for the help!!!!!
I was thinking about blending myself but didn't know if it was possible, now i know:-) And it works great!!
#19
05/23/2011 (2:21 pm)
Yeah blending is the key... Sorry for the delayed reponse again, just got out of the hospital today.. Kind of abrubt, but.. That's all I'd be doing for the most part is setting up a blending solution that stops "bleeding" edges and allows for colored lighting, and shadows.. fun, fun, fun.
#20
06/03/2011 (10:48 am)
Ok, so opinions are welcome... how does this look so far? It supports 1 ambient light, and 3 dynamic sources (only because that's all I added right now). Now this is NOT the same thing as a 3d light source, these are handled by the manager. No shadows, yet.. but this is a good start. ;) Currently, the only illumination by the lights are well, the light and what is under them.. there is no radiance for the light outside of that in this picture. The light type created for this is just a spot light of sorts, lol. Support will take as many lights as you want, and ambient as well as light colors, textures, etc can be changed on the fly. You can even make an imagemap, shape, or anything except a particle a light source currently. I'm just making sure everything is coming together on this correctly for now.

[EDIT]Updated image[/EDIT]

www.embermill.com/gg/imagescreenshot0.png
Page «Previous 1 2