View previous topic :: View next topic |
Author |
Message |
Mr Rob Member
Joined: 30 Oct 2009 Posts: 20
|
Posted: Mon Nov 02, 2009 12:09 am Post subject: DeleD/Blitz3D question |
|
|
I'm using DeleD PRO in conjunction with Blitz3D and seem to have a problem, being a new user it might just be me rather than a program bug.
I make two cubes in DeleD, spaced a little apart, texture them with a DeleD tga transparent material (I've tried both tga and png), and set the material to Alphablend. Everything ok at this stage. I export it into a Blitz3D programme and move around the cubes looking at them. As you look through the nearest transparent cube the one that should be in the background appears in front. it's as if it's being drawn last like a sprite would be. It only seems to affect one cube though, and if you look through the transparent object with a solid object in the background everything appears normal, the solid object doesn't appear in front. I've tried different objects, different scenes and blitz3D programmes and get this problem all the time. I'm putting bushes and hedges in a garden so need to see between the leaves. |
|
Back to top |
|
|
Mr.Fletcher DeleD PRO user
Joined: 07 Aug 2004 Posts: 1772 Location: Germany
|
Posted: Mon Nov 02, 2009 9:29 am Post subject: |
|
|
Without knowing B3D at all:
That's a common problem with OpenGL applications, it has something to do with the z-Buffer and the order in which the objects are rendered afair. Try sorting transparent objects by depth distance to the view point and rendering it beginning with the farest one. Might be a bit expensive though, if you have many such sprites in your scene. _________________ Behold! The DeleD Wiki! Please help us expanding it
DeleD on IRC |
|
Back to top |
|
|
Starnick DeleD PRO user
Joined: 28 Jul 2007 Posts: 611
|
Posted: Mon Nov 02, 2009 10:00 am Post subject: |
|
|
Well it's not just openGL either, and it's a big thing with engines - sorting that is (you can also sort based on materials used to reduce state changes, but that's more to gain performance vs addressing visual glitches).
Fletcher's correct in that it's because of the depth buffer. Imagine you have two boxes, A and B and are semi-transparent. A is behind B in the world. If you render B before A, the pixels that B occupies will be filled in the depth buffer, so when you go to render A, those pixels don't get modified. For opaque objects, it's alright, but you're supposed to see through box B and see box A. So that's where the whole back-to-front order of rendering, and sorting based on depth comes into play.
I'm not familiar with Blitz3D so I don't know if there is any built in support (if it's anything like XNA where it's more of a framework than an engine, you probably have to do this yourself). |
|
Back to top |
|
|
Mr.Fletcher DeleD PRO user
Joined: 07 Aug 2004 Posts: 1772 Location: Germany
|
Posted: Mon Nov 02, 2009 12:01 pm Post subject: |
|
|
Starnick wrote: |
Imagine you have two boxes, A and B and are semi-transparent. A is behind B in the world. If you render B before A, the pixels that B occupies will be filled in the depth buffer, so when you go to render A, those pixels don't get modified. |
That was my first thought too, but his problem seems reversed, it's not that A is not rendered at all but that A overwrites B completely, so I expressed it a bit more generic. Perhaps B2D disables writing to the depth buffer for transparent objects or whatever. _________________ Behold! The DeleD Wiki! Please help us expanding it
DeleD on IRC |
|
Back to top |
|
|
Nocturn DeleD PRO user
Joined: 08 Aug 2004 Posts: 635
|
Posted: Mon Nov 02, 2009 12:34 pm Post subject: |
|
|
I didn't use Blitz since years but did you check if you have the WBuffer set on true ? |
|
Back to top |
|
|
Mr Rob Member
Joined: 30 Oct 2009 Posts: 20
|
Posted: Tue Nov 03, 2009 3:57 am Post subject: |
|
|
Thanks for the info. Tried changing W buffer settings in Blitz3D but didn't make any difference, I'm using the latest ATI Radeon 4770 card, do better graphics cards sort the distant and near pixels any better or more accurate than cheaper cards.
From what everyone's saying am I right in thinking this is more of a game engine problem than a graphics card problem ?
Anyone using a different game programme to Blitz3D who doesn't get this problem ?
I'm texturing 3d objects not 2d sprites if it makes any difference by the way. |
|
Back to top |
|
|
Starnick DeleD PRO user
Joined: 28 Jul 2007 Posts: 611
|
Posted: Tue Nov 03, 2009 6:32 am Post subject: |
|
|
Mr Rob wrote: |
Thanks for the info. Tried changing W buffer settings in Blitz3D but didn't make any difference, I'm using the latest ATI Radeon 4770 card, do better graphics cards sort the distant and near pixels any better or more accurate than cheaper cards.
From what everyone's saying am I right in thinking this is more of a game engine problem than a graphics card problem ?
Anyone using a different game programme to Blitz3D who doesn't get this problem ?
I'm texturing 3d objects not 2d sprites if it makes any difference by the way. |
Graphics cards don't provide that sort of sorting for you (when you write to the depth buffer, it just compares values in there, which is why back-to-front sorting is an important concept). Sorting is a CPU operation, so it doesn't really matter what gpu you have. Though I suppose you could do such sorting using general GPU computing (like CUDA)...but that's kinda way beyond the scope of this discussion.
As for the sorting, you can do a sort by comparing each object's distance to the camera with one another.
I can point to some source from jMonkey's RenderQueue:
http://code.google.com/p/jmonkeyengine/source/browse/trunk/src/com/jme/renderer/RenderQueue.java
Points of interest would be the renderTransparentBucket() method. Not sure how helpful it'll be since sometimes dumping someone into unknown code isn't good...but it's something another engine does. Honestly, this is something that should be pretty automatic/general and integrated into your rendering process, so while it's a small idea, its implementation may be a part of a rather complex operation. I don't know Blitz3D, so I don't know what it offers, or what is up to the programmer to develop. |
|
Back to top |
|
|
Mr Rob Member
Joined: 30 Oct 2009 Posts: 20
|
Posted: Wed Nov 04, 2009 7:36 am Post subject: |
|
|
With a bare DeleD scene loaded into Blitz3d I made 3 blitz cubes and textured them with transparent textures together with alpha flag 2: works perfect, so Blitz seems to be able to sort it's own transparent textures in the right order. It would be a lot easier though if it could all be done in DeleD as you're building your scene. I wonder if the DeleD can be fixed ? |
|
Back to top |
|
|
Nocturn DeleD PRO user
Joined: 08 Aug 2004 Posts: 635
|
Posted: Wed Nov 04, 2009 9:07 am Post subject: |
|
|
This has nothing to do with DeleD at all - you should really check if you're using the right WBuffer or ZBuffer technique in Blitz3D. Unless ofcourse something is wrong with your meshes or b3d file, but i doubt that. |
|
Back to top |
|
|
Mr.Fletcher DeleD PRO user
Joined: 07 Aug 2004 Posts: 1772 Location: Germany
|
Posted: Wed Nov 04, 2009 9:40 am Post subject: |
|
|
The order of objects you should render them is view point dependent, so there's no way DeleD could consider this.
Quote: |
I made 3 blitz cubes and textured them with transparent textures together with alpha flag 2: works perfect, so Blitz seems to be able to sort it's own transparent textures in the right order |
My speculation: Perhaps, if the transparency of a texel is either 1 or 0, the z-buffer is only written to if it's a 1 (if the texel is visible), so that works there. I really dont know though if it really behaves that way. _________________ Behold! The DeleD Wiki! Please help us expanding it
DeleD on IRC |
|
Back to top |
|
|
Mr Rob Member
Joined: 30 Oct 2009 Posts: 20
|
Posted: Wed Nov 04, 2009 11:32 pm Post subject: |
|
|
Quote: |
This has nothing to do with DeleD at all - you should really check if you're using the right WBuffer or ZBuffer technique in Blitz3D. Unless ofcourse something is wrong with your meshes or b3d file, but i doubt that.
Thanks Nocturn, my knowledge of buffering is limited to either enabling or dissabling the W buffer in Blitz. I think I'm using 32 bit colors, it's on another comp. so I'll check later. Would this make any difference ? |
|
|
Back to top |
|
|
|