A Fast Technique for Rendering Realistic Laser Bolts

Started by
11 comments, last by Styves 7 years, 5 months ago

Hello,

While I'm unsure if this approach is entirely new, I've developed a technique for rendering laser bolts or lightsabers that looks realistic from all angles in 3D, even when viewed directly head-on. The effect also works with perspective distortion. It's not based on post-processing blur or traditional billboarding techniques, and it only requires 6 cleverly-positioned triangles, so it's cheap to render.

Here are two screenshots showing the effect with laser bolts of varying colour and width. Note that the red laser bolt looks realistic when viewed head-on, even in the presence of perspective distortion.

[attachment=33955:laser-shot-1.png][attachment=33956:laser-shot-2.png]

I've posted an explanatory 2 minute video on YouTube describing the effect. The video also depicts a wireframe overlay at one point to clearly show what's going on.

Complete source code and executable for the program used in the video demonstration (and the above screenshots) is available here.

A more complex example showing a lot of batch-rendered laser bolts is available here.

I hope someone finds this useful.

Thanks,

Geoff

Advertisement

Nice, will check it out later, can it also be used for simple bullets? Or other simple projectiles?

Indie game developer - Game WIP

Strafe (Working Title) - Currently in need of another developer and modeler/graphic artist (professional & amateur's artists welcome)

Insane Software Facebook

Nice, will check it out later, can it also be used for simple bullets? Or other simple projectiles?

There's no reason it couldn't be used for tracer-style bullets or shorter/smaller lasers, yes. In my provided implementation, you can vary the length, width, and colour. The base texture, which is coloured in the fragment shader, could also be modified to give a different appearance (such as less/more glow).

At work, and I have a firewall in between, will certainly look into it! :)

Indie game developer - Game WIP

Strafe (Working Title) - Currently in need of another developer and modeler/graphic artist (professional & amateur's artists welcome)

Insane Software Facebook

That's quite cool, haven't seen those done like that before.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

This is very cool, but I wouldn't call it "realistic". Reality is boring, anyhow. :)

Looks good. Would love to see more texture variations if that's possible. Regarding existing approaches, I remember there was a demo by nvidia for volumetric lines. Here is the white paper, and here is a dx9 implementation of the technique, although I think your approach is simpler. Good stuff!

Would love to see more texture variations if that's possible.

My implementation currently doesn't support multiple textures, but this is a simple addition to make. It would be very useful, and I'll definitely add this in the future. Thanks for the suggestion.

Regarding existing approaches, I remember there was a demo by nvidia for volumetric lines. Here is the white paper, and here is a dx9 implementation of the technique, although I think your approach is simpler.

Interesting---I haven't seen that before. I see that they use a texture containing 4x4 tiles and select the most appropriate one based on the orientation factor. I guess the downside of this is that it requires one to build or have these textures on hand. This could be a painful process if you want different appearances (colour can be easily addressed in a fragment shader, but glow intensity would be trickier) for your volumetric lines. The paper also seems to suggest that even with their proposed corrections for smoother transitions between the textures, the effect won't be totally smooth.

Why do you need six triangles instead of just four? Two of them seem to be completely transparent...

Why do you need six triangles instead of just four? Two of them seem to be completely transparent...

I had the same comment on my YouTube video. It just appears that the two end triangles are unused because the glow inside of the texture is relatively small compared to the texture size itself. If a larger glow (relative to the texture size) was used, those two end triangles would be coloured, too.

But, it's a good point---for the texture I've chosen to use in my implementation, those two end triangles aren't required because the glow is so small.

This topic is closed to new replies.

Advertisement