Thread: Glow shader with tiny glow sources.

  1. #1
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476

    Glow shader with tiny glow sources.

    Hi. Firstly, nice new layout. And Facebook Connect.

    Ok, now I want to ask a question. Not exactly a C/C++ problem, or game programming, rather a graphics programming one. I've asked the gamedev.net about this but I decided to ask here for better chance to get the answer.

    I am trying to implement the shader in this article: Gamasutra - Features - Real-Time Glow . It has been successful so far with a pretty big model. But when I decreased the model's size and distance from the camera (to the point that it became a single dot in the scene), it didn't glow. I know that it's probably due to the small size of the glow source so the data to do some neighbor-sampling are not enough. Alas, my scenes have lots of this tiny glow sources that should be glowing. So, can anyone tell me how to fix this? Thanks in advance.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    The reason for the low amount of glow is that there are not enough bright pixels being rendered in order to create the final glow after you blur the downsampled scene. The only way I know of to remedy this is to use good old fashioned glow billboards in instances where the actual glow algorithm does not produce satisfactory results. In reality the objects that are glowing in the foreground ought to contribute enough glow to divert the player's eyes away from those areas that do not glow. Alternatively you could use depth of field effects as well to guide the player's eyes towards the more prominent areas and this would also produce a bit more blur on the distant small areas that are not glowing that much.

  3. #3
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Yeah that's what I thought. Maybe I'll try that glow billboards but I can't find any source from google. Can give me some examples / articles about it please? Thanks again.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Glow billboards simply need a glow texture. These can be created in GIMP as white alpha blended textures. These 'glows' can then be colored by the vertices of the quad and they can be scaled, rotated, etc. to some degree to make them appear more realistic. The larger the quad and the more indistinct the glow area (in other words no hard edges on the glows) the more convincing they will be. Quite honestly in GIMP you can start with a pure white texture as the color. Create a new image the same size as the first but it should be black. Add a reasonably large white circle brush stroke in the middle of the texture. Go the the filters and run the gaussian filter on the thing a few times to get a nice blur. Ramp down the white color with the contrast/brightness and/or RGB controls to get a somehwat gray/white blurred circle. Use this texture as your alpha and combine it with the color from the first texture. This should create a nice glow texture that you can scale and use in various places without being too overpowering. Run the final render through your glow shader and the shader should pick up the glows from the quads using the glow texture and you should get a better glow around those areas. Be very careful that the gaussian filter does not cause non-zero areas of the texture to reach the edges of the image as this will create hard-edged ugly borders when you render the quads with the glow texture. The whiter your glow area the more contribution to the final image and vice versa. You can also use additive blending when drawing the quads to ramp up the colors a bit. I would be careful though since you are still going to run the final render through the glow shader which could produce some overly bright areas.

    One other possible and a bit more simple answer is to really ramp up the exposure on the final output. Try a vignette technique or something similar to really ramp the bright areas up. This will certainly produce a lot of glow in the foreground but you could find some middle ground that looks good for close objects and good enough for objects further away. You can use a depth of field technique (or the z-buffer) to find the texels that are farther from the camera and then ramp these texels up without ramping up the texels that are produced from objects that are closer to the camera. This would ramp the far away distant and smaller glows and leave the near and larger glows alone. Alternatively you could do two passes and on the first render pass you only render far away glowing objects and really ramp up the exposure. The second pass would render the closer objects and would not use such an extreme exposure. Run the entire final render texture through your glow shader and it should look pretty good.

    I am interested to see what you come up with. Some time ago I attempted to implement this same technique and found it was not as simple as the article made it out to be. I could never achieve the correct amount of glow and ended up scrapping it b/c it made my world look too bright.
    Last edited by VirtualAce; 06-22-2011 at 11:23 PM.

  5. #5
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Sorry for the long delay. It was weekend so... :P

    OIC. So, I should put a quad with glow texture that always face the camera, right? Just like a billboard, right? But if I've got lots of light sources (like 100 or so of glowing tiny dots), won't that increase the camera facing routine calls? Won't that affect performance? Maybe I'll try the vignette technique. Can you give me any source about it? I've tried googling but what I found were non relevant articles like vignette technique on Canon camera and BMW cars (umm???).
    Last edited by g4j31a5; 06-27-2011 at 05:21 AM.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL: Translucency and Glow
    By Hunter2 in forum Game Programming
    Replies: 8
    Last Post: 12-16-2008, 10:15 PM
  2. not able to understand this tiny tiny method
    By noobcpp in forum C++ Programming
    Replies: 5
    Last Post: 10-20-2008, 10:42 AM
  3. Cel Shader
    By taelmx in forum Game Programming
    Replies: 4
    Last Post: 11-15-2006, 07:36 AM
  4. Shader hell
    By VirtualAce in forum Game Programming
    Replies: 4
    Last Post: 08-18-2006, 09:21 PM
  5. Compiled GLOW into static lib
    By cboard_member in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 03-05-2006, 03:01 PM