projection
TypeScriptget projection(): Promise<SDKHandle>Swift declarationvar projection: float4x4The projection matrix used to render the frame.
struct · iOS 15.0+ · SDK 27.1
struct PostProcessContextAn object the framework uses to pass data to a postprocess callback. In iOS 15 and later, as well as macOS 12 and later, you can register a callback function to apply postprocessing effects to RealityKit’s rendered scene. Once every frame, RealityKit calls that function before it displays the scene. You can use this callback to apply postprocess effects using any APIs that can modify an image texture. However, because RealityKit calls this method every frame, you should only use APIs that execute on the GPU, such as Metal compute functions, <doc://com.apple.documentation/documentation/metalperformanceshaders>, or <doc://com.apple.documentation/coreimage>. You can also render additional content, such as a rendered SpriteKit scene, on top of the frame buffer. - Note: For more information on implementing postprocess effects, see <doc://com.apple.documentation/documentation/realitykit/implementing_special_rendering_effects_with_realitykit_postprocessing>, which demonstrates multiple postprocess techniques. A postprocess callback takes a single `PostProcessContext` parameter, which contains data the callback function needs to modify the rendered scene, including the frame buffer, depth map, and a property for writing the modified image. If you’ve registered a postprocess callback, that function needs to encode to the output texture or the frame is never displayed. A postprocess function looks like this: ```swift func myPostProcessCallback(context: ARView.PostProcessContext) { // Handle postprocessing here. } ``` To register a function as the postprocess render callback, assign it to the ``ARView/RenderCallbacks-swift.struct/postProcess`` property of the ``ARView/renderCallbacks-swift.property`` property of the scene’s `ARView`: ```swift arView.renderCallbacks.postProcess = myPostProcessCallback ``` To stop postprocessing, set the ``ARView/RenderCallbacks-swift.struct/postProcess`` render callback to `nil`. ```swift arView.renderCallbacks.postProcess = nil ``` If your app turns postprocessing on and off frequently, another option for disabling postprocess effects is to keep your callback registered, but use an <doc://com.apple.documentation/metal/mtlblitcommandencoder> to encode the unmodified framebuffer directly to the output texture whenever postprocess effects aren’t active. ```swift func myPostProcessCallback(context: ARView.PostProcessContext) { if (usePostProcessEffects) { handlePostProcessing(context: ARView.PostProcessContext) return } // If postprocess effects are disabled, copy sourceColorTexture // directly to targetColorTexture. let blitEncoder = context.commandBuffer.makeBlitCommandEncoder() blitEncoder?.copy(from: context.sourceColorTexture, to: context.targetColorTexture) blitEncoder?.endEncoding() } ```
get projection(): Promise<SDKHandle>Swift declarationvar projection: float4x4The projection matrix used to render the frame.
setProjection(value: SDKHandle): Promise<void>Swift declarationvar projection: float4x4The projection matrix used to render the frame.
get commandBuffer(): Promise<SDKHandle>Swift declarationvar commandBuffer: any MTLCommandBufferThe Metal command buffer for encoding the frame.
setCommandBuffer(value: SDKHandle): Promise<void>Swift declarationvar commandBuffer: any MTLCommandBufferThe Metal command buffer for encoding the frame.
get sourceColorTexture(): Promise<SDKHandle>Swift declarationvar sourceColorTexture: any MTLTextureThe rendered frame buffer.
setSourceColorTexture(value: SDKHandle): Promise<void>Swift declarationvar sourceColorTexture: any MTLTextureThe rendered frame buffer.
get sourceDepthTexture(): Promise<SDKHandle>Swift declarationvar sourceDepthTexture: any MTLTextureThe frame’s depth buffer.
setSourceDepthTexture(value: SDKHandle): Promise<void>Swift declarationvar sourceDepthTexture: any MTLTextureThe frame’s depth buffer.
get targetColorTexture(): Promise<SDKHandle>Swift declarationvar targetColorTexture: any MTLTextureThe output texture where the postprocess callback writes the modified frame buffer.
setTargetColorTexture(value: SDKHandle): Promise<void>Swift declarationvar targetColorTexture: any MTLTextureThe output texture where the postprocess callback writes the modified frame buffer.
get time(): Promise<number>Swift declarationvar time: TimeIntervalThe scene’s elapsed time.
setTime(value: number): Promise<void>Swift declarationvar time: TimeIntervalThe scene’s elapsed time.
get device(): Promise<SDKHandle>Swift declarationvar device: any MTLDeviceThe Metal device where the scene renders.
setDevice(value: SDKHandle): Promise<void>Swift declarationvar device: any MTLDeviceThe Metal device where the scene renders.
static init(device: SDKHandle, commandBuffer: SDKHandle, sourceColorTexture: SDKHandle, sourceDepthTexture: SDKHandle, targetColorTexture: SDKHandle, projection: SDKHandle, time: number): Promise<ARView_PostProcessContext>Swift declarationinit(_ device: any MTLDevice, _ commandBuffer: any MTLCommandBuffer, _ sourceColorTexture: any MTLTexture, _ sourceDepthTexture: any MTLTexture, _ targetColorTexture: any MTLTexture, _ projection: float4x4, _ time: TimeInterval)Creates a new context object. This initializer creates a new postprocess context object. RealityKit creates context objects and passes them to the postprocess render callback. Your code won’t usually need to create context objects directly. - Parameters: - device: The Metal device the view renders to. - commandBuffer: The Metal command buffer that encodes this view. - sourceColorTexture: A texture containing the rendered frame. - sourceDepthTexture: A texture containing the frame’s depth buffer. - targetColorTexture: A texture the callback function writes to. - projection: The projection matrix for this frame. - time: The current elapsed time.
No declarations were skipped in this snapshot.