-
Notifications
You must be signed in to change notification settings - Fork 100
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
Transparency issue with lots of spheres #101
Comments
Updated the example app so that the render now happens on MouseDown. This makes it much easier to see the problem by repeatedly clicking. Still can't fathom what is going on here. Any ideas where to start looking? |
Opengl transparency is faked in many ways, and doesn't always work correctly when many objects are involved. To really have it work correctly in all cases, you need to each transparent sphere in its own render pass.... |
Thanks. I didn't think I'd ever get a reply to this one! I realise that for transparency to work, that the transparent outer sphere needs to be rendered after the solid inner one. I had assumed that Three would do the necessary back-to-front sorting to achieve this. However, after your reply I have dug a bit deeper into the issue and found this SO question: http://stackoverflow.com/questions/15994944/transparent-objects-in-threejs It seems that Three does do the sorting but only per object rather than per vertex. So, as the two spheres have the same centre point, I think it is pot luck which ends up being rendered first. This does seem to account for the flicking between transparent and opaque that I was getting. I tried setting depthWrite to false, as per one of the suggestions on SO, and this does seem to improve things. You can now always see the inner sphere, although it is still pot luck whether or not the inner sphere is rendered first. I think a more reliable solution may be to move the outer sphere slightly closer to the camera, although this would have to be done for every camera movement, so may not be very efficient. Two render passes, as you suggested, could also work, although I'm not sure how easy this is to do with Three. |
You will need to render all opaque objects first, then in a second pass all
|
Hmmm.... according to this, Three should already be rendering in two passes:
I would have thought that this would mean it would work for my case since the opaque spheres would always be rendered before the transparent ones. |
Have you checked the ThreeDart code that its working in a similar manner? On Tue, Feb 10, 2015 at 9:24 AM, markhats [email protected] wrote:
|
It does appear to be. From the render method in WebGLRenderer.dart:
Maybe there is a bug in there somewhere though. |
Ran into a strange issue today. Bascially I am trying to draw lots of small spheres that are surrounded by a slightly larger partially transparent sphere. See below image:
This seems to work OK for a small number of spheres (< 17 on my machine). However, if the number of spheres is increased, I seem to get issues with the transparent spheres. They seem to either not be transparent at all or they flick between having transparency and not on each frame.
I have put together a small example at:
https://github.com/markhats/three.dart_examples/tree/master/examples/webgl_transparency
At it is at the moment, you can see the transparency flickering on some of the spheres. If you change NUM_SPHERES (line 6) from 50 to say 10, the flickering disappears.
The text was updated successfully, but these errors were encountered: