Making SCNNodes transparent

I need to adjust the alpha on an SCNNode containing an SCNText geometry. It seems there are many ways to try to accomplish this, but all of them seem to make the node blacker rather than mre translucent. The background nodes don't show through. I've tried:


node.opacity = alpha

node.geometry?.materials.first?.diffuse.intensity = alpha

node.geometry?.materials.first?.transparency = alpha

node.geometry?.materials.first?.diffuse.contents = newColor // where the newColor was recreated with the appropriate alpha


They all seem to have similar affects. The node is invisible when alpha == 0, but if it has any value at all (say 0.001) then the text node shows up as black against the background.


Anyone know how to accomplish this?

Replies

what is the hierarchy? and are you accessing the correct geometry?


also what does your "alpha" mean? is it a value or a texture? if it is a texture does it actually contain alpha information or is it a black and white image? if it's a black and white image you need to set transparency mode to RGB Zero. what is the Blend Mode for the material?


diffuse does not change transparancy unless your blending mode is something other than alpha.


so many questions. would help a lot if you showed more of your setup.

It is a simple heirarchy. The nodes are added directly to the scene. Yes, I'm sure I'm accessing the correct geometry. The color changes, but goes to black rather than transparent (although alpha = 0 is transparent).


Alpha is a value in the range 0...1


I had not tried other blendModes, just using the default .alpha. I just ran through all the others a and they don't give me anything useful either. The text is either white or black.


Here is how I set up the SCNtextNode:


  let label = SCNText(string: title, extrusionDepth: 0);
  label.font = UIFont (name: "Arial", size: 128)
  let labelNode = SCNNode(geometry: label)

  let labelMaterial = SCNMaterial()
  labelMaterial.blendMode = .alpha
  labelMaterial.diffuse.contents = spiralArmLabelColor
  label.materials = [labelMaterial]

  labelNode.position = SCNVector3(x: Float(x * sceneScale),
  y: Float(y * sceneScale),
  z: Float(0 * sceneScale))

  let scale = defaultLabelScale * 1.2
  labelNode.scale = SCNVector3(scale, scale, scale)

  labelNode.pivot = SCNMatrix4MakeTranslation(0, 0, -100.0) // the -100 helps the label float above the galactic plane

  labelNode.constraints = [SCNBillboardConstraint()]

  scene.rootNode.addChildNode(labelNode)

I ams adjusting the alpha depending on the orientation of the view. I am making a view of the Galaxy and labelling the sprial arms. I want the labels to fade out when looking at the Galaxy nearly edge on.


Here is how I currently do it, but as I said in my original post, I've tried all the ways I can see to set the rtransparency and all of them have the same effect.


  for node in armLabelNodes
  {
       node.opacity = 1 - alpha2
  }


Thanks for your help

I should clarify that the changing the opacity is affecting the transparency. But rather than fading to transparent, it fades to a transparent black. The text looks like it is filled with black, but you can see things behind it. I want it to be invisible in that case.


You can see the effect here.


Notice the words "Orion Spur". You can see some background yellow dots behind the text, but I want the words to become invisible here, not black.