I am currently experimenting with the creation of a 3D editor. So far so good - except that I have a minor transparency problem. I haven’t been able to find a solution so far, so I am posting it here, hope it can ring any bells in any of the experienced developers here…
The problem is as following: to guide the user, I present 3 rectangles, each of them representing a basic plane (XY, XZ, YZ). Each rectangle consists of an outline and a transparent rectangle inside it. I disabled back face culling on these, enabled alpha and put them into the transparency queue bucket.
As you can see, the transparency does work… but not exactly as it should. Sometimes the transparency of the overlapping rectangles does not add up. I assume the problem is the drawing order of the rectangles.
Trying to split up each of the rectangles into 4 smaller rectangles to enable them to be ordered properly does not seem to fix the issue. Does anyone here have an idea how to get these ordered properly - preferably without having to write my own code to order the rectangles.
It should be noted that users will be able to add any number of planes to help them draw their model, so the method that is used should be scalable. It can be assumed that many planes will be overlapping.
With those uniformly colored rectangles, the order should be irrelevant, unless… since the lines around the rectangles are visible, I would guess that you set the stuff correctly, but just in case: What are depth write and ztest set to? Depth write should be turned off, ztest should be turned on.
Note that in the meantime I have added 3 green axis for further clarity.
I have also simplified my code such that it now uses only 1 rectangle - since cvlad made the intelligent note that the drawing order is irrelevant. (I hope, though, that it doesn’t interfere with future modifications).
Just a few notes in case it comes up in the future:
as full quads, no rendering order would have been correct. There is no back to front rendering order that would have worked because this is a textbook example of a case where sorting is fully ambiguous. No matter which quad you pick to render first there is always one behind it.
The reason splitting them didn’t work is because 0,0 was always in the same place. You created the meshes in the different locations instead of translating the geometries. So all of them were still at the same location with the same bounding volume.
Your solution of not writing depth is the probably the proper one because I assume you intend to render objects there later… and in that case you wouldn’t want them partly obscured by one of the planes if they are also transparent. If they use anything other than straight alpha blending then you will again run into sorting issues, though.