Opengl glow...?

Started by
26 comments, last by JavaCoolDude 18 years, 11 months ago
Hello, i was wondring if anyone could show me an example of how to create a "glow" effect? for somthing that is bright, like this http://www.ixbt.com/video/itogi-video/gal1003/r9700-splintercell-2.jpg See all the lights and stuff? how they draw slightly overtop of the other things....sooo anyone got any examples?(or even the technical name for this, so i can search for it better) thanks
Advertisement
It's a post-processing effect created using pixel shaders.

I know that's not much help. :D
I was under the impression that you could get the same effect by rendering all the geometry that you want to glow, to a low resolution off-screen buffer, and then additively blending the buffer over the whole screen. If this is the case, then you wouldn't need pixel shaders.

Perhaps someone can correct me if this is not the case. I could be mistaken, and this could be a different effect altogether. I know that some PS2 games use glow buffers in this way.
Look at this (you might need to create an account). It describes what you are trying to do.
If you want to go a bit beyond, look up "high-dynamic range." Look here, for instance. He has some slides on how its done.


jfl.
Quote:Original post by Oxyacetylene
I was under the impression that you could get the same effect by rendering all the geometry that you want to glow, to a low resolution off-screen buffer, and then additively blending the buffer over the whole screen. If this is the case, then you wouldn't need pixel shaders.

Perhaps someone can correct me if this is not the case. I could be mistaken, and this could be a different effect altogether. I know that some PS2 games use glow buffers in this way.


ohhh....so sorta like rendering it all again, then scaling it bigger and then pasting it overtop? im still not 100% down with all this fancy dancy computer lingo :P and for the pixel shaders, does the radeon 9700 pro support them? thanks for the quick answers :D
Quote:Original post by Oxyacetylene
I was under the impression that you could get the same effect by rendering all the geometry that you want to glow, to a low resolution off-screen buffer, and then additively blending the buffer over the whole screen. If this is the case, then you wouldn't need pixel shaders.

Perhaps someone can correct me if this is not the case. I could be mistaken, and this could be a different effect altogether.


Yup that's right. Using a pixel shader would be a better solution but it doesn't work on all platforms (PS2). After you have the low res texture just draw it a few times with an diffrent offsets and diffrent alphas; a poor mans gaussian blur.
Don't shoot! I'm with the science team.....
A method without pixel shaders is...

1. Set the viewport to 512x512 (glViewport(0, 0, 512, 512);) and render the scene.
2. Download (grab) the framebuffer to a 512x512 buffer (glReadPixels(0, 0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, pixelData);)
3. Apply a "blur" filter to the pixelData. Check Gamasutra for an article on fast blurring.
4. Apply a "contrast" filter to the pixelData. Do something like channel = channel / N * N for each red, green and blue channel (the greater the N, the bigger the contrast).
5. Upload the pixelData to a 512x512 texture.
6. Set the viewport to your nornal viewport (f.e. glViewport(0, 0, 800, 600); for 800x600 mode) and render the scene again.
7. Enable blending (glEnable(GL_BLEND);) and set the blending function to perform additive blending (glBlendFunc(GL_ONE, GL_ONE);).
8. Draw a quad at the whole screen that contains the texture you made at step 5.
9. Disable blending.
10. Show the rendering (flip the buffers - SDL_SwapBuffers() in SDL).

and that's it.

(probably :-P)

The above method will add a glow effect in all bright areas, which is not that good. You probably want to do something else: instead of rendering the scene in step 1 with usual materials, use "glow materials" (f.e. glow textures) and render only the objects which have a "glow material". This will have a better result and probably speed up the rendering because you'll only render objects which have glowing.
--Slashstone - www.slashstone.comNerveBreak free scripting system.
wow, 5 additional replies while i was writing this one :-P
--Slashstone - www.slashstone.comNerveBreak free scripting system.
Quote:Original post by badsector
A method without pixel shaders is...

1. Set the viewport to 512x512 (glViewport(0, 0, 512, 512);) and render the scene.
2. Download (grab) the framebuffer to a 512x512 buffer (glReadPixels(0, 0, 512, 512, GL_RGB, GL_UNSIGNED_BYTE, pixelData);)
3. Apply a "blur" filter to the pixelData. Check Gamasutra for an article on fast blurring.
4. Apply a "contrast" filter to the pixelData. Do something like channel = channel / N * N for each red, green and blue channel (the greater the N, the bigger the contrast).
5. Upload the pixelData to a 512x512 texture.
6. Set the viewport to your nornal viewport (f.e. glViewport(0, 0, 800, 600); for 800x600 mode) and render the scene again.
7. Enable blending (glEnable(GL_BLEND);) and set the blending function to perform additive blending (glBlendFunc(GL_ONE, GL_ONE);).
8. Draw a quad at the whole screen that contains the texture you made at step 5.
9. Disable blending.
10. Show the rendering (flip the buffers - SDL_SwapBuffers() in SDL).

and that's it.

(probably :-P)

The above method will add a glow effect in all bright areas, which is not that good. You probably want to do something else: instead of rendering the scene in step 1 with usual materials, use "glow materials" (f.e. glow textures) and render only the objects which have a "glow material". This will have a better result and probably speed up the rendering because you'll only render objects which have glowing.


ok thank you, using this way is there anyway i can force it? like just so it well make an object glow based on some settings? like amount and intensity?
[Honest attempt to help]
I'm in the process of writting a demo that exploits both HDR and GLOW techniques desribed above by fellow members, do you want me to send you a PM when I'm done with the source and hinaries?
[/Honest attempt to help]

This topic is closed to new replies.

Advertisement