metal

Metal alpha blending is not working

我的未来我决定 提交于 2019-12-11 03:42:57
问题 For whatever reason I am having issues with alpha blending in metal. I am drawing to a MTKView and for every pipeline that I create I do the following: descriptor.colorAttachments[0].blendingEnabled = YES; descriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd; descriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd; descriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha; descriptor.colorAttachments[0].sourceAlphaBlendFactor =

Capture a SkeneKit scene as video

浪子不回头ぞ 提交于 2019-12-11 00:47:54
问题 I'm using SceneKit with Metal (not openGL) & would like to allow a user to record a video of him playing the game. Any ideas how can I render the scene to a video? (There's no need to record the scene audio, which might make it more simple) 回答1: I thought I'd add it as an answer: ReplayKit should do the job fine, though it does require iOS9 and a device that supports Metal (A7 or later). I've never used it but from what I remember of WWDC 2015 it only required a few lines of code to set up.

rotate camera up and down, left and right with pan gesture

点点圈 提交于 2019-12-10 23:01:17
问题 I want to rotate camera up or down and left or right to look around an object, (360 degrees view) with pan gesture using opengl lookat function, I use swift and Metal(in this case Metal = opengl es). here is the code: the lookat function(this function is in another ViewController which is inheritance from the main ViewController which is with the viewDidLoad and pan gesture function): let viewMatrix = lookAt(location, center: ktarget, up: up) the viewDidLoad and var: var ktarget = V3f() var

MTLCreateSystemDefaultDevice returning nil on iOS 13 Simulator

霸气de小男生 提交于 2019-12-10 22:22:48
问题 I am using Xcode 11 GM Seed (11A419c). When I run Metal code on iOS 13 simulator and try to access metal device created using MTLCreateSystemDefaultDevice(), it returns nil. How is Metal supposed to run on simulator without this device? Is there any setting in XCode to fix it? I have Macbook Pro retina 2012 model running Mac OS 10.14.6 if that matters. 回答1: Metal is available in iOS 13 and tvOS 13 simulators only when running on macOS Catalina (10.15) or later. This is documented in the Xcode

Metal draw 2 different objects, only one is showing

二次信任 提交于 2019-12-10 18:24:34
问题 I want to render 2 different objects with Metal...I have 2 different shaders, different renderpipeline, and command buffers, passDescriptors, they are all different..But there is only one object is drawing on the screen, I don't know where i went wrong.... Here is the draw function: dispatch_semaphore_wait(inflightSemaphore, DISPATCH_TIME_FOREVER) //Sky if let drawable = metalLayer.nextDrawable() { var modelMatrixTransSky = M4f() var modelMatrixRotSky = M4f() var modelMatrixScaleSky = M4f()

MTKTextureLoader saturates image

心不动则不痛 提交于 2019-12-10 15:29:42
问题 I am trying to use a MTKTextureLoader to load a CGImage as a texture. Here is the original image However after I convert that CGImage into a MTLTexture and that texture back to a CGImage it looks horrible, like this: Here is sorta what is going on in code. The image is loaded in as a CGImage (I have checked and that image does appear to have the full visual quality) I have a function view() that allows me to view a NSImage by using it in a CALayer like so: func view() { ..... imageView!.layer

transparency issues with repeated stamping of textures on an MTKView

北慕城南 提交于 2019-12-10 11:43:49
问题 I am trying to implement a metal-backed drawing application where brushstrokes are drawn on an MTKView by stamping a textured square repeatedly along a path. The problem I'm having is that, while each brush stamp properly shows the texture's opacity, overlapping squares do not build value, but rather override each other. In the caption below, each stamp is a textured circle with an alpha component I have a feeling that because all the stamps are being rendered at once, there is no way for the

iOS code to identify metal support in runtime?

Deadly 提交于 2019-12-09 15:10:02
问题 Usually, I use the below code to identify the iOS version of the device. if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) In a similar way, I'm trying to find Metal support for the device. Metal is supported for Apple devices with the A7 (or better) GPU and iOS 8.0. This is the way I expect my code to work: if (MetalSupported == true) { // metal programming } else { // opengles2 programming } How do I get the value for the Boolean variable MetalSupported ? 回答1: It's good that

Are MTLVertexAttributeDescriptors necessary? Why are they needed?

岁酱吖の 提交于 2019-12-09 14:56:09
问题 I've been learning Metal for iOS / OSX, and I began by following a Ray Wenderlich tutorial. This tutorial works fine but it makes no mention of MTLVertexAttributeDescriptors . Now that I'm developing my own app, I'm getting weird glitches and I'm wondering if the fact that I don't use MTLVertexAttributeDescriptors may be related to the problem. What difference do they make? I've been able to make a variety of shaders with varying vertex structures and I never even knew about these things. I

All black frames when trying to write Metal frames to Quicktime file with AVFoundation AVAssetWriter

こ雲淡風輕ζ 提交于 2019-12-09 06:55:03
问题 I'm using this Swift class (shown originally in the answer to this question: Capture Metal MTKView as Movie in realtime?) to try to record my Metal app frames to a movie file. class MetalVideoRecorder { var isRecording = false var recordingStartTime = TimeInterval(0) private var assetWriter: AVAssetWriter private var assetWriterVideoInput: AVAssetWriterInput private var assetWriterPixelBufferInput: AVAssetWriterInputPixelBufferAdaptor init?(outputURL url: URL, size: CGSize) { do { assetWriter