Skip to main content
gamedev.net
🔒 Locked

transparency

Started by wxb1 Jun 21, 2004 at 10:45 AM 11 replies 1.2k views
Original Post
wxb1
wxb1
What is the best way to fix overlapping transparent polys (or polys that partially break the plane of another poly)? z-sorting alone doesn't fix the problem. I started writing some complicated code to check the half space of a poly vs another polys verts... but there are some issues. Will directx zbias take care of this problem? I need a simple solution...
JohnBolton
JohnBolton
Split the polys at their intersection and z-sort, try additive blending, or live with it.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
wxb1
wxb1
depth peeling is no good for this app to intensive... but additive blending? That sounds like what I want...
Squirm
Squirm
glBlendFunc(GL_ONE, GL_ONE);

but no idea what the DX call looks like.
superpig
superpig
Quote:
Original post by Squirm
glBlendFunc(GL_ONE, GL_ONE);

but no idea what the DX call looks like.


Shouldn't that be glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)?
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Yann L
Yann L
Quote:
Original post by superpig
Quote:
Original post by Squirm
glBlendFunc(GL_ONE, GL_ONE);

but no idea what the DX call looks like.


Shouldn't that be glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)?

That's for standard order dependent transparency. Assuming Squirm's reply was to wxb1's inquiry about additive blending, then yes, it's glBlendFunc(GL_ONE, GL_ONE);
wxb1
wxb1
Ok so let me get this straight... just z-sort and additive blending... no poly splitting? much simplier than what I envisioned... but I'll take it!
mikeman
mikeman
Quote:
Original post by wxb1
Ok so let me get this straight... just z-sort and additive blending... no poly splitting? much simplier than what I envisioned... but I'll take it!


Additive blending doesn't need z-sorting,because it is...well,additive.
wxb1
wxb1
Ok...

I used this:

D3DBlendFunc (D3DBLEND_ONE , D3DBLEND_ONE );

And the transparent parts of the model lit up white, and the whole model was transparent...

Then I tried:

D3DBlendFunc (D3DBLEND_SRCALPHA , D3DBLEND_ONE );

And the transparent parts stayed transparent but the whole model was transparent...

I think I need to state that I'm trying to render a model like a tree which has leaves that have transparency. But the trunk of the tree should be solid! Now the tree is mapped with one texture as well...
OrangyTang
OrangyTang
For something like a tree additive blending will just look weird. You'll need to use (SRC_ALPHA, ONE_MINUS_SRC_ALPHA) with proper sorting to get correct results.

However for trees you can avoid using blending altogether. Use the alpha test instead and no blending. Since you get a binary pass/fail you can still use depth testing and don't need to sort anything. With a suitable test value (somewhere between 0.4 and 0.6 is usually good) you can get nice fake curved edges much like you would from blending.
wxb1
wxb1
Thanks OrangyTang! I'll give it a try...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.