Alpha Channel Render Order

Blitz3D Forums/Blitz3D Beginners Area/Alpha Channel Render Order

Mikorians(Posted 2012) [#1]
[ALPHA TOPIC RESOLVED - See Update below]
I made my first .b3d file and it loads correctly with alpha maps displayed correctly, but when I move my camera behind the brass fences, I see themselves and the other fences right through them.

With pivots centered, the upper levels should be further away from the camera and rendered before the lower levels.
Do I have to do this ordering manually? This is why I made my exporter.

[Update] No I don't - my mistake? Loading the scene with LoadMesh and not LoadAnimMesh

Last edited 2012


RemiD(Posted 2012) [#2]
I have had the same problems.
2 ways to avoid this zordering problem :
Use the flag 4 "mask" when you load a texture (instead of the flag 2 "alpha")
or
Use EntityOrder(Mesh,x) and change the EntityOrder of each mesh with alpha depending on where the Camera is.


Yasha(Posted 2012) [#3]
This is a known limitation of Blitz3D, basically caused by its DirectX 7 engine.

DirectX 7 can't depth-sort polygons with alpha enabled, and won't try. So when Blitz3D throws an array of polygons (surface) to DirectX, instead of being depth-sorted, they're simply drawn from first to last in the order that they appeared in the surface. It would technically be possible to reorder the polygons within the surface, in software, but in practice this is usually far too expensive to work in realtime.

The absence of a depth test also means polygons are not properly sorted between objects; an alpha-enabled object drawn after another one will appear in front of it unless manually ordered to be drawn first. However, the order in which the whole objects are drawn is still sorted by distance - it's just that it measures the distance to the entity pivot, so if your entity pivot isn't perfectly centred it may not give the expected results.

Anyway, in this case it looks like the answer is to use masking, since you're not actually using semitransparent pixels: masking shouldn't count as enabling alpha since all relevant pixels are either present-or-not, and it can still use the normal "solid" depth sort mode for the pixels that are present.

You might find that DDS textures work better with masking than other image types (I have no idea, never used them but I recall a discussion a while back where they got rid of someone's black-edge artifacts).


Mikorians(Posted 2012) [#4]
Thank you. My old engine sorted alpha objects, so nothing new if I have to.
The Masking works on my fence example perfectly.
Thank you both very much!

I will now investigate DDS textures for translucent objects (haven't had a need until now - I have a tool though)

I keep hoping for a free ride :)

Do you know if folks will have an interest in my Max5 macroscripts for export here?

Last edited 2012


Mikorians(Posted 2012) [#5]
YA KNOW... It seems that I was loading my mesh with LoadMesh and not

************* LoadAnimMesh *************

It had nothing to do with pivots.
Now everything works magically...

Sigh.


Yasha(Posted 2012) [#6]
Yep, for future reference you do need to use LoadAnimMesh to preserve mesh hierarchy when loading.

If in doubt just use it for everything.


Mikorians(Posted 2012) [#7]
Ah. I've noted however, that I still can't load my very large scene...

And for reference-- Fragmotion doesn't import large b3d scenes very well probably for the same reasons that b3d doesn't. They're not wrong or bad. Just too big I think.

Here's my latest attempt to load this insanely large map.
Can anybody else get it to load -and stay in memory- ?

http://sites.google.com/site/mikorians/ArcGBldg.zip


Mikorians(Posted 2012) [#8]
You'll find that they do indeed load without trouble separately (not in fragmotion, of course).

** I don't want to keep pestering you guys about this - if you have no problem loading both together, I just wanna know so I can go buy a newer graphics card or something. ***

Last edited 2012


RemiD(Posted 2012) [#9]
Mikorians>>I have tried to run "loadb3d.bb" and there is an error :"parameter mus be greater than 0"

At this line :
If Instr("0123456789",Mid(a$,i,1))<>0 And Instr("0123456789",Mid(a$,i-1,1))<>0 Then

I don't understand what is your problem with large scenes ? You can probably export the scene in different parts and load them in Blitz3d separately.
It will be much better for an occlusion routine.


Mikorians(Posted 2012) [#10]
Sorry about the viewer app. It is meant to be compiled and used as a drag and drop. The same problem with loading occurs no matter how many pieces I break the scene up into.


Mikorians(Posted 2012) [#11]
Oh, and RemiD - thanks for the Mask suggestion.