I am using MetalKit and have a complex rendering pipeline. The results are rendered into a MTKView
.
Now I would like to feed the contents of the MTKView
to a SCNScene
and using a SCNCamera
to perform post-process effects like HDR.
How is this possible?
I do not want general directions. I want specific calls if possible.
You should ideally perform your post-process as part of your Metal rendering pipeline. The procedure you are suggesting requires unnecessary resources since you will be rendering a 2D plane in 3D in SceneKit just to apply some HDR effects.
Nevertheless, you can achieve what you want by rendering your Metal pipeline output to a texture and then simply applying it to a plane in SceneKit.
First assign your texture:
plane.materials.first?.diffuse.contents = offscreenTexture
Then override your SceneKit rendering to your Metal rendering loop:
Then perform your Metal rendering with the texture as target, and once that is done you render your SceneKit scene:
Full example project:
https://github.com/lachlanhurst/SceneKitOffscreenRendering