Questions tagged [metalkit]

Use this tag for questions MetalKit, a framework that provides functions and classes intended to reduce the effort required to create a Metal application. Consider using a more specific tag such as [mtkview] or [mtktextureloader].

MetalKit is a framework that first appeared in iOS 9 and OS X El Capitan. It provides functions and classes intended to reduce the effort required to create a Metal application.

The following functions are the three key areas MetalKit provides:

  • Texture Loading enables your application to load textures from various sources easily. Loading of textures can be achieved in an asynchronous way with only a few lines of code. For more information, please see the MTKTextureLoader Class Reference.
  • Model Handling enables Metal-specific functionality to easily interface with Model I/O assets; these highly-optimized functions and objects make up of a collection that enables efficient data transfer between Metal buffers and Model I/O.
  • View Management provides a standard implementation of a Metal view and an optional drawing delegate, which reduce greatly the amount of code needed to generate graphics rendering in Metal app. For more information, please see the MTKView Class Reference and MTKViewDelegate Protocol Reference.

This tag is appropriate for general questions about MetalKit. Specific questions about any of the aformentioned functions should use a more specific tag instead, such as or .

400 questions
5
votes
1 answer

Convert Core Image Kernel Language function to Metal Shading Language

I have the following function in Core Image Kernel Language and I need something equivalent in Metal Shading Language, but I have problem with destCoord , unpremultiply and premultiply functions. kernel vec4 MyFunc(sampler src, __color color, float…
Asteroid
  • 1,049
  • 2
  • 8
  • 16
5
votes
3 answers

How to get programmatically the maximum texture size (width and height)

How to get programmatically the maximum texture size (width and height) with metal? with openGL i can do: glGetIntegerv(GL_MAX_TEXTURE_SIZE, ...) but how to do it with Metal ?
zeus
  • 12,173
  • 9
  • 63
  • 184
5
votes
2 answers

Metal Shading language for Core Image color kernel, how to pass an array of float3

I'm trying to port some CIFilter from this source by using metal shading language for Core Image. I have a palette of color composed by an array of RGB struct and I want to pass them as an argument to a custom CI color image kernel. The RGB struct…
Andrea
  • 26,120
  • 10
  • 85
  • 131
5
votes
2 answers

How to properly render a 3d model using Metal IOS?

I created a 3D object using blender and exported it as an OBJ file and I tried to render it using Metal by following this http://metalbyexample.com/modern-metal-1 tutorial. But some of my 3D object parts are missing. They are not rendered…
Nilupul Sandeepa
  • 748
  • 6
  • 20
5
votes
0 answers

On MTLComputePipelineState what determines maxTotalThreadsPerThreadgroup?

When working with Metal Shaders / Compute Kernels on iOS or MacOS... MTLComputePipelineState has a limit of maxTotalThreadsPerThreadgroup. This limit can be queried after the pipeline state is created. This limit is dependent on both GPU hardware…
TJez
  • 1,969
  • 2
  • 19
  • 24
5
votes
1 answer

MTKView updating frame buffer without clearing previous contents

I am working on a painting program where I draw interactive strokes via an MTKView. If I set the renderPassDescriptor loadAction to 'clear': renderPassDescriptor?.colorAttachments[0].loadAction = .clear The frame buffer, as expected, shows the…
Plutovman
  • 677
  • 5
  • 22
5
votes
1 answer

How to hit test with a bounding box using MDL

I am trying to compute the intersection with MDL bounding Box, my code is based on the great article by WM at http://metalbyexample.com/picking-hit-testing/#more-738 the idea that t0 should be the nearest point…
mjeragh
  • 85
  • 8
5
votes
2 answers

OpenGL ES deprecated in iOS 12 and SKShader

I am very new to the concept and use of shaders in SpriteKit. I found this tutorial on how to render a Mandelbrot fractal with a custom shader file - Fractal.fsh - attached to a Color Sprite's Custom Shader…
Sanxion
  • 95
  • 1
  • 6
5
votes
1 answer

How do you detect where a mouse down event occurred in an MTKView?

This might be more of a generic graphics programming question, but for now this is within the context of using Apple's Metal framework on macOS. In NSView mouseDown, it's trivial to get the local coordinates of where the mouse down event took place…
kennyc
  • 5,490
  • 5
  • 34
  • 57
5
votes
2 answers

Swift Metal save bgra8Unorm texture to PNG file

I have a kernel that outputs a texture, and it is a valid MTLTexture object. I want to save it to a png file in the working directory of my project. How should this be done? The texture format is .bgra8Unorm, and the target output format is…
mackycheese21
  • 884
  • 1
  • 9
  • 24
5
votes
1 answer

Off Screen Rendering Metal

func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) { print("current drawable size:\(view.drawableSize)") } func draw(in view: MTKView) { guard let drawable = view.currentDrawable else { return } …
Ruban4Axis
  • 821
  • 6
  • 27
5
votes
0 answers

Metal Render Loop optimization

I'm looking for some direction on how to properly implement a Metal render loop. My render loop is being fed a stream of video frames from an AVPlayer. Here's my current implementation: A CVDisplayLink queries the AVPlayerItemVideoOutput of the…
zzyzy
  • 973
  • 6
  • 21
5
votes
1 answer

Textures and no textures at the same time in metal, with multiply blending

I'm drawing 2 different vertex buffers in metal, one with a texture (ignoring vertex color data) and the other without a texture (drawing purely the vertex color data): let commandBuffer = self.commandQueue.makeCommandBuffer() let commandEncoder =…
usrgnxc
  • 794
  • 2
  • 9
  • 34
4
votes
1 answer

How to create a metal-cpp project?

I am trying to learn metal and since I am already familiar with C++, I am trying to do it using metal-cpp. I am not an experienced macOS developer but I have worked in Xcode in the past in projects using OpenGL and C++ as the main language. My…
dandov
  • 41
  • 2
4
votes
1 answer

SceneKit Metal shader compilation performance bug in iOS 14 workaround ideas

I'm looking for a SceneKit expert to suggest some way to work around the bad performance bug in SceneKit's built-in Metal shader compilation in iOS 14.x and macOS Catalyst 11.x. Since I've tried everything I can think of to get Apple to fix the…
LenK
  • 2,944
  • 2
  • 20
  • 26
1 2
3
26 27