Game Development Community

I dont get blending modes

by Kiyaku · in Torque Game Builder · 08/06/2007 (4:19 am) · 3 replies

Hi guys!

after some hours of trying around with blending modes... i still dont get them~ o-o

i want to do something like a spotlight effect where i have a background, a black panel(for darkness) and then a white circle for the spot.

so i thought i could someone manipulate the alpha of the black panel with the white circle.. so that you see through it and then it looks like a spot or something.

i remembered that i did see some flashlight, or spotlight thing here before that did something like this
but now i cant find it anymore.

does somebody know where i can find this flashlight thing, a tutorial for blending modes, or can explain how i can get this effect?

thanks alot

#1
08/06/2007 (4:21 am)
You can not get this effect if you wanted to make the rest outside the spotlight dark.

That needs straight OpenGL code / DX code to be done and is not achievable through blend modes.
#2
08/06/2007 (1:30 pm)
You can fake it pretty well by making a large (2x your scene size) black panel with a transparent hole in the middle, then just move the entire panel around to move your spotlight. If the panel is flat black, this should look just like a spotlight.

If you want true masking, that would require modification to the engine.
#3
08/14/2007 (7:12 am)
Hey now, if you want what i think you want then this should do it. Keep in mind that i may have left something out or messed something up, but either way, i have a working light and dark demo going so i don't see why it wouldn't work :)
You get a darker coloured sprite, say a dark blue or something and stretch it over the camera view (you can mount it there if you want). Set the blend factors to this (and select a blend colour):
Source: Dest_Color
Destination: One Minus Src_Alpha

Now take a sprite that's transparent but with something white on it (some of the particle sprites work good for this). Mount it on your character or where ever you want it and set the blend factors to this:
Source: Dest_Color
Destination: Src_Alpha

Now this SHOULD work fine and you'll have some darkness over your scene and a sort of glowing effect where there is a light source. Like i said, the particle effect images work good for point lighting but if you want something like directed lighting/flashlight effect then just make a sprite that way and do a transparency gradient for the attenuation (sorry for the word choice; it makes sense in my head).