Two bits of a model overlapping when the shouldnt
Blitz3D Forums/Blitz3D Programming/Two bits of a model overlapping when the shouldnt
| ||
I have one model of a village in 3ds which i export to b3d. I have created a fence and long grass one behind the other. But the grass appears to be infront of the fence when it is geometricly placed behind it. How would i over come this? I have tried loading the grass seperatly and using entity order but that just puts the fence infront of the grass instead. I dont want either of these results. How do i get the grass shoing like it is infront and behind the fence without the fence screwing up? ![]() |
| ||
I have even noticed that the back grass overlaps the front grass. Eeeaaarrrr!! How do i stop this? |
| ||
Using masked textures instead of alpha'ed textures will probably do it. It's not ideal, I know, but any time you have multiple alphaed objects sharing screenspace, this seems to happen. |
| ||
So there is no way to ACTUALLY fix it? Thats a real bad bug. |
| ||
nope not really, I think beaker wrote a alpha sorting algorithm for sorting billboard sprites, but its not really suuitable for meshes like the fence. Sometimes you can get away with mixing alpha as the alpha for an entity is sorted by how close its pivot is to 0,0,0 so sometimes you can set up layers and move the entities local pivot further from 0 on Y so that it gets drawn behind whatever entity with alpha has its pivot closer to 0 Not much use for a lot of things, and certainly not in your case, but useful to know. (it's one of those things that realy holds blitz back, shame there can't be an optional alpha sorting flag you can set if you want certain things to get sorted). Your only real solution is to use a mask, a bit dirtier looking, however its pretty common even in commercial engines like Ghost recon etc to use 1bit masks. It's just a lot quicker to render than an 8bit greyscale, and often people are used to seeing it that they don't really notice. Actually I don't think I ever used an engine that could cope with more than 4 seperate overlapping arbitrary meshes with alpha properly unless they are billboard type sprites. |
| ||
Yes, because alpha stuff can not use the Z buffer it is depth sorted at the entity level. So if the origin of the grass is closer to the camera than the origin of the fence it will be drawn after the fence and if it is further away it will be drawn before the fence. The fix is to use masked textures as already suggested unless you want major headaches. Here is a quick example that demonstrates how alpha objects are sorted and how using masking instead resolves the issue. Note how I avoid a dirty mask caused by bilinear filtering by setting the mask color to a color close to the unmasked color. Masking usually only masks out black on loaded textures, but you could get around that by loading as alpha then copying to masked, bearing in mind that any pixel with an alpha value less than 129 will be masked out. |
| ||
BTW Alpha sorting issues are NOT Blitz3D bug or anything; it's just how HW/DX does it. Would be nice to have "automatic" z-sorting but it would be slow and quite case spesific... so don't ask Mark to "fix this" because he can't. Use masked textures instead. |
| ||
I thought 'EntityOrder' solved problems like this: http://www.blitzbasic.com/b3ddocs/command.php?name=EntityOrder&ref=3d_a-z EDIT* Oh! I see you've tried that... Regards, Rogue Vector |
| ||
My Z sorter would be ideal here as long as you combined the fence and grass textures into one. OR you could mask the fence and z-sort the grass. |
| ||
Beaker, how do i get your Z sorter? Is it in the source archives? |