08-27-2011, 11:35 AM,
|
|
joevenzon
Administrator
|
Posts: 2,679
Threads: 52
Joined: Jun 2005
|
|
This is a pretty good explanation of what's going on:
http://www.sjbaker.org/steve/omniv/alpha_sorting.html
VDrift already draws all opaque objects before translucent ones (A First Quick Fix). If you turn off the transparent blended flag, then VDrift will use alpha testing (Another Good Trick), and each pixel of the texture will be judged either fully opaque or fully transparent. That adds hard edges to the texture, but it allows the zbuffer to work properly, where each pixel gets a depth value and on subsequent draws, pixels will only be drawn over the existing color if the depth is closer. Otherwise (with transparent blended flag on), if some pixel is partially translucent, we don't know what value to put in the zbuffer. If we put a value in there, we get problems like you originally saw when you started the thread: if (due to draw order) you draw a skid mark first (and write to the z buffer), and it's closer than the starting grid, then when the starting grid gets drawn, it's further away than the value in the zbuffer from the skid, so doesn't get drawn. If we don't put a value in the z buffer for transparent blended flagged objects (Disabling Z-write for Translucent Polygons), which is the fix in R885, then the depth of the translucent objects isn't considered relative to each other (only relative to opaque objects), and you get situations like you mentioned where the draw order controls layering. VDrift doesn't do the "depth sorting" step from the link because it can be slow and also gives inconsistent results. I think the best way to do it is to have it like it is now, where z writes are off and the layering is controlled by ordering. Or, if you can accept the artifacts of turning off transparent blended for even one of the two objects, that would fix it too.
|
|
08-29-2011, 10:15 AM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
joevenzon Wrote:So maybe sort at load by the y (height) coordinate of the object's bounding box center? that's what i was thinking. i wonder if it will cause problems with the horizon as it is also a transparent blended texture drawn onto the sky?
--alex--
|
|
|