flashlight sfx

Blitz3D Forums/Blitz3D Programming/flashlight sfx

Amanda Dearheart(Posted 2010) [#1]
OK, I'm trying to design a flashlight effect for my game?
Y'know, if a person was to shine a flashlight on a surface, how would I go about it?

Would I use animated textures, the light entity, or something else?


Gabriel(Posted 2010) [#2]
What does sfx mean in this context? Typically I read sfx as sound effects, but you seem to be asking about visual effects. I'm assuming you want visual effects for the purposes of my answer, in any case. Tell me if I'm off-track.

I normally use a projected texture for flashlight type effects. Blitz3D, out of the box, doesn't support "true" texture projection but you can make a pretty good job of it just the same. Fredborg's version is pretty effective and simple to understand, I think.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1000

You might want to use this technique in combination with a real light or by itself. I think Fredborg's example uses a light.


Hotshot2005(Posted 2010) [#3]
DO You mean flashlight GFX?


Shambler(Posted 2010) [#4]
http://en.wikipedia.org/wiki/SFX

I am sure fredborg posted this in the code archives...searching...here he is...
http://www.blitzbasic.com/codearcs/codearcs.php?code=1000


puki(Posted 2010) [#5]
We are talking S-FX as in special effects - also known as SPFX.

Get with the flow people. I cannot continue to drag this community behind me.

Easiest way is using FastExtension. "fredborg" has a somewhat ugly code archive entry - I don't like it, but others love it.

Some people go the double-render route, you just light the scene and mask out a spot (an image, not an actual hardware spotlight) and then render the scene with the normal lighting (ie not much) with your 'captured' spot overlayed - if that makes sense.


Kryzon(Posted 2010) [#6]
Half Life 2 and Quake IV use a projected "flashlight" texture. They blend the texture using Addition, so it lights up the surface that get's lit.

You can use that method (with the cost of having to use the 2nd UV layer for it, not allowing you to have a lightmap!), or you could also try to use a cone with vertex alpha.

You can get a flashlight volumetric cone out of that:


Note that cone is not Add-blended; giving it a whiter color and making it Add-blended might give better results - that screen was just a test I was doing with vertex alpha from 3DS to B3D.


_PJ_(Posted 2010) [#7]
Certainly the posters above know way more about this kinda thing than I do, but I'm wondering, what specifically is the 'bit' you're after?

1) The cone of the flashllight
2) The "End" iof the flashlight beam, reflecting off a surface it hits?

3) Both the above, i.e. the whole flashlight deal

#1 I really wouldn't have the first clue about, but I think this is what Kryzon is getting at.
#2 Could be solved perhaps in a similar method to casting shadows, some kinda camerapick that picks out the surfaces the light would fall on. Where a circular sprite or texture modification is shown lighting things up

Overall, I find the whole subject so 'common' and almsot 'necessary', bt at the same timer extremely complicated relatively for what it is, just to get a torch beam! I'd be really interested to know how this is solved in the end!


jfk EO-11110(Posted 2010) [#8]
A Flashlight (in a game) usually only makes sense in a dark, greedy enviroment or so. So you want the walls to be lit, also indirectional to some degree, to explore the darkness. I found it rather easy to combine the cone mentioned with a Light Entity that is fixed to the big end of the cone. There may also be a 2nd, smaller light right at the start of the cone, to prevent the active light from being to far away to light a wall when you're very close to it. It is however essential that all the walls and Meshes are fragmented in rather small pieces in order to allow the directX light to make detailed use of vertices. It other words: A cube cannot be lit well by a Directx Point light based Flashlight, a sphere at the other hand can.


Amanda Dearheart(Posted 2010) [#9]
Yeah Puki, you know what I'm talking about!

Malice, you're half-right. My immediate concerns are for texture-based lighting, but for future reasons, I may want the whole flashlight effect.

jfk, you've come closest to what I'm trying to describe.

Games like Oblivion, Morrowind etc. when they are in a dark dungeon, use a torch to light up the scene when they're traveling in the darkness!


jfk EO-11110(Posted 2010) [#10]
Would this be for first person perspective, third person perspective behind Character, Topdown, or anything else?
edit, anyway, here's a sample with a rather smart third person camera btw.

It shows clearly the vertex problem with lowpoly models.




puki(Posted 2010) [#11]
Yeh, this is why some people will just opt to double render and get a pure spotlight - which means you can get away with surfaces of a couple of triangles and nobody would know, until you shunted any other form of lighting at them.


_PJ_(Posted 2010) [#12]
This is also a common thing I've noticed with Blitz Terrains, as the tri's of the mesh show up with all their jagged ugliness if the contrast of the light is too high...

I'm really glad for this thread, as I mentined previously, things like flashlights (and again, I'll draw the analogy code/graphics-wise to accurate shadows) are so common in games, but are a difficult aspect to get right even with the latest hardware and DX9million or whatever they use nowadays. Until computers are powerful enough to have totally accurate and photorealistic raytracing and such in realtime :) Though I guess, een when that becomes a possibility, game devs'd begin fussing about why their photons aren't accurately portraying wave/particle duality XD