Alpha problems

Blitz3D Forums/Blitz3D Programming/Alpha problems

Ross C(Posted 2008) [#1]
Hey there, i have a river, with a texture. The river mesh is alpha blended. Now, i have a fire with alpha particles coming out it. Now, when i stand looking at the fire, with the river behind it, the particles are appearing BEHIND the river.

Can this be sorted? They don't share the same surface or mesh.




Stevie G(Posted 2008) [#2]
To avoid this I always use additive blending on water.


Ross C(Posted 2008) [#3]
I tried using that, but it doesn't seem to help. Produces the same result.

EDIT - wait your right actually. Got that much stuff here... Thanks :o) I'll try that on my other alpha stuff.


Wings(Posted 2008) [#4]
You ned to sort the alpha triangles in the z buffer.

here is how you do it.

http://www.blitzbasic.com/codearcs/codearcs.php?code=850

Good luck.

If any one have any better idea please let uss know :D


D4NM4N(Posted 2008) [#5]
Try using <= than 0.48 alpha on the water. This seems to help filter it out.

To achieve the same level of translucency eg .6, use 3 water surfaces one slightly below the other (or blended) so they dont zfight but both at 1/3rd the alpha (.20). It seems anything =>0.50 will dominate if the flames are between the bit of water thats shown above and its (the water mesh's) axis. (alpha objects appear to be sorted by axis to some extent)

This is a little way of cheating it i noticed when i was doing a similar project.

Wings way looks better tho.


Ross C(Posted 2008) [#6]
I don't want a speed hit by sorting all my triangles :o) I'd rather just use the add blend mode. I did also try using 0.3 alpha transparency, but it still didn't look write. Thanks for the suggestions guys.


Dreamora(Posted 2008) [#7]
if you want to have that much alpha, choose by "sorting" or "getting funny errors"

Although, you seem to have serious amount of them.

Whats you camera setup?
I assume you are on 32Bit and your max range is no more than 3000 times as large as your min range (lower than that naturally is better)

Otherwise you are causing those whole mass of problems by degrading the zbuffer to joke buffer.

And make sure your drivers are current because they should handle such stuff up to a given level as well.


Ross C(Posted 2008) [#8]
Nah it's a sorting issue. Using the add blend mode has sorted the problem :o) Thanks!

I'm not using alot of alpha. I just have an alphaed mesh, and some particles.


D4NM4N(Posted 2008) [#9]
" I did also try using 0.3 alpha transparency, but it still didn't look write. "

Ah, but did you try using a second offset layer for the water at .3? .3+.3=0.6 :)


John Blackledge(Posted 2008) [#10]
Ross this has been reported many times. In my case it was a river 'punching through' foliage.

Also alphed tree segments aften punch through: back through front.


Ross C(Posted 2008) [#11]
What was your solution to that particular problem John?

I didn't try that no D4NM4N, i'm happy with the results of my river. Though, i'll bare that in mind if i come across more alpha problems that aren't sorted so easy :o)


Dreamora(Posted 2008) [#12]
One question: Do you use alpha meshes or alpha textures? Thats a difference and a not that small actually.


Ross C(Posted 2008) [#13]
Nope, it's the same. I get the exact same result whether i use alpha meshes, or textures i'm afraid.


John Blackledge(Posted 2008) [#14]
Ross - No solution, sorry.
Just one alphaed object now - the river.


Ross C(Posted 2008) [#15]
Try using the entityblend mode add for it. It seems to work well for me.


John Blackledge(Posted 2008) [#16]
Ross, can you give me an example of the entityblend that's working for you?


Naughty Alien(Posted 2008) [#17]
..have you try to load particles with mask flag and then do transparency?


Ross C(Posted 2008) [#18]
IU'm using entityblend entity,3 on my water, as stevie suggested above. It works alot better :o) You don't get the exact same results looks wise, but it does for my needs. My waterfall looks ok too.


Gabriel(Posted 2008) [#19]
For a river/foliage situation, you might try masking the foliage instead of alpha blending. I know that masking is not as nice as smooth alpha blended edges, but if you eliminate the blending, it should eliminate most of the draw-order problems without sorting. Manually offsetting the position of the entity which contains all the foliage surfaces ( and counter-offsetting the foliage within that entity so that they're in the same world position, obviously ) might help too.


IPete2(Posted 2008) [#20]
As reported above alpha sorting is the only real way to get this to work.

I guess you could try masking the fire particles instead of alphaing them. You will need to create a particle with a solid background black and no antialiasing for it to work properly, of course it won't have the translucency of alpha particles, sigh but that is the price I fear!

During my last epic development I had this issue and although it was reported fixed in the SDK I'm not so sure it was. Mark isn't able to fix it in B3d because I asked him, and it is not possible, so we have to work around it.

I wonder if there is a way to only render the particles on a second render pass? but I think they would then always be in front of every object.

IPete2.