SceneKit透明节点,透明材质

时间:2017-06-26 13:53:05

标签: ios scenekit

我尝试创建两个节点,一个透明,一个正常。那里有相同的位置节点。 代码如下

//UIBezierPath *aPath = ....
// add transparent node
SCNMaterial *transparentMaterial = [SCNMaterial material];
UIImage *checkImage = [UIImage imageNamed:@"tree.png"];
transparentMaterial.diffuse.contents = checkImage;

SCNShape *transparentGeometry = [SCNShape shapeWithPath:aPath extrusionDepth:0.000001];
transparentMaterial.transparency = 0.000001;
transparentGeometry.materials = @[transparentMaterial];
SCNNode *transparentNode = [SCNNode new];
transparentNode.geometry = transparentGeometry;
transparentNode.transform = SCNMatrix4MakeRotation(M_PI_2, 1, 0, 0);
[root addChildNode:transparentNode];

// addd node
SCNMaterial *materal = [SCNMaterial material];
UIImage *checkImage1 = [UIImage imageNamed:@"tree.png"];
materal.diffuse.contents = checkImage1;
SCNShape *geometry = [SCNShape shapeWithPath:aPath extrusionDepth:0.00001];
geometry.materials = @[materal];
SCNNode *node = [SCNNode new];
node.geometry = geometry;
node.transform = SCNMatrix4Rotate(SCNMatrix4MakeRotation(M_PI_2, 1, 0, 0), M_PI_2 , 0, 0, 1);
[root addChildNode:node];

问题是我可以通过透明节点查看可见节点。仅当可见节点具有图像内部具有Alpha通道的材质时才会出现问题(就像我的示例图像,它具有清晰的背景)。

enter image description here

它是SceneKit的错误?任何帮助将不胜感激!

这里是图像资源" tree.png" enter image description here

0 个答案:

没有答案