[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Glowies and the Z-buffer.

Gregor Mückl wrote:
> Adam D. Moss wrote:
> I've recently played the Descend 3 demo for Linux and never actually 
> noticed that. I think this shows that this paricular effect was used 
> with great skill by the designers. Never use an effect just because your 
> engine can do it.
>> There are two ways to do these (and both are arguably correct
>> depending on the real-world effect you are trying to emulate):
>> 1) Cast a ray from the world's glowing point to the eye
>> origin, and if it reached the eye without being obscured then
>> draw a blurry glow-spot (and some lens-flare if you have no
>> pride) at roughly the point where this ray meets the near clipping
>> plane.  This can be quite expensive but allows the edges of the
>> glow to obscure objects which are nearer than the glowing point,
>> simulating an artifact of the virtual eye's lens.
>> 2) (cheaper) Draw the glow-spot in world-space over where the
>> glowing point (e.g. light) is, billboarded to face the eye.
>> You don't get the correct fringing of the glow's edges on the
>> near-plane as if the effect were happening in the virtual lens,
>> but this is cheap and people are likely to value this effect more
>> than effect 1)'s drop in frame-rate...  Also it's not
>> an incorrect approach if your glow is just meant to model
>> a diffusion of light through fog at the source.

(1) can be done nicely on nVidia hardware using their occlusion_test
extension...it actually lets you count how many pixels passed the
Z test when a light is either visible, hidden or partially hidden.
You can scale the transparency of the glow according to what fraction
of the area of the light passed the Z test.  This is very cheap and
MUCH better than either (1) or (2).

> I don't know how expensive it is to temporarily disable z buffering. 

Very cheap.

> Hm... if there was a way to test whether a polygon is partially occluded 
> it would come in very handy here. But I seriously doubt that this can be 
> done in plain OpenGL.

Not *plain* OpenGL...well...you could render the lights into the stencil
plane or something - read back the frame buffer and search it for lighted
pixels and go render glows around those locations...that would be incredibly
slow though.

The nVidia occlusion test is awesome...every card should implement it.

There is also an HP occlusion test extension - but it's poorly designed
and consequently cannot be implemented efficiently on hardware renderers.

---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1@airmail.net>    WorkEmail: <sjbaker@link.com>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sf.net    http://tuxaqfh.sf.net
            http://tuxkart.sf.net http://prettypoly.sf.net