metal

Why is the triangle being rendered with rough edges and not smooth edges? Metal, Swift, Xcode

爱⌒轻易说出口 提交于 2021-01-29 12:19:53
问题 I am using this code to render the "Hello Triangle" triangle. On my iPhone, though, the triangle has very rough edges, not smooth edges, like in the example. import UIKit import Metal import MetalKit import simd class MBEMetalView: UIView { // // // // // MAIN // // // // // var metalDevice: MTLDevice! = nil var metalLayer: CAMetalLayer! = nil var commandQueue: MTLCommandQueue! = nil var vertexBuffer: MTLBuffer! = nil var pipelineState: MTLRenderPipelineState! = nil var displayLink:

How to draw a textured rectangle with Metal

醉酒当歌 提交于 2021-01-29 06:35:10
问题 I'm looking for a most efficient way of drawing a 2-dimensional background in metal. This requires rendering a textured rectangle. The basic geometry example shows an example on how to draw a triangle. Is there an easy and non-bloated way to draw a rectangle (a polygon with 4 corners)? 回答1: The Basic Texturing sample draws a textured rectangle 来源: https://stackoverflow.com/questions/52515513/how-to-draw-a-textured-rectangle-with-metal

addPresentedHandler not being triggered in Metal on iOS

白昼怎懂夜的黑 提交于 2021-01-28 07:54:39
问题 I've been trying to set up a addPresentedHandler for some time now, but without luck. I've got a addCompletedHandler working on the command buffers that contain the rendering work to be executed every frame. I've verified that the addCompletedHandler is working by seeing setting breakpoints within the code block. These are triggered when running the app. For the addPresentedHandler however, no breakpoint within the code block is triggered (I've also verified through modifying variables from

Get the Triangular Polygon where the Ray Point intersected

不羁岁月 提交于 2021-01-28 07:30:36
问题 I am rendering a 3D Obj model in iOS. http://metalbyexample.com/picking-hit-testing/. I am following the above Tutorial written by WM to find the hit point in the 3D model. Using the above link I can find the intersecting point with 3D model. I want to find the triangular polygon where I touched and I want to find the UV coordinates in the Image texture. How can I do that.. 来源: https://stackoverflow.com/questions/56832882/get-the-triangular-polygon-where-the-ray-point-intersected

Resulting MTLTexture lighter than CGImage

若如初见. 提交于 2021-01-27 11:41:52
问题 I have kernel func which must convert Y and CbCr textures created from pixelBuffer(ARFrame.capturedImage) to RGB texture like in apple guide https://developer.apple.com/documentation/arkit/displaying_an_ar_experience_with_metal But I get over lighted texture kernel void renderTexture(texture2d<float, access::sample> capturedImageTextureY [[ texture(0) ]], texture2d<float, access::sample> capturedImageTextureCbCr [[ texture(1) ]], texture2d<float, access::read_write> outTextue [[texture(2)]],

Antialiasing a SceneKit rendering with Metal

﹥>﹥吖頭↗ 提交于 2021-01-07 03:52:26
问题 I'm new to Metal. I'm rendering a SceneKit scene with Metal using this Apple sample code. TLDR; it calls the SCNRenderer's render function and passes in a command buffer. I'm compiling for Big Sur. It works, but it is not anti-aliased. I've tried a few ways to achieve it, as you can see in the updates below. Without Metal, I'd just set isJitteringEnabled to true on the SCNRenderer, and I get beautiful (and slow) 96-ish-pass renderings. If I try to do this with Metal, I get weird pixel format