Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLSL object glowing

is it possible to create a GLSL shader to get any object to be surrounded by a glowing effect? Let's say i have a 3d cube and if it's selected the cube should be surrounded by a blue glowing effect. Any hints?

like image 974
Andreas Roth Avatar asked Jan 13 '11 10:01

Andreas Roth


1 Answers

Well there are several ways of doing this. If each object is also represented in a winged edge format then it is trivial to calculate the silhouette and then extrude it to generate a glow. This however is, very much, a CPU method.

For a GPU method you could try rendering to an offscreen buffer with the stencil set to increment. If you then perform a blur on the image (though only writing to pixels where the stencil is non zero) you will get a blur around the edge of the image which can then be drawn into the main scene with alpha blending. This is more a blur than a glow but it would be relatively easy to re-jig the brightness so that it renders a glow.

There are plenty of other methods too ... here are a couple of links for you to look through:

http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html
http://www.codeproject.com/KB/directx/stencilbufferglowspart1.aspx?display=Mobile

Have a hunt round on google because there is lots of information :)

like image 149
Goz Avatar answered Oct 26 '22 17:10

Goz