Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opacity of overlapping structures #55

Closed
mizuchi3 opened this issue Nov 10, 2014 · 2 comments
Closed

Opacity of overlapping structures #55

mizuchi3 opened this issue Nov 10, 2014 · 2 comments

Comments

@mizuchi3
Copy link

Hi Marco,
I was playing with the new opacity settings, they will be really useful indeed. However I find that if I set the opacity of an overlapping structure to 0, the structures which lie behind the now transparent object are not visible

all visible
opacities set

@biasmv
Copy link
Owner

biasmv commented Nov 13, 2014

That's an inherent problem of the way opacity is implemented. When a transparent triangle gets rendered before something that is behind it, the triangle behind does not get rendered, because it fails the Z-test. To solve this with the current method, all the triangles would have to be sorted by projected Z-coordinates and that's relatively expensive in JavaScript. Another option is to implement per-object opacity as a post-processing pass.

I've added a small fix for the case where an the objects is completely transparent. That doesn't solve the visual artifacts when multiple objects are semi-transparent. To somewhat lessen the problems, we could order the objects such that the most opaque gets rendered first. When setting the opacity you could do the following(untested):

var alpha = 0.5;
obj.setOpacity(alpha);
obj.order(10 - alpha * 10);
viewer._objects.sort(function(lhs, rhs) { 
   return lhs.order() - rhs.order(); 
});

@mizuchi3
Copy link
Author

Thanks, that works well, and is better than the binary on/off switch we were using. I notice that if option outline is true, then for 0 opacity, the object is drawn black. If outline is false, then the object is not visible at opacity 0 as expected.

biasmv added a commit that referenced this issue Nov 13, 2014
This makes sure the outline fades out together with the rest
of the structure. Without this patch, the structure is rendered
in outline color (see #55).
@biasmv biasmv closed this as completed Nov 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants