6

I'm trying out Scenekit and I'm running into an issue when I'm trying to render particles behind semi transparent objects. They simply don't render while other objects in the scene do.

enter image description here

On this pictures all particles are in front of the semi transparent box, all particles that are behind are not displayed. You can see that the sphere is properly displayed and the colors of the covered part are attenuated. I would expect the same from the particles but maybe the rendering choices of the framework to make particle systems efficient make this kind of behaviour normal ?

I've tried to google/stackoverflow it, but it seems that scenekit is not a very well covered topic.

Xav
  • 270
  • 3
  • 13
  • I don't know as much about scene kit, but I know in OpenGL draw order is very important for translucency. Can you control if you draw the particles before or after the box? You should draw opaque objects first. – Justin Meiners Oct 13 '15 at 16:12
  • that is a good hint... I have been looking for it but I think I overlooked... I can't change the particles rendering order but it seems that I can change the particle emitter rendering order... will try it out. – Xav Oct 13 '15 at 16:17
  • Just a quick google shows that you can control drawing order with the scene graph. "A parent draws its content before rendering its children." "Children are rendered in the order in which they appear in the child array." – Justin Meiners Oct 13 '15 at 16:19
  • that was it... I just needed to adjust the rendering order of the scnode parent of the particle system. thanks ! – Xav Oct 13 '15 at 16:30
  • Ill write up an answer. – Justin Meiners Oct 13 '15 at 16:30
  • nope I was wrong. Something is missing see post bellow the answer – Xav Oct 13 '15 at 17:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92170/discussion-between-xav-and-justin-meiners). – Xav Oct 13 '15 at 17:16

1 Answers1

5

Translucency depends heavily on draw order. With alpha blending the renderer reads the current values in the frame buffer, and mixes in the translucent color on top of those values.

What this means is that opaque objects should be drawn first and translucent objects should be drawn from back to front. If opaque objects are drawn after translucent objects the renderer has no current colors to mix with.

With SceneKit the draw order can be controlled by the renderingOrder property on the scene node.

The order the node’s content is drawn in relative to that of other nodes.

Apple Docs

Justin Meiners
  • 10,754
  • 6
  • 50
  • 92
  • 1
    this is true in SpriteKit (2D), but not in SceneKit (3D). The order in which nodes are rendered in SceneKit does not depend on their position in the scene graph. – mnuages Oct 13 '15 at 16:50
  • @mnuages ah thanks for the catch. I updated the answer. – Justin Meiners Oct 13 '15 at 16:51
  • 1
    Well actually now I'm having the opposite problem... The particles behind the box are properly attenuated, but particles in front of the box are also attenuated while they are not transparent ! – Xav Oct 13 '15 at 16:57
  • I had an issue with an opaque node object that is inside a semi transparent box object. without adjusting the rendering order to i.E 100 the object was drawn sometimes, and sometimes not at all. after setting the order to 100 the opaque object is always drawn - perfect answer. – ZAY May 10 '21 at 09:15