Alpha vertex terrain stuff

Blitz3D Forums/Blitz3D Programming/Alpha vertex terrain stuff

Rob Farley(Posted 2006) [#1]
Ok... Loads of people have done this and I'm unsure of the general technique behind this...

You know like of ALE and FLE.

If someone could let me know the general principles of how to do this I'd appreciate it.


Beaker(Posted 2006) [#2]
I think essentially you lay out a mesh terrain for each texture (all with the same positions etc) and then only add tiles for each mesh where you can see that texture (or a blend of 2 or more of the textures). Wherever you want a terrain 'tile' to blend between 2 (or 3 or 4) textures you double up the mesh at that point and use vertex alpha on one (or both) of them.

Not too complicated.


Matty(Posted 2006) [#3]
I've found that I get horrible z-sorting issues if I layer more than 2 meshes using vertex alpha. The textures on the layers flicker in and out of view, alternating between the two or more textures. However I am probably doing something wrong because it looks like plenty of other people have done it successfully.


OJay(Posted 2006) [#4]
create base meshterrain without transistions, but with textures applied to each vertex. then create additional surfaces foreach transition and blend these ones with vertexalpha. that way you dont get any z-order issues, because no alpha-triangles are above each other.


RGR(Posted 2006) [#5]
@OJay
What does that mean? create base meshterrain without transistions (how?)

And how do I apply Textures to a vertex?

Then you write create surfaces for each transition ... How, if you first mentioned to create without transition ?

Your explanation is quite confusing.

BTW: I had it working with full meshes - changed to "optimized" meshes which had only the painted triangles and then had the same trouble as Matty and never managed to get an optimized working version.
Am very much interested to see examples to figure out what went wrong after my optimizations which obviously should work, as in ALE is to be seen.


OJay(Posted 2006) [#6]
ok, i will try explain it with a high-detail professional concept art:



there we want to have a terrain with grass and a small isle of sand in the middle. between these two textures we want some real smooth vertexalpha-transitions, bro.

see the two mentioned steps?

1. create a mesh with 2 surfaces. one for the gras, one for the sand. the grey lines indicating the quads (each consisting of 2 triangles). the red line indicates the surface border.

2. create a new mesh with one surface and apply the sand-texture to it. you can move this mesh up by, say, 0.0001 unit to avoid some flickering on larger distances on some graphicscards (especially ati ones ;)). create the vertices along the orange quads and create triangles between the red and blue line. then comes the magic: apply vertexalpha of 0.0 to all vertices on the red line, 1.0 to all on the blue line.

that way, you should get something like that: http://eqil.de/hfe/screens/editor/frk_plates.JPG


Matty(Posted 2006) [#7]
Ahh thanks, that makes perfect sense.


RGR(Posted 2006) [#8]
I had 1 Mesh with 8 textured surfaces that partly overlapped and vertexalpha was anything between 0.0 and 1.0 depending how intensive the mixture of textures should be.
Thank you OJay - I will give your method a try.


Mr Snidesmin(Posted 2008) [#9]
Sorry to bring this old post up, but I need help on the same topic...

Suppose you have more than 2 types of tile and they are all next to each other for example:


green = grass
yellow = sand
red = rock

How would you decide which tiles should blend and which verts should have what alpha and which textures need to be used for blending?

I know that one work around I can use is to have a base tile type (eg grass) and then keep all other tile types at least 1 tile apart (with grass in between) but it would be cool if there was a way to universally blend any combination...


Dreamora(Posted 2008) [#10]
there is no "universal always right logic"
you must decide on how to do it, give each of the possible constellations a code and select the code to decide on how to blend it together ...

that or do it manually on a blend map this means a texture on which each of the 4 color channels defines the alpha value of the given vertex.


puki(Posted 2008) [#11]
I just make sure FX 32 is not on the base texture and just shunt it with a vertex blend.

I also do my terrains in pure code - pure code.





My real-time, code-based, terrain engine is considered to be one of the best in the world.


Ross C(Posted 2008) [#12]
Looks pretty good puki :o)


puki(Posted 2008) [#13]
pretty good


?

'Best in the world' is what you meant to say.

That's not some "Andy Pandy" application-generated terrain, it's real-time and produced purely from code.


Ross C(Posted 2008) [#14]
Yep, pretty good stuff ;o)


puki(Posted 2008) [#15]
Oh, the other thing with regard to this is I don't load textures with the Alpha flag. I think doing so made it all bent. I just do the Alpha via EntityFX - but not the base layer - I find stacking layers is fine if the base layer is okey-dokey.


Wings(Posted 2008) [#16]
I failed with the EntityFX cause it disrupted the Z buffer.

I am living hapy with BrushFX 32 instead. (Undocument flag)

have you sen somthing simular Puki ?


Here is anyway a working example.. using brush fx32. and one mesh with several surfaces. ehh the world is still built of 10x10x64size meshes with 8 surfaces.



Wings(Posted 2008) [#17]
Ammf.

i got the zorder problem again.. but this time it is the sorting alphas from other meshes.


MikhailV(Posted 2008) [#18]
Exists one more good variant, without alpha-sorting (zorder) problem!
Download FastExtension library from http://fastlibs.com/download.php?id=fastextension_1_11_trial.zip and see example - FastExt_Example_TextureBlends.bb.
You can flexible mix several (2 or more) textures with separate alpha-channel without any problems!


puki(Posted 2008) [#19]
Blending is a method, not an eventuality - this equates to alpha is irrelvent.

You can reapply what you already applied.

2, 3, 4, 5, 6, 7, 8 can become 1 - 1 is a single - a single is an eighth of what is a maximum.


Wings(Posted 2008) [#20]
checking this out :D


Wings(Posted 2008) [#21]
Here is a link and source of a alpha terrain demo
http://www.tiberion.com/furysalphademo.zip

thoe it has problem with zbuffer alpha.


Can anyone fix this ?


Wings(Posted 2008) [#22]
Here

i fixed the whater with a workaround.. simple dont use alpha at sea flor.. it probably works also on land.






I have updated the old FuryVertexAlpha world demo also.
http://www.tiberion.com/furysalphademo.zip


Wings(Posted 2008) [#23]
finial build..

Added a lake into middle of the island.. No it is not sea. this lake is higher up than the sea plane is. so we may have as many lake as we wish. just dont forgett to puc none alpha layer at bottom of lake.. aka mudd in this case.



source + files.
http://www.tiberion.com/furysalphademo.zip

edit: I added an optimized build also. it will not create verices that is not needed. so optimized build is intended for the gameplay. the unoptimized is for a editor.

edit2: updated pic now show optimized verions.. here is some statistics.

Unoptimized version.
Total 793800
Triangle Rendered: 285784
FPS: 42



Optimized
Total 136479
Triangle Rendered 132391
FPS: 59


_33(Posted 2008) [#24]
Thanks alot for the source, will investigate


puki(Posted 2008) [#25]
My source is better.


Wings(Posted 2008) [#26]
Puki where is your source ?


puki(Posted 2008) [#27]
Considering my engine is probably the best in the world, the source code is somewhat valuable.

See previous quote:
My real-time, code-based, terrain engine is considered to be one of the best in the world.



Wings(Posted 2008) [#28]
Ahh :D

verry well then puki.

iam continuing with b3d lol gfx