View Full Version : Angles of layers
12-06-2001, 06:12 AM
I'm having a strange visibility problem in which portions of the image become more or less visible depending on the angle. The situation involves space-filling layers of cubes. The layers are adjacent with no space between them. These cubes have different colors and alphas, brighter being more opaque. When the edge of these layers is looked at from above ( visible cube edges in lower part of screen ) they have visibilities as I intend, but when viewed from below the transparency is much more than I intended and almost disappear. When the image is rotated the effects on the object reverse and the new parts below look good.
Has anybody seen this effect and solved the problem? What further information would you need to understand the problem?
12-06-2001, 06:17 AM
Most blending modes aren't commutative, i.e, you get different results depending on drawing order. If you're drawing transparent stuff, unless you use additive blending, you generally have to sort your primitives back to front. If the problem appears even when you switch off blending, you have probably run out if depth buffer precision, try pushing the near plane out and see if that helps.
12-06-2001, 06:45 AM
Thanks for the comments.
1) With alpha = 1.0 for all cubes the "look" is the same, top or bottom.
2) I took your suggestion of drawing from the back to the front and the effect was reversed. The top ( above my line of sight ) is now good and the bottom is very transparent ( same physical arrangement of cube layers as when drawing front to back ).
3) I forgot to mention in the original post that I am not using lighting or material properties.
Does the above suggest any solutions?
When harsman said you should render from back to front, he meant you should render from front to back as seen from the viewpoint. When looking form above, render the bottom layer first, then the top layer. When looking from below, render the top layer first, then the bottom layer. This is important, because blending A over B is not the same as blending B over A. You should measure the distance between the objects and the viewpoint, and draw the object with the largest distance first.
12-06-2001, 07:33 AM
I understand the point about the farthest first. Are there any shortcuts ( tricks ) since I am dealing with about 3 million cubes and the boss is already unhappy with the speed. He will eventually get me a faster board, but meanwhile I have to get everything I can out of the software and the sorting you are talking about sounds grindingly slow.
Transparency is not an easy task. If you want it, you must be ready to pay the price.
There's no way around the fact that you have to sort from back to front (OK, there's a paper over at NVIDIA, descibing order independent transpenency, might want to check it out by the way). If these cubes are static, i.e. don't move around, you might want to try building a BSP tree or something. It won't eliminate the problem, but will help you draw them in the correct order.
A faster board won't help here, cause the slow part is the actual sorting.
12-06-2001, 08:00 AM
Try using an additive blending mode so you don't have to sort the cubes. If you have to use a non commutative blending mode, remember that you only have to sort when the view changes a lot.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.