Drawing to Multiple MTKViews

Having read through Chapter 14 ( Multipass and Deferred Rendering ), I am intrigued by the possibility of viewing several textures at once in a window while an app is rendering and combining them.

I have created a View Controller which holds two MTKViews, but am puzzled by what would be best practice to try having more than one “drawable” presented to the Renderer class.

It has been easy to switch the target from one MTKView to the other by passing either to the Renderer init. But that’s not helpful :frowning:

Should I be trying to use a blitEncoder to send an offscreen texture to the second MTKView? Is it more plausible to use a fragment shader with a quad?

I’m hoping that pixels can be blitted to any particular onscreen view with a single Renderer class (?)

Thanks very much,
John Lobe

All you need to do is use the blit command encoder four times, once for each quarter of the screen.

Okay, thanks very much. Blitting directly to the mtkView caused trouble which I couldn’t sort out.

So, I am blitting four smaller textures to one large texture before rendering the latter to the mtkView using a quad. Seems to work and I am going to try it with the Raytracing in Swift example that you created. It might be a fun way to see how the rays are interacting with the models :slight_smile:

Thanks again

1 Like