This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| guard let computePipelineState = self.computePipelineState, | |
| let encoder = context.commandBuffer.makeComputeCommandEncoder() | |
| else { | |
| return | |
| } | |
| encoder.setComputePipelineState(computePipelineState) | |
| encoder.setTexture(context.sourceColorTexture, index: 0) | |
| encoder.setTexture(context.targetColorTexture, index: 1) | |
| encoder.dispatchThreadgroups(self.threadgroupsPerGrid, threadsPerThreadgroup: self.threadsPerThreadgroup) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private func setupComputePipeline(targetTexture: MTLTexture) { | |
| guard let device = MTLCreateSystemDefaultDevice(), | |
| let library = device.makeDefaultLibrary(), | |
| let postProcessingKernel = library.makeFunction(name: "inverseColorKernel"), | |
| let pipelineState = try? device.makeComputePipelineState(function: postProcessingKernel) | |
| else { | |
| assertionFailure() | |
| return | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let device = MTLCreateSystemDefaultDevice() | |
| let library = device.makeDefaultLibrary() | |
| let postProcessingKernel = library.makeFunction(name: "inverseColorKernel") | |
| let pipelineState = try? device.makeComputePipelineState(function: postProcessingKernel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| arView.renderCallbacks.postProcess = { [weak self] context in | |
| // ... post-processing code ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // LoopAndGestureViewController.swift | |
| // | |
| // | |
| // Created by Dennis Ippel on 02/04/2021. | |
| // | |
| import UIKit | |
| import RealityKit | |
| import Combine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import RealityKit | |
| import Combine | |
| class GameViewController: UIViewController { | |
| var sceneEventsUpdateSubscription: Cancellable! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let viewBoundingBox = viewSpaceBoundingBox(fromNormalizedImageBoundingBox: boundingBox, | |
| usingDisplayTransform: displayTransform) | |
| let midPoint = CGPoint(x: viewBoundingBox.midX, | |
| y: viewBoundingBox.midY) | |
| // Get the feature point that is closed to our detected rectangle's center | |
| let results = sceneView.hitTest(midPoint, types: .featurePoint) | |
| let depthBufferZ = calculateFragmentDepth(usingCamera: camera, |
NewerOlder