Alpha rejection material cost..

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Alpha rejection material cost..

Post by syedhs »

Artist have gotten lazy and they simply use material with alpha_rejection in all meshes regardless of the texture transparency. A lot of the textures are not transparent - so the question is, is it worthwhile to remove 'alpha_rejection' for texture with no transparency in it? Will there be any speed increase or fps smoothness? Currently, the speed is not that great and there are fps hiccups here and there.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5537
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1395

Re: Alpha rejection material cost..

Post by dark_sylinc »

Well, the benefits depends on the bottlenecks and performance patterns.

However, yes alpha_rejection isn't free.
It prevents early depth from kicking in. So if you've got heavy pixel shaders and you're rendering front to back, you won't get the performance boost of having the Z Buffer kill the pixel shaders before they even get to run for the pixels that are hidden.
It also may disable Z compression.

It's still however, much faster than doing regular alpha blending. And if there's no heavy overdraw or pixel shaders are cheap, then there's not a noticeable difference.

On tilers (i.e. most mobile GPUs; no desktop GPU); alpha_rejection can be very expensive as the GPU must deal it like a special case. In some cases it may even be better to do alpha blending instead (depends on a lot of factors).
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Alpha rejection material cost..

Post by syedhs »

Thank you dark_sylinc for the reply.
dark_sylinc wrote: It prevents early depth from kicking in. So if you've got heavy pixel shaders and you're rendering front to back, you won't get the performance boost of having the Z Buffer kill the pixel shaders before they even get to run for the pixels that are hidden.
My scene is pretty simple.. all materials are just slapped with diffuse texture (and they are either solid or have transparency).
I have done simple test.. ie comment all the lines in the materials containing 'alpha_rejection'.. and I have got nice boost.. 35 fps to 45~47.. probably the actual FPS will come down to the worst 42fps..
It's still however, much faster than doing regular alpha blending.
Yes the alpha blending has already been eliminated altogether!

Probably I will end up with C++ code that reparse material files to remove the alpha_rejection when the texture doesn't contain transparency.

On the other hand, I read that DXT1 can contain 1 bit alpha, probably I can squeeze something here.. :evil:
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me