• Advertisement
Sign in to follow this  

Half-Life 1 Electricity and Beams

This topic is 4788 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anybody know how Valve did the Electricy and Beams in Half-Life 1. They are very versitle and look different in a lot of cases. They also seem to be 3D. I have experimented with triangle strips so far but they look no where near as good. I am going to experiment with lines and line size changing next.

Share this post


Link to post
Share on other sites
Advertisement
I can't remember the precise details offhand, but here's what I recall.

The electricity beams were usually actually made up of many electricity beam entity type things placed in the level editor, to give the overall effect. These had parameters like amplitude, frequency, diameter, colour etc. which the mapper would set for the desired effect. As for actually rendering them I'd be fairly sure they used texture tri strips between the two end points, maybe they had two at 90 degrees to each other to give it a more 3D look.

-Mezz

Share this post


Link to post
Share on other sites
Yeah, firing up Hammer and examining the properties on the env_beam entity will clue you into how it works quite a lot.

The beam itself is basically just a function that takes a parameter between 0 and 1 (start and end), and returns a position in 3D (based on an offset from the straight line between the endpoints). I'm pretty sure it renders by sampling that function at regular intervals and drawing a screen-aligned quad between each sampled point.

Of course, if you're really interested, I believe the relevant code is in the HL1 SDK. Check through the client DLL, that's where special effect rendering is handled for mods.

Share this post


Link to post
Share on other sites
I've looked into using translucent lines but (in OpenGL) the maximum line width is pretty weak and the lines don't join well causing broken elbow syndrome. It must be something different as you guys suggest for the curvy lines to work and look nice.

These simple touches along with the excellent looking HUD in the game are why I enjoyed it for so long. Thanks for the help.

I think I'll look into quad strips next to replace lines.

Share this post


Link to post
Share on other sites
- Generate a bunch of disturbed points along two points (start and end). You'll have an electricity beam line.
- Now calculate the normals, relative to the screen, for each point, by averaging the normal of the two line segments connected to that point.
- Using the normals, you can generate a series of screen aligned quads. Pseudocode:

for (n = 0; n < beam.vertexCount-1; n++) {
quad[0] = beam.vertex[n] - beam.normal[n]*beam.width
quad[1] = beam.vertex[n] + beam.normal[n]*beam.width
quad[2] = beam.vertex[n+1] + beam.normal[n+1]*beam.width
quad[3] = beam.vertex[n+1] - beam.normal[n+1]*beam.width
}


- Now give your quads a nice texture. It should be a linear gradient with the following colors (from left to right): black->blue->white->blue->black
- Draw those quads with additive blending.
- Fade out the beam quickly, while you draw new beams (with randomly disturbed points) every few milliseconds.

Share this post


Link to post
Share on other sites
The beams in HL1 did have 'elbow syndrome' as you call it - the joints were often darker because two lines (or quads or whatever) would overlap some, and the problem was worse if you made the beam more noisy. Usually, they were there and gone so fast, and far enough away, that you couldn't tell. I only really noticed when I tried to make a mod that had some persistent beams. When the beams stick around, the effect is extremely noticable especially if you're close to the beams.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
@M3d10n
thanks for the nice info,
but can you please explain
Quote:
- Now calculate the normals, relative to the screen, for each point, by averaging the normal of the two line segments connected to that point.

a bit more, i don't really understand what you do
rob

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement