Render: laser with 'persistence of vision' effect
by Michael Spencer · in Torque Game Engine · 03/19/2006 (1:30 am) · 8 replies
I want to create a "realistic" laser weapon effect, inspired by real-life effects seen when you film powerful laser pointers with a camcorder. I wonder if I could get a few pointers, to start me off in the right direction. I'm hoping to be directed to some documentation to read, or parts of the code to look into. Maybe even some implementation hints. (Or worse, evidence that my prior-thread search missed something obvious.)
1) I want to create a "persistence of vision" effect wherever the visible beam of a laser is on a client's screen. I'm picturing rendering a laserbeam as a one-pixel-wide purple line, masking that purple and creating a 2D overlay, processing the 2D image, and using THAT to create my laser-beam effect.
In-game effect: suppose another character to the right of the player fires a brief (one-frame-duration) laser across the view of the player. Neither the start nor the end of the laser are visible -- just the beam. This beam would create a bright "burned in" image, as if the bright line was stuck to the player's monitor, staying at the same screen coordinates even if they turn, jump, move, etc. The image would fade out within a certain amount of time -- maybe a fraction of a second, maybe longer.
2) I would like to create a kind of blinding effect whenever the impact spot of a laser shot is on a client's screen. I'll detect this intersection / impact point, "bloom" it into a huge spot on a 2D overlay, and wash out the rest of the screen (same effect as if the client is looking directly into the sun) for a few seconds.
In-game effect: suppose the player is being chased by another character with a laser weapon. The other character fires a shot and misses, but the laser hits the wall ahead of the player. The player sees a persistence-of-vision effect from the beam, as described above, but the player also has a BIG blinding spot of light centered around where the laser hit the wall. That spot makes vision very difficult, until several seconds pass and the effect wears off.
3) If the player is hit in the face with the laser, they're blinded. I think I can handle this one alone. :-)
I guess I'm too intimidated to just tinker with the rendering engine on my own. I must be too afraid of taking this stable, mature game engine and making it crash-prone again. Oh well.
Thanks again for reading!
--Michael Spencer
1) I want to create a "persistence of vision" effect wherever the visible beam of a laser is on a client's screen. I'm picturing rendering a laserbeam as a one-pixel-wide purple line, masking that purple and creating a 2D overlay, processing the 2D image, and using THAT to create my laser-beam effect.
In-game effect: suppose another character to the right of the player fires a brief (one-frame-duration) laser across the view of the player. Neither the start nor the end of the laser are visible -- just the beam. This beam would create a bright "burned in" image, as if the bright line was stuck to the player's monitor, staying at the same screen coordinates even if they turn, jump, move, etc. The image would fade out within a certain amount of time -- maybe a fraction of a second, maybe longer.
2) I would like to create a kind of blinding effect whenever the impact spot of a laser shot is on a client's screen. I'll detect this intersection / impact point, "bloom" it into a huge spot on a 2D overlay, and wash out the rest of the screen (same effect as if the client is looking directly into the sun) for a few seconds.
In-game effect: suppose the player is being chased by another character with a laser weapon. The other character fires a shot and misses, but the laser hits the wall ahead of the player. The player sees a persistence-of-vision effect from the beam, as described above, but the player also has a BIG blinding spot of light centered around where the laser hit the wall. That spot makes vision very difficult, until several seconds pass and the effect wears off.
3) If the player is hit in the face with the laser, they're blinded. I think I can handle this one alone. :-)
I guess I'm too intimidated to just tinker with the rendering engine on my own. I must be too afraid of taking this stable, mature game engine and making it crash-prone again. Oh well.
Thanks again for reading!
--Michael Spencer
#2
03/19/2006 (9:23 am)
The only problems with that are: I already have TGE and don't want to buy TSE... I don't own a computer with a graphics card capable of running TSE, and I don't want to require my users do either. The effects I'm animating are very much 2D -- once the laser shot is drawn, the laser's path is pushed from 3D down to 2D, and then it's a rather simple 2D procedural animation.
#3
You're right, though -- render-to-texture would be helpful. I might not be able to afford that.
03/20/2006 (7:46 am)
Or I guess another way to say that is: rendering a straight line in 3space should be easy. If the engine won't help me -- if I can't get an image buffer of the current screen contents -- maybe I can just manually render the line. You know, with math and stuff. :-P (I mean, going back to where I studied openGL -- place the ray in 3space according to the firing character's rotation matrix, rotate using the viewer's rotation matrix, draw the master 'overlay line', walk the scene looking for objects with a closer z position and clip the line. Then I have my "purple line", or if multiple lasers at once, my 'several shades of purple in several lines', and I can apply 2D overlay processing as needed.)You're right, though -- render-to-texture would be helpful. I might not be able to afford that.
#4
Reason being, what you are describing in your parenthetical is a client-side effect determined by proximity to the player and the player's LOS.
Sounds like you need create a method of exposing the projectile data to the client so you can then manipulate it directly during the client render of the scene. You could then use standard Torque methodology rather than reinventing the wheel.
03/25/2006 (2:27 am)
Are you using the Beam.cc resource or are you using some projectile variant?Reason being, what you are describing in your parenthetical is a client-side effect determined by proximity to the player and the player's LOS.
Sounds like you need create a method of exposing the projectile data to the client so you can then manipulate it directly during the client render of the scene. You could then use standard Torque methodology rather than reinventing the wheel.
#5
Are there any tutorials I might be missing? I don't so much need something that'll show me what to do to achieve a particular effect, but something general which will help me understand how the server object -> client object -> renderer flow occurs. Again, I'm not looking for someone to give me the answer giftwrapped -- I am willing to read and learn, but am confused about where to start.
03/25/2006 (9:35 am)
I had looked at beam.cc earlier, and it seemed interesting. I was hoping I'd be able to use something similar. The "targeting laser" from Tribes seems like what I need to start with.Are there any tutorials I might be missing? I don't so much need something that'll show me what to do to achieve a particular effect, but something general which will help me understand how the server object -> client object -> renderer flow occurs. Again, I'm not looking for someone to give me the answer giftwrapped -- I am willing to read and learn, but am confused about where to start.
#6
I keep fighting off comments that "Torque games all look like they're Tribes 2 mods" by saying how helpful this forum is, and how easy they make it to dive into the renderer and make changes. Uh oh...
04/01/2006 (10:52 am)
Wow. Nobody at all?I keep fighting off comments that "Torque games all look like they're Tribes 2 mods" by saying how helpful this forum is, and how easy they make it to dive into the renderer and make changes. Uh oh...
#7
All I could understand that all you want is burn an afterimage to the screen, like the ones when you look at a strong light/flash.
I'd go after the Motion Blur resource. It implements a screen FX manager of sorts, and it got the structure for you to code-in new fullscreen effects as well. It calls a preRender() function in the active effects, then capture the buffer, and call a render() function, passing the capture texture so you can use it. It's surely possible to code an effect that draws a laser on the render() method (only on the first frame), then fades it gradually away, creating the burned image effect.
Best place to learn how to do effects: the source code. Find the thing that does the closest to what you want to do, and see how it works. Looking at other people's resources, and isntalling a helluva different resources can also help a big deal in getting familiarized with the source. The more source-code experience you get, the more flexible Torque becomes, and more crazy stuff you can do.
04/01/2006 (1:58 pm)
Too much bitching, to little trying. That doesn't help your problem. Often people want to do things that aren't obvious nor they can explain it properly, that I think is your case. I think I partially understand the effect you want, but I never seen real life laser weapons nor physically laser beans in movies/games, so I can't get the picture properly.All I could understand that all you want is burn an afterimage to the screen, like the ones when you look at a strong light/flash.
I'd go after the Motion Blur resource. It implements a screen FX manager of sorts, and it got the structure for you to code-in new fullscreen effects as well. It calls a preRender() function in the active effects, then capture the buffer, and call a render() function, passing the capture texture so you can use it. It's surely possible to code an effect that draws a laser on the render() method (only on the first frame), then fades it gradually away, creating the burned image effect.
Quote:
Again, I'm not looking for someone to give me the answer giftwrapped -- I am willing to read and learn, but am confused about where to start.
Best place to learn how to do effects: the source code. Find the thing that does the closest to what you want to do, and see how it works. Looking at other people's resources, and isntalling a helluva different resources can also help a big deal in getting familiarized with the source. The more source-code experience you get, the more flexible Torque becomes, and more crazy stuff you can do.
#8
Also, thanks VERY much for that resource. I'll not bug you all with this again until I can demonstrate some understanding of how TGE implements rendering, how the Motion Blur resource alters that, and how I can use these changes to approach what I want to implement.
04/02/2006 (1:27 am)
Thanks for the advice. The last time I looked at the source I got a bit confused, but I've gained a bit more experience since then. I'll try again.Also, thanks VERY much for that resource. I'll not bug you all with this again until I can demonstrate some understanding of how TGE implements rendering, how the Motion Blur resource alters that, and how I can use these changes to approach what I want to implement.
Torque Owner Josh Moore