Terrain with vertexalpha Zshort problem

Blitz3D Forums/Blitz3D Programming/Terrain with vertexalpha Zshort problem

Pinete(Posted 2007) [#1]
Hi,
I would like to know if there exist some way to avoid
the problem of alpha sorting of the layers of a terrain
that uses vertex alpha...
Maybe the way in which the terrain is exported or maybe something to do when paint onto it... I don't know...

Please, someone have idea about how to deal with this?

Thanks in advance!


jfk EO-11110(Posted 2007) [#2]
Personally I solved this by using two meshes, 1 is the underlying bottom layer (without holes), 2nd has all other layers, tho not sure if they will z-fight eachother noless. Basicly, as soon as some alpha tris are part of the same mesh, there will be z-problems. Then again I rarely have lots of layers in the seconds mesh.

Of course, saveing the terrain as two meshes requires to have access to the sourcecode (eg. to the fle code as seen in the toolbox)


Pinete(Posted 2007) [#3]
Hi jfk,
thank you very much.
I am working with the source code of FLE, the problem is when i'm painting over the layers and put some grass, then an incredible z order problem appears.

What I've not tried is save the map as two meshed as you said and FLE does, and after that, put some grass.

Do you know what should I hope doing this way?

Could be possible to have only the z order problem during painting process because the terrain is composed by various layers?

Thanks in advance jfk!

regards!


jfk EO-11110(Posted 2007) [#4]
Basicly I'd say, don't use alpha for grass, but mask mode (big textures, eg 512*512). while alpha basicly looks nice, it opens a pandora box of troubles, also speed issues (due to sorting hacks etc.). Well masked grass may look good as well. Make sure to load the grass texture by code, then neutralize the masked parts RGB color (initially this is black, that's why it will fade the contours to black. Check out the "Optimize Mask" example from the archives)

This is an example of masked grass on FLE terrain:
http://www.blitzbasic.com/gallery/view_pic.php?id=1362&gallery=&page=8


Pinete(Posted 2007) [#5]
Thanks jfk,
but there exist still another issue... and its related to the alpha too...
Talking about the stuff you can place over an alpha terrain not only appears the grass... but the particle effects of, in example, magic effects, fires, cannon explosions or a lot of possible effects that this time should require alpha blending.
do you have any idea about how to solve this? maybe in terms of concept because at the technical side it seems to haven't a good approaching...

Thanks!


jfk EO-11110(Posted 2007) [#6]
While some of these things could use the additional blendmode instead (eg. particles) I do agree, sometimes you'll have to use alpha, eg. for glass.

The whole alpha issue sometimes still confuses me.

Alpha is bad for solid things, eg. a window frame with glass. From one side it will look ok, but from the other side it will look as if the mesh was flipped insideout.

So you may use multiple alpha objects, but they may not be part of the same mesh. Neverless, it seems it's not always working this way.

The golden rule seems to be: make sure there ain't multiple alpha meshes overlapping onscreen.

Somebody said you can fix this when you add a masked texture layer to the alphatextured mesh. Not sure of that, may also be a performence hit. A further idea is to add a copy of it, slightly offset, textured with a masked texture that is actually completely transparent (fully black)

I do however try to use only one alpha object at a time, eg: there's a wall facing the window, not a second window. It's possible to use only a few alpha and do most of it with additional blending and masked textures instead, I've seen this is eg. in Splinter Cell.

Finally, you may also try to use something like Beakers Z-Sorting workaround, seen in the archives. Although this will also slow things down.


Pinete(Posted 2007) [#7]
WOW!
thanks a lot for your extensive and quick response! and of course for all the ideas you give me.
I will try the masked layers and will research over that way...
Thanks a lot again..
I'm not a megablitzer like you, but I promise if you've a problem i will try to help!

best regards!


jfk EO-11110(Posted 2007) [#8]
NP, glad to help. I'm no megablitzer - sounds like some kind of dino, no? :o) . I surely will need help from time to time, thanks.