scenekit

How to pass non-texture data to SCNTechnique Metal shaders

社会主义新天地 提交于 2019-12-11 07:32:56
问题 I can a pass custom parameter of type sampler2D to the Metal fragment function of an SCNTechnique and I have a working 2nd pass: PList: <key>inputs</key> <dict> <key>imageFromPass1</key> <string>COLOR</string> <key>myCustomImage</key> <string>myCustomImage_sym</string> </dict> ... <key>symbols</key> <dict> <key>myCustomImage_sym</key> <dict> <key>type</key> <string>sampler2D</string> </dict> </dict> Relevant Obj-C code: [technique setValue: UIImagePNGRepresentation(myCustomTexture) forKey:@

Update SCNPhysicsBody when scaling SCNNode

核能气质少年 提交于 2019-12-11 07:28:09
问题 I know that SCNPhysicsBody dont scale when the node scale, but I haven't found a great solution to fix this. I want to scale the node and then update the SCNPhysicsBody to node after scaling it. let box = SCNBox(width: 0.2, height: 0.3, length: 0.4, chamferRadius: 0.1) box.firstMaterial?.diffuse.contents = UIColor.blue var boxNode = SCNNode(geometry: box) boxNode.scale = SCNVector3(0.5, 0.5, 0.5) boxNode.position.x += 0.5 boxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.static,

Work inside colorGrading property?

只谈情不闲聊 提交于 2019-12-11 07:23:33
问题 Does anybody use colorGrading property of the SCNCamera to adjust rendered colors? The colorGrading's contents value must be a 3D color lookup table(LUT) or a 2D texture image the represents such a table arranged in a horzontal strip. So I try to download some 3D color lookup table file whic is .cube format and write some Metal code. But when I run it, I got the whole black scene. But when I move the camera, the black disappear but the colorGranding didn't work that way. So I want to use 2D

Low cost Image to NSData conversion for feeding SCNTechnique's sampler2D inputs

北城余情 提交于 2019-12-11 07:02:16
问题 Sometimes the only way to pass precious data from CPU to GPU is by hiding it in textures. I tried to trick SCNTechnique and simply pass [NSData dataWithBytes:length:] or a CGDataProviderRef containing my neatly prepared raw pixel data bytes, but SceneKit is smart enough to detect my sinister attempts. But I did not give up, and found a loophole: [_sceneView.technique setValue: UIImagePNGRepresentation(encodeInSinglePixelUIImage(pos.x, pos.y)) forKey:@"blob_pos_"]; Encoding and decoding single

ARKit – Rendering a 3D object under an invisible plane

孤人 提交于 2019-12-11 06:55:18
问题 I have an ARKit scene with an invisible SCNPlane : plane.geometry?.firstMaterial?.colorBufferWriteMask = [] This plane is placed on the ground and is used to render deferred shadows from other objects placed in the scene. I want to render another SCNPlane which should be on the same level as the invisible plane (same Z -coordinate). The problem is, that every time the new object is under the invisible plane, it is not rendered at all. Is there any way to render the object when it is under the

Big SCNGeometry SceneKit for iOS

拜拜、爱过 提交于 2019-12-11 05:43:04
问题 I am working on a cocoa/iOS projet. I have a common swift class which manage a Scenekit scene. I want to draw a big terrain (about 5000x5000 points). I have 2 triangles per 4 points. I have created a scngeometry object for the whole terrain (is it a good thing ?) I decided to store those points in a 6-Float structure (x,y,z and r,g,b). I tried to create an empty array or to allocate a big array at the begining : i got the same issue. I work with Int datatype for indices array. The project

Scenekit camera orbit around object

北城余情 提交于 2019-12-11 05:33:39
问题 Hello everyone, I come back to you about my current problem. I already asked a question about that but no one had success to help me. Then I will explain my complete problem and how I tried to fix it. (I tried several things) So, I need to code a lib that adds many functions in order to manage cameras and objects in a 3D world. For that we have chosen SceneKit Framework to use Metal. I will post a very simplified code but all necessary things are here. To illustrate my thought here is a GIF

how do you get collision detection on different materials within an scn node

房东的猫 提交于 2019-12-11 05:33:27
问题 I'm trying to get collision detection between different materials within an scn node. I have a cube with 6 different materials/ colors and balls coming at the cube. I'd like to detect same and different colored collisions but don't know how to apply different categories to each material. import UIKit import SceneKit class GameViewController: UIViewController, SCNPhysicsContactDelegate { Can I create categories to assign to different sides of the cube later? let ballCategory = 0 let

SceneKit keyed blend shape animation imported from Collada (.dae) file (created in Maya) not playing

柔情痞子 提交于 2019-12-11 05:05:41
问题 I'm using Maya to create animations to use in SceneKit . I'm exporting as COLLADA file ( .dae ) using Maya's built-in FBX DAE exporter. Animations on the node transform all work perfectly. For example, if we have an animation of the translation, rotation, or scale -- or a combination of those -- the animation imports correctly with the node. However, when I import an animation based on keyed blend shape inputs, the animation doesn't play. Within Xcode, if I click on the .dae file and start

Scenekit: Add animation to SCNNode from external Collada

家住魔仙堡 提交于 2019-12-11 04:50:05
问题 I initialize my Scene like this // Load COLLADA Character let myScene = SCNScene(named: "Characters.scnassets/Police/Police.dae") // Recurse through all the child nodes in the Character and add to characterNode for node in myScene!.rootNode.childNodes as [SCNNode] { characterNode.addChildNode(node) } // Add characterNode to scene self.rootNode.addChildNode(characterNode) Is it possible to add an animation to characterNode from an external DAE? It is autorigged through Mixamo. 回答1: Apple has