scntechnique

How to use SCNTechnique to create a “masked” portal effect in SceneKit / ARKit?

巧了我就是萌 提交于 2019-12-23 03:36:10
问题 I'm trying to wrap my head around how to use SCNTechnique with Scenekit. The effect I'm trying to create can easily be achieved in Unity by adding a custom shader to two materials, making objects with the "filtered" shader to only be visible when it is seen through the other shader (the portal). I've followed this tutorial to create this in Unity: https://www.youtube.com/watch?v=b9xUO0zHNXw I'm trying to achieve the same effect in SceneKit, but I'm not sure how to apply the passes. I'm

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