Depth buffer

Blitz3D Forums/Blitz3D Programming/Depth buffer

Warren(Posted 2003) [#1]
Is there a way to turn off the depth buffer? I want to draw a bunch of quads and the zbuffer is making my life difficult.

Basically, I want to add a bunch of quads to a surface and have them rendered on top of each other, as if I had used the DrawImage command multiple times. Problem is, the zbuffer is stepping in and making things look wrong.

Can I disable it?


fredborg(Posted 2003) [#2]
Have a look at CameraClsMode or EntityOrder. I believe setting entity order to the same for all quads, will kill zbuffer fighting, not sure though...

Fredborg


Warren(Posted 2003) [#3]
Thanks, but neither command seems to make any difference.

Basically, what I'm doing is that I'm adding 2 quads to a mesh. When they render, the first quad is on top of the second one. I'd like them to draw in the order that I add them.

I THINK the depth buffer is screwing me over, but I might be wrong.

Has anyone does this sort of thing before? Should I be creating a new mesh for every quad then? Seems wasteful ...


big10p(Posted 2003) [#4]
Creating a new mesh for each quad isn't going to make any difference, I don't think. I needed to achieve a similar thing to you recently for a special effect. I simply placed each layer/quad with a slightly different Z coord - something like 0.0001 difference between each layer.


sswift(Posted 2003) [#5]
EntityFX 32. That enables vertex alpha, which disables zbuffer writes, but still checks the zbuffer. This allows the polygons in your cube to draw in the order you specify, yet still sort with the rest of the scene properly.

Keep in mind that all transparent objects are rendered last, so any opaque object between the cube and the camera will cover it. But that's normal. Still, depending on what you're doing, this order could make a difference. Also note that since you're not updating the zbuffer, the cube won't affect the z values. So that might cause things to render differently than you expect as well in some cases.


sswift(Posted 2003) [#6]
Also, you can use Entityorder in some limited cases. Entityorder disables zbuffer writes AND checks. So this allows you only to place objects over all the other geometry in the scene. If entityorder didn't change the appearance of anyhting at all then I suspect you did something wrong.


Warren(Posted 2003) [#7]
Well, at the moment I've got a single mesh that I'm adding multiple surfaces into. I'm using the sprite camera set up from the "Sprite Control" library that's been mentioned on this site many times.

That camera set up seems to offer a very limited range of Z values so maybe that's the problem.

I tried EntityOrder, but since there's 1 mesh I guess it's really not going to do anything. I also tried bit 32 for EntityFX with no luck (and I know it took it because I CAN specify alpha values for the verts and it works).

I just don't understand what's going on. I guess I can try putting every quad on it's own mesh but that seems horribly wasteful.


sswift(Posted 2003) [#8]
Just for those that are following this thread to learn something...

Epicboy just told me he was using the 32 only on EntityFX but then painting surfaces with BrushFX.

I told him he was overriding the EntityFX when he painted the surfaces individually. Unless he specifies the 32 on the BrushFX he will turn it off and then the surface won't do the vertex alpha trick I outlined above.

EntityFX is like a short cut. It paints all surfaces at once. Though I don't know if this means that it can ovveride surfaces which have already been painted with a brush individually. But it does definitely affect any surfaces which haven't been painted with a brush yet. So EntityFX is kind of like a convenience function. But it would be better named as PaintSurfaces or something to imply what it is doing different from PaintSurface. The help documentation needs to be somewhat clearer in this respect.


jhocking(Posted 2003) [#9]
I don't know about its behavior with flag 32 but EntityFX seems to override brush properties for other stuff like vertex colors, and full bright.

That would have stumped me (I didn't know applying a brush overrides EntityFX) so it's good to know.


sswift(Posted 2003) [#10]
" EntityFX seems to override brush properties for other stuff like vertex colors, and full bright."

Yiou sure about that? I would like to see a tes demonstating that if you apply a brush to a surface after using entityfx that it does not oveeride any and all properties.


Warren(Posted 2003) [#11]
Anyway, to bring this to a close, I'm creating a new mesh for every texture change instead of just creating a new surface instead a common mesh.

Seems to fix the depth buffering crapola. I guess it's costing me some extra overhead, but for the game I'm trying to do that shouldn't matter much.