metalkit

Repitition of texture on pan gesture in Metal Shading Language

若如初见. 提交于 2019-12-13 03:41:31
问题 I am new to metal shading language.So your kind guidance would be so helpful. I just repeated texture using metal as shown on below image (Image sequence). But it seems not smoothy.How can I make it to be appeared as smoothy line as done in following link for metal points.(overlapping Metal Point primitives and blending) At the moment what I do is allocating memory for vertex buffer (MTLBuffer) at each touch point in my gesture. code: func allocateMemoryForVetexBuffer(vertices: Array<Vertex>)

Triangulation in Metal

时间秒杀一切 提交于 2019-12-11 17:19:46
问题 As Shown in the picture. The numbers are touchpoints in the screen in order. I need to draw the traingulation only inside Colored area. Can we do it in metal with its algorithm or Any suggestions please var temp1:VertexInFillBrus temp1 = VertexInFillBrush(a:drawPoints[0] , b:drawPoints[drawPoints.count - 1] , c: drawPoints[drawPoints.count - 2])) self.bezierCalculatedCoordinates.append(temp1) self.buildBuffers(device: device) In Draw Command commandEncoder.setRenderPipelineState

MTKView blend issues when re-using currentDrawable.texture in draw() loop

最后都变了- 提交于 2019-12-11 17:12:09
问题 I am working on a metal-backed painting application in which I divide the drawing of a stroke in two steps: the first step draws the leading edge of a stroke to screen and captures the entire to an MTLTexture via: metalTextureComposite = self.currentDrawable!.texture the second step draws an updated leading edge of the advancing stroke, and composites atop a polygon textured with the last saved metalTextureComposite. This method allows me to draw infinitely long strokes without sacrificing

Setting up Metal in Swift 3 on an iPhone 6s

北城以北 提交于 2019-12-11 05:41:16
问题 I've been trying to convert Apple's MetalBasicTessellation project to work in swift 3 on an iPhone 6s running iOS 10.3.1. Everything compiles with no errors, but when running on my iPhone, I get the following error when I define renderCommandEncoder: validateAttachmentOnDevice:347: failed assertion `MTLRenderPassDescriptor texture must be MTLTextureType2DMultisample when using a resolveTexture.' I have properly set the renderPassDescriptor's texture property to inherit MKTView.currentDrawable

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

UIImage created from MTKView results in color/opacity differences

两盒软妹~` 提交于 2019-12-09 06:47:41
问题 When I capture the contents of an MTKView into a UIImage, the resulting image looks qualitatively different, as shown below: The code I use to generate the UIImage is as follows: let kciOptions = [kCIContextWorkingColorSpace: CGColorSpace(name: CGColorSpace.sRGB)!, kCIContextOutputPremultiplied: true, kCIContextUseSoftwareRenderer: false] as [String : Any] let lastDrawableDisplayed = self.currentDrawable! // needed to hold the last drawable presented to screen drawingUIView.image = UIImage

overlapping Metal Point primitives and blending

血红的双手。 提交于 2019-12-08 20:53:33
I am rendering Points primitives that overlap partially. The fragment shader shades parts of each Point primitive square transparent (solid center circle). A point primitive that does not overlap any other point primitive, shades as expected (the transparent areas of the square show the background). When such a point primitive overlaps another point primitive, the behavior is a unexpected. specifically: the transparent area does not show the opaque color of the unlerlying points primitive, but instead clears it and shows the background color. In other words, point primitives with a higher

overlapping Metal Point primitives and blending

断了今生、忘了曾经 提交于 2019-12-08 07:17:21
问题 I am rendering Points primitives that overlap partially. The fragment shader shades parts of each Point primitive square transparent (solid center circle). A point primitive that does not overlap any other point primitive, shades as expected (the transparent areas of the square show the background). When such a point primitive overlaps another point primitive, the behavior is a unexpected. specifically: the transparent area does not show the opaque color of the unlerlying points primitive,

How do you synchronize a Metal Performance Shader with an MTLBlitCommandEncoder?

两盒软妹~` 提交于 2019-12-06 02:47:24
问题 I'm trying to better understand the synchronization requirements when working with Metal Performance Shaders and an MTLBlitCommandEncoder . I have an MTLCommandBuffer that is set up as follows: Use MTLBlitCommandEncoder to copy a region of Texture A into Texture B. Texture A is larger than Texture B. I'm extracting a "tile" from Texture A and copying it into Texture B. Use an MPSImageBilinearScale metal performance shader with Texture B as the source texture and a third texture, Texture C, as

UIImage created from MTKView results in color/opacity differences

╄→гoц情女王★ 提交于 2019-12-03 09:15:18
When I capture the contents of an MTKView into a UIImage, the resulting image looks qualitatively different, as shown below: The code I use to generate the UIImage is as follows: let kciOptions = [kCIContextWorkingColorSpace: CGColorSpace(name: CGColorSpace.sRGB)!, kCIContextOutputPremultiplied: true, kCIContextUseSoftwareRenderer: false] as [String : Any] let lastDrawableDisplayed = self.currentDrawable! // needed to hold the last drawable presented to screen drawingUIView.image = UIImage(ciImage: CIImage(mtlTexture: lastDrawableDisplayed.texture, options: kciOptions)!) Since I don't modify