   Sun effects (blooming)
  I want a sun to bloom over the edges of an interposing planet or ship object.  That is, I want the sun to bleed heavily over the front of a partially obscuring object which is closer to the camera.  There's a rough example here, but in games it is often far prettier...http://www.indussky.com/gallery/thumbnails/Lunar_Eclipse_Partial_20080220_tn.jpgI don't know how this usually works but was thinking that IF my shader can read the scenes depth buffer I could render the sun last and it could know where it was obscured... then, for each obscured pixel, make a vector expressing its direction from the centre of the sun using (U - 0.5f, V - 0.5f)/Scaling And use this vector to do a 'walking sample of neighbours' - ie, count the number of 'sunny' pixels using only those neighbours radiating outwards from the suns centre starting at the pixel being tested.  Such that the more sun that shows, the deeper the bleed.  But then, maybe that idea is unworkable, suboptimal or jus' plain silly.So, ignoring my uneducated ramblings, can anyone describe an efficient workable setup for accomplishing something like this in realtime ?  Preferably not a postprocessing bloom effect over the whole scene unless absolutely necessary.BTW: A perfect example of this can be seen in "EVE Online" ... http://images.mmosite.com/space/060915/biggish/eve07_dt6wPX63HC3G.jpghttp://cache.kotaku.com/assets/resources/2006/10/eve.jpgIgnoring the horizontal lighting effect - Is that a clever shader applied to a post-rendered sun?  Some sort of modified Lens-Flare with additive sprites making the effect ? A post-process over a completed scene ?I so need to know how to do this : /Many thanks,-GaryCh[Edited by - GaryCh on May 25, 2010 4:49:32 AM]
The Internet, muddyfunster! Do you use it?Make sure to have a look at this word of warning as well.   ;Quote:Original post by ShadowdancerThe Internet, muddyfunster! Do you use it?Yes, I googled first, but thanks anyway.The examples of bloom are all PP and quite costly, however I am pretty sure it is possible in shader without doing a fullscreen bloom.  There are also additive point sprites, and a great example in NVidias CG Browser called "Glow" but it doesn't show me the source of anything except the blending of texture layers.I have shown in my post that I can think of a few ways of doing it, and I actually point out that I'd like to avoid a full PP bloom if possible.I'd just like some input on how it can be done without a fullscreen PP bloom.Quote:Make sure to have a look at this word of warning as well.You know, that last link almost makes up for the otherwise unhelpful nature of your response XD-GaryCh   ;  I honestly don't think you're looking at that much of a performance hit even on current "low-end" hardware, that's not something I'd be bothered with. You're not reading the framebuffer back to RAM to apply the effect on the CPU or anything.If you try doing it the "smart" way, you'll spend more precious frametime trying to determine where your blooming objects sit, what occludes them, how far the bloom spreads, etc., than by just doing a blanket sweep over the whole frame. Graphics hardware is far better at bulk processing than with smart algorithms.(edit) I'm also pretty sure that EVE "cheats" for that effect, and just renders a sun in front of an occluding object, scaled by coverage. It was there long before the (rather crappy) HDR.   ;Quote:Original post by ShadowdancerI honestly don't think you're looking at that much of a performance hit even on current "low-end" hardware, that's not something I'd be bothered with. You're not reading the framebuffer back to RAM to apply the effect on the CPU or anything.Ah, that's good to know - I intuitively figured it would be a real hog.  I'm actually writing a few test shaders now... luminance biased filter, Gausian directional blur, the combiner, etc.  So hopefully (If I can get the texture rendertargets to work, never tried that before) I'll be able to measure the hit.Quote:If you try doing it the "smart" way, you'll spend more precious frametime trying to determine...Point taken.  Although, when I was considering alternatives I was looking into a sunshader which blurred outwards from it's visible pixels using lookup into depth on a finished scene.  If it worked then no positional math.  I'll probably still try that at some point, just for the experience.Quote:I'm also pretty sure that EVE "cheats" for that effect, and just renders a sun in front of an occluding object, scaled by coverage. It was there long before the (rather crappy) HDR.Hmmm... that's kinda what I was looking for really ... after all, isn't all 3D programming a series of elaborate hoaxes against the viewer?  Billboards, bumpmaps, skyboxes (and bears, oh my!) *grin*  The effect still looks pretty decent, if I can get that using some cheat that is faster than blooming then I'd definitely explore that route, but like you say it is then the CPU side hit from all that extra math to calculate the level of obstruction.(Hmmm... Perhaps I should try patching the IAT and see if a wireframe view yields any clues regarding point-sprite cheating.  )Since I seem headed down the bloom route the question now is, should I render to the RGB screen surface, then luminance bloom the screen via some buffers for the bloom calculations ... or, should I render to an ARGB and let objects use masks to set their bloom preference in the Alpha.Again, not sure what the performance hits would be in the latter.Any ideas ?  My gut tells me the last is gonna be more flexible later when tweaking a fully populated scene to get the lighting balance right.  Or should you just choose a single bloom strategy and stick with it for the sake of scene continuity.Thanks for the pointers,-GaryCh   ;  I agree with Shadowdancer's evaluation of the EVE method. My guess (based on playing EVE a lot) is that EVE uses hardware occlusion queries to determine the occlusion level.If you're going to be doing a cheap bloom with an LDR buffer, you definitely want to control which objects will be "blooming" somehow, like with your alpha idea. Basing it on luminance with an LDR buffer looks pretty horrible IMHO.   ;  Okay, got the full screen PP bloom working (intermediate buffers are size/4) and after a LOT of tweaking it is looking fantastic... better than I imagined and the frame rate hardly even dipped.  But yes, I really think it needs some way for each object to control bloom attenuation as my reflections and specular highlights can sometimes overexpose.But all in all a positive experience.Going to draw each object to an ARGB buffer instead and use the final A channel to control my ExtractHighlights filter.  This way my sun can write 1.0f to A and bloom like crazy, whilst highlights on the shiny parts of my ships hull can be RGB=(1.0f, 1.0f, 1.0f) but by giving an A=0.4f they won't bloom ... let the emissive lights built into the diffues texture can also be A=0.8f and spread nicely making them more prominent than their texels.Lasers, Thrusters, Jet nozzles, etc can have high bloom too, and I can balance them all using the brightness slider in photoshop till they all gel together well.Finally I know where I'm headed.All in all a very productive day though : )Thanks guys!  Crates of Stella Artois all round : )))))-Gary;  Take a look at this one:http://www.mathematik.uni-marburg.de/~menzel/index.php?seite=tutorialsHope it helps.   ;  Gary: we demand screenshots! :-)   