TextureFlag 2, alpha problems!

Blitz3D Forums/Blitz3D Programming/TextureFlag 2, alpha problems!

Jeroen(Posted 2004) [#1]
Hi!

I'm having troubles with entities that use an alpha channel: I can see leaves of trees that suppose to be behind other trees, being rendered in FRONT. What is going wrong? :-(



The crystal should be behind the tree, not in front.


The trees on the right are transparant, when the sea is behind them.


Thanks


Paul "Taiphoz"(Posted 2004) [#2]
Try looking into entityorder I think it is.. to set when you want something drawn to screen.

Hope this helps.


Jeroen(Posted 2004) [#3]
No it hasn't to do anything with entityOrder....only the alpha textures give the problem, the mesh in its whole is drawn correctly as you can see on the screenshots.


Tangent(Posted 2004) [#4]
I'm new to b3d, but I've encountered this in other packages.
It's the sorting. Your alpha maps are showing in front of everything else... Is there some control on the sorting?


Jeroen(Posted 2004) [#5]
that's my question as well :)


Tangent(Posted 2004) [#6]
Sorry, there's a piece of code dealing with sorting in the code section.. perhaps that would help?


Stevie G(Posted 2004) [#7]
Have you tried 'entityfx 34' (vertexalpha + vertex color) - not sure if that would work with 'entityalpha' but if you use vertexcolors I'm sure alpha always screwed up?

I don't think entitorder will help as this apparently disables the z-buffer altogether for that entity.


fredborg(Posted 2004) [#8]
Alternatively you could use masking instead of alpha, it doesn't have the same problem.

Another solution is to sort your polygons manually. MasterBeaker has made some great functions for this, which you can scoop out of the code archives.


Genexi2(Posted 2004) [#9]
This might help :
http://www.blitzbasic.com/codearcs/codearcs.php?code=850

Anyway, I have to say, thats a damn mighty fine lookin' project you goin' there, you make the graphics yerself?


Jeroen(Posted 2004) [#10]
It seems Blitz does not z-order alpha textures, which is IMHO really, really bad. The code Genexi2 suggested seems to do the job, but unfortunately I haven't got any results yet (nothing happens :-)


Mustang(Posted 2004) [#11]
It seems Blitz does not z-order alpha textures, which is IMHO really, really bad.


It's not really Blitz's fault, but rather HW and DX related "problem". Most 3D-engines (even games) have the same problem and because of the nature of alpha, there is no automatic way to z-order it. Only way to do this is to sort every polygon "manually" in every frame, and that is VERY cpu-time consuming. I doubt that DarkBasic for example is any better in this matter.


Al Mackey(Posted 2004) [#12]
Indeed.. For textures with an 8-bit alpha channel, any part of the poly with that texture might end up being partially transparent. Transpareny doesn't jive with the Z-buffer, so polygon ordering needs to be done. B3D will order these polys by their entitys' origins, so you can only get your Alpha leaves to be properly transparent if each of them is a separate entity with an origin near its middle.

There is another option...

Try using the "Masked" flag (4) instead of the "Alpha" flag (2). Masked is a binary alpha channel; Any part of the image that is true black won't be rendered, and anything else will be fully opaque. The texture will never need to have partial transparency, so while it may have some jaggies, it can use the Z-buffer just like a normal surface -- you con't have to do anything to get your polys in order.


Al Mackey(Posted 2004) [#13]
Here's an example of the Masked flag from something I'm working on.. Here's a tree that uses it seen from quite a long way away:


And here's a close-up of a branch, where you can see the jaggies I was talking about:



Genexi2(Posted 2004) [#14]
> where you can see the jaggies I was talking about:

There any way around that by any chance? Just in other games I've played like FFXI, there are no jaggy outlines, but the pixels themselves just keep gettin smooth\rounder\blurrier up close, kinda like vector art in Flash. :-/


jhocking(Posted 2004) [#15]
Anthony Flack had come up with a clever masking solution for "Cletus." I don't recall the post/URL but he might pipe up here, or just email him.