SceneKit: Make child sphere visible inside semi-transparent parent sphere?

953 Views Asked by At

In SceneKit, say you want to embed a node, Child, inside a semi-transparent node, Parent, such that Parent acts like a "cage" you can see through and view Child.

Concretely, say Parent is a SCNSphere with radius 2. Child is a SCNSphere with radius 1 and is a child node of Parent.

Child is not visible since it's inside Parent. Setting Parent's opacity to 0.3 or something semi-transparent also affects Child's opacity lets you see Child but now Child is no longer fully opaque.

How can you make Child fully opaque yet still visible through Parent?

One option is to Child a standalone node, no longer a child of Parent, and instead manually compute the position needed to center Child "inside" Parent. But this requires moving Child manually every time Parent moves whereas when Child already is a child node of Parent, this movement happens automatically.

Is there a better approach?

1

There are 1 best solutions below

0
On BEST ANSWER

you can set the parent material transparency to 0.3 instead of changing the node opacity. This won't be inherited by child nodes.