Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Drythe

Speed Up Alpha Blending

This topic is 5527 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Whenever I scale a primitive with alpha blending too much the framerate goes way down. Is there any way to speed up the rendering in code? thx

Share this post


Link to post
Share on other sites
Advertisement
doesn''t it resize it anyway? i tried 64x64 (originally 128x128) and it''s just as slow unfortunately. I think it''s just taking a long time to draw the pixels on screen or something. As soon as I take off alpha blend it''s liquid smooth (but no transparency obviously).

Share this post


Link to post
Share on other sites
How big is the part of screen usually covered with blended object ? If it slows down especially when the object is covering bigger part of screen, then it is fillrate, I think.

What is the gfx card you are using ?


VladR
Avenger game

Share this post


Link to post
Share on other sites
i''m rendering about 5 quads with 64x64 textures (*.png) and when they cover about 50% or more of the screen it goes from 60fps to about 4. I''m using a GF2 vid card.

Share this post


Link to post
Share on other sites
Since I`m currently switching 4 gfx cards (TNT1, GF2MX, GF2GTS, GF3) on a daily basis, I could test it at home if you send it to me.
But it seems to be a fillrate problem since it appears mainly when transparent quads cover more than 50% of screen.

Are you rendering some smoke particles ? Can`t this be achieved through Alpha Testing ? It is supposed to be faster than alpha blending. So will you send it to me to test it ?

VladR
Avenger game

Share this post


Link to post
Share on other sites
1) Change the resolution and bitdepth of the screen with the same stuff being rendered. If it affects the frame rate, then fillrate is your likely bottleneck. Alpha blending uses up more fill rate because as well as plotting the pixel, the original pixel must be read. Also you lose most of the benefit from depth buffering.


2) If the polygons have areas which are totally transparent (i.e. alpha at around 0%), turn on alpha-test with a reference value of 0. A pixel which fails alpha test doesn''t write to the frame buffer or go through blending so doesn''t use so much fill rate for those areas. Beware though that alpha test does move Z test to later in the pipe so some early-Z-reject schemes stop working so your more expensive pixel shader setups may turn into another bottleneck.


3) The reverse of the above - if you have a lot of opaque pixels you can do the alpha in two passes. The first pass with full Z buffer writes and testing on and all alpha which isn''t ~100% rejected (i.e. only render opaque pixels). The second pass with alpha test as in point #2 to reject 0 pixels and blending on as usual for the rest. Rendering a large body of water (sea, lake etc) is the kind of thing that would benefit from this (assuming stuff like Fresnel term changing the alpha value).


4) If ever you''re scaling these textures **down**, i.e. minifying, then ALWAYS use MipMapping or you''ll be inefficient in texel cache terms.


5) Check if there''s a difference between all your polygons being all on screen and the same polygons straddling the edges of the screen. Although you should be benefitting from guardband, it''s still a test I''d do to see if clipping was somehow killing you.


6) Unfortunate reality: fillrate is the biggest limitation on most chips. Be careful and/or clever with how much see-through/glowy stuff you use and how you use it (most games come up against fillrate issues at some time or other).


7) There''s a presentation at the developer.nvidia.com site called something like "balancing the pipeline" that I''d recommend you download - it explains:

a. how to detect which bottlenecks are affecting you

b. how to reduce the problem

c. what you can trade (e.g. if you''re fillrate limited, increase your polycount etc)


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Is there any difference between an alpha blend as just a flat color without a texture that would somehow make it different?

[edited by - valles on June 4, 2003 1:40:22 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Drythe
how do i get only semi-transparent pixels to pass the alpha test?



Some examples:

// all alpha values != 0 get rendered
// i.e. those that aren''t 100% transparent get rendered
D3DRS_ALPHAREF=0
D3DRS_ALPHAFUNC=D3DCMP_NOTEQUAL

// all alpha values != 0xFF (1.0) get rendered
// i.e. those that aren''t 100% opaque get rendered
D3DRS_ALPHAREF=0xFF
D3DRS_ALPHAFUNC=D3DCMP_NOTEQUAL

// all alpha values > 127 (~0.5) get rendered
D3DRS_ALPHAREF=0x7F
D3DRS_ALPHAFUNC=D3DCMP_GREATER


etc...


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!