Render order inside transparent sphere

Hi everyone,

For my little project I am making dynamic skybox (moving sun, moon, etc), but I’m having some problems with rendering order…

For my skybox I’m using background sphere, quad with planet image, inner sphere and quad with sun image (check image).



http://i.imgur.com/cHjLf.png



By changing inner spheres alpha color I can change color of the sky and also cover up stars during day, problem is…



Because material is on the inside of the inner sphere, transparent render bucket is sorting objects in wrong order (pic 1).

I can fix this, by not adding inner sphere to transparent bucket (pic 2), but the problem is - planets aren’t rendered at all.

Again, I can fix that by removing planets from transparent bucket and setting alpha test to “true” (pic 3), but this way planets have little black space around them. I can live with that (it’s hard to notice with clouds).



My question is, is there a right way to fix my problems (maybe change skybox structure), or am I on the right track?

It is possible to specifically control the transparent bucket’s sorting order by setting your own comparator. That may end up being the only way to solve this issue.



Normally, it sorts by distance between the camera and the closest point on the geometry bounds. You could instead add some kind of layer number to the user data and use this to pre-sort your transparent objects… letting them sort normally if they don’t have this layer number.



See:

http://hub.jmonkeyengine.org/javadoc/com/jme3/renderer/queue/RenderQueue.html#setGeometryComparator(com.jme3.renderer.queue.RenderQueue.Bucket,%20com.jme3.renderer.queue.GeometryComparator)

1 Like

Ok, thanks for the answer, had the same idea, but didn’t know the right way to do it :slight_smile:

Fixed, works great :slight_smile: