alpha testing

Member
Posts: 194
Joined: 2009.02
Post: #1
When performing an alpha test in ogl, is it possible to use the alpha value already in the frame buffer corresponding to the incoming fragment as the ref value for glAlphaFunc(without resorting to glReadPixels())?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Nope.

Assuming you are doing that to mask your shadows on your iPhone game, it's not even recommended to use alpha testing on the iPhone anyway.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #3
Yes what I'm working on is an iphone project. By "not recommended", do you just mean it's very slow?

I have no trouble rendering multiple shadows from different light sources but only with a single brightness(in other words they don't take into account the falloff of influencing lights).

I though maybe I could use the alpha buffer like you would use a stencil buffer to mask shadows taking into account the falloff gradients from other lights- I tried this without alpha testing just using different blending functions and I got a lot of mixed results(something was always incorrect) along with a headache.
Quote this message in a reply
Member
Posts: 30
Joined: 2009.02
Post: #4
I'm not sure what the status of the stencil buffer is on the iPhone, but it can do some pretty sweet and quick logic. Even though in my last posts I distanced myself from it, I've since made extensive use of it when mixing multiple light and shadow sources, and it works great. I'd try looking into using it to mask out where lights write their alphas, then let their alphas accumulate together so they mix properly.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #5
Simple attenuation can be implemented by blending the shadow color based on the distance from the light:

[Image: TexEnv8bitShadow.png]
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  png without alpha fine, png with alpha, nothing dave05 6 6,707 Jun 11, 2005 10:31 AM
Last Post: dave05