0

I work with SceneKit and I have a problem: When I make two cubes, one inside the other, one of which has a semi-transparent texture, the cube inside is not drawn.

How it should be(scene created in XCode)

How actually is(I made a few pixels with alpha 0 to understand what needs to be seen)

Edit: I found a problem related to the blender but which is very similar to mine Link

  • can you show us your code for the scene setup and the cubes? – ZAY Dec 25 '20 at 12:22
  • @ZAY boxes with texture are created from custom geometry 'SCNGeometry *geometry = [SCNGeometry geometryWithSources:@[vertexSource, normalSource, uvSource] elements:@[indicesElement]];' the red lines on the edges of the cube are standard box with modified shader for drawing only at the edges Scene configuration '_sceneView.scene = scene; _sceneView.antialiasingMode = SCNAntialiasingModeNone; _sceneView.autoenablesDefaultLighting = YES; _sceneView.allowsCameraControl = YES; _sceneView.contentMode = UIViewContentModeScaleAspectFit;' – Freename Freefam Dec 28 '20 at 10:49
  • it could be the shader program (SCNProgram) you use, because it will replace all the shading that comes with scenekit. If you want something as you did in your first example image, you should be able to do so with the standard shaders from scenekit. Try to create different materials for the two cubes, adjust their lighting models and give the outer cube a transparency of 0.3 or 0.4 – ZAY Dec 29 '20 at 08:44
  • I finally found the cause. It all depends on the order in which the cubes are added. if the small one is added first, everything will work, if the big one - the small one will not be seen. The biggest problem is that the application is a 3D editor, and the order of the elements is set by the user. I will try to find a solution. – Freename Freefam Dec 29 '20 at 13:14

1 Answers1

0

For those who will encounter the same problem as me: it has been solved but not completely.

The solution consists in the calculation at render order depending on the size in geometry. The result is not stable, but better than nothing.

cubeDict[@"render_order"] = @((sizeX + inflateDouble) + (sizeY + inflateDouble) + (sizeZ + inflateDouble));