Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm learning shader program and need some general direction.

I want to add noise to my laser beam.

Which is the best way to handle it?

I could pre-compute an image and pass it to the shader. I could then use the image to change the opacity and easily animate the smoke by changing the offset of the texture lookup.

I could also generate noise in the shader and do the same thing the texture was used for.

Is it generally better to avoid I/O to the graphics card or the opposite?

share|improve this question
Doing less computations on the shader is definitely the way to go. Procedural generation of noise often implies the usage of branch (if-s or for-s). Using a texture fetch and some uniforms to control the animation is not that expensive and is the way to go. – teodron Nov 7 '12 at 16:59
"Fewer" computations, not "less". – Arcane Engineer Nov 8 '12 at 11:13
up vote 1 down vote accepted

I'd go with the first approach. It's not only easier to pull of but also more elegant. While this kind of overhead on the GPU mustn't necessarily be avoided (it's not fatal to go with your second approach), I'd rather save it up for something more worthwhile.

Now if the question was about whether to use a high-poly mesh or tessellate/displace a low-poly one in realtime, I'd definitely say go for the later. Such would be a case in which utilizing a shader rather than a pre-baked asset would be most advisable, as you'd otherwise waste a lot of good bandwidth.

share|improve this answer
I created a custom object for the laser beam. It creates one long cylinder, with no caps, and adds an extra 'edge loop' at each end. That lets me do fancy muzzle flash and leading edge effects. I thought about doing it as a billboard but didn't see how to get it to look correct. I wish I could figure out how to do the beam edge effects, but that's a different question. Thanks – Jay Nov 7 '12 at 16:32

depending if you are fillrate bound or memory bound, you can chose from that. but other than that, but i would go with the texture. that way you can let artist control the noise aswell.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.