开发者

GLSL object glowing

开发者 https://www.devze.com 2023-02-03 20:06 出处:网络
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 c开发者_开发问答ube should be surrounded by a blue

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 c开发者_开发问答ube should be surrounded by a blue glowing effect. Any hints?


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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消