Sign in to follow this  
monkeyman

Half-Life 1 flashlight effect?

Recommended Posts

Hey- This is low-tech stuff here :), I figured that someone can point me in the right direction.. I want to implement a dynamic lighting effect similar to the flashlight in the first Half-Life..I can identify the polygons that the light hits, the range, etc., I'm just not sure how to do the actual rendering.. For example: The geometry is rendered with shadowmaps, so the area might be very dark.. I can apply an alpha-blended attenuation map in the right place, etc., but I don't know how to combine this with the original texture to make the area appear lit.. I can "brighten" things up using the attenuation map, but this doesn't help to bring out the original texture if the shadowmap is too dark.. I assume I'll need to use the attenuation map as some sort of alpha mask for the base texture, but I'm not sure how to go about doing this.. It occured to me that I may have the order of operations mixed up, maybe I need to render this area BEFORE rendering the shadowmaps, not after.. Thanks in advance to anyone who can help :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
hl1 seemed to write the flashlight into the level lightmaps dynamically

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
hl1 seemed to write the flashlight into the level lightmaps dynamically


Can anyone verify this?

I can make custom lightmaps as needed using a combination of the original and the attenutation map, but I'm concerned about the overhead..

The original geometry and shadowmaps are in display lists, so it's not easy to replace the original lightmap dynamically, I'm looking at re-drawing over the polygon..

If I can render the (attenutation map + base texture) over the affected area I don't need ro redraw the entire polygon, just a clipped portion of it..I also wouldn't need to generate a full lightmap for each affected polygon, just use a clipped version of the attenuation map..

Share this post


Link to post
Share on other sites
FYI I've found some info on projected textures, appears to be what HL1 uses..

Original geometry with base textures can be rendered along with projected attenuation map, all clipping is done automatically (less work for me, just need to identify which polygons are affected, not exactly where/how the light hits them)..

If anyone has any extra info (or where to find the best tutorials for using projected textures for something like this) it would be greatly appreciated, I've got some brushing up to do..

Thanks
-MM

Share this post


Link to post
Share on other sites
Imagine a two-pass approach; first pass to render lightmaps and z values, and second pass to render textures (modulating the textures with the lightmap values). If that's the case you can render as many extra things as you want between the two passes, additively, to brighten specific areas.

Share this post


Link to post
Share on other sites
Quote:
Original post by superpig
Imagine a two-pass approach; first pass to render lightmaps and z values, and second pass to render textures (modulating the textures with the lightmap values). If that's the case you can render as many extra things as you want between the two passes, additively, to brighten specific areas.


Cool, that would eliminate rendering the textures a second time..

Could you elaborate on modulating the textures based on the lightmaps? That sounds like it would be a simple blend operation, but I've never done it that way, I'm used to rendering the base texture, then rendering the lightmaps on top..

I can see the benefits of rendering lightmaps first, I've never thought of doing it that way, I like it :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If I recall, I was under the impression that half-life cast a ray, back up a few units from the collision of the ray with the wall, and then spawned a light there.

Share this post


Link to post
Share on other sites
Check the Quake 1/2 source code. The original Half-life was done with the Quake engine, although it was modified a lot the dynamic lights look the same so I assume it uses the same method.

Share this post


Link to post
Share on other sites
Quote:
Original post by monkeyman
Cool, that would eliminate rendering the textures a second time..
Aye. Though if your renderer is currently single-pass, using multitexturing to do the lightmaps and textures in one go, you can do exactly the same thing for the flashlight - calculate texture coordinates for the flashlight lightmap projectively, modulate that lightmap with the texture, and add the result to the scene. You should be sampling the same texels from the actual surface texture each time so it'll build up correctly.

Quote:
Could you elaborate on modulating the textures based on the lightmaps? That sounds like it would be a simple blend operation, but I've never done it that way, I'm used to rendering the base texture, then rendering the lightmaps on top..
It's just an alpha blending 'src*dest' op.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this