So to be clear on my goals, since I don't have any code to share... Lets say I have a SCNNode which is positioned between the camera and another SCNNode. The first SCNNode is a SCNBox, but has no texture, thus the second SCNNode can be seen behind it. I want to give the first node a transparent material, but to have it also occlude all nodes behind it, as though it was opaque. In a regular scene, this would mean that you could see the scene background color, black perhaps, but I'm planning on doing this in ARKit, which makes more sense as that means you'd simply see the real world behind it.
Is it possible to have a SCNNode which is transparent, but which occludes any object behind it?
5.2k views Asked by Andrew AtThere are 2 answers
Marco Boschi
On
I've tested my idea from the comments and it seems to work, not be perfectly but I'll expand later on this point.
To support the rendering process SceneKit uses a depth buffer and render a point only if it will be in front of what is saved in said buffer so we have to tell SceneKit to render your see-through cube first then all the other nodes, so leave your cube node renderingOrder property to 0 (the default value) then set all the other nodes renderingOrder to a higher value, i.e. 1, 10... Normally for transparent objects you don't want to write to the depth buffer so you can see objects behind but it's not the case so leave your cube material writeToDepthBuffer property to true (the default value). Last thing to do is to make your cube transparent, you can use the default material and then add
cube.geometry?.firstMaterial?.transparency = 0.00000001
As I've said before this method is not perfect and it feels more of a workaround... but it works. The reason why we don't set the transparency to exactly 0 is that if we do so is like the cube is not even there, that is fully transparent pixel are not saved to the depth buffer.
Related Questions in IOS
- URLSession requesting JSON array from server not working
- Incorrect display of LinearGradientBrush in IOS
- Module not found when building flutter app for IOS
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Occasional crash at NSURLSessionDataTask dataTaskWithRequest:completionHandler:
- Expo Deep linking on iOS is not working (because of Google sign-in?)
- On iOS, the keyboard does not offer a 6-character SMS code
- Hi, there is an error happened when I build my flutter app, after I'm installing firebase packages occurs that error
- The copy/paste functionalities don't work only on iOS in the Flutter app
- Hide LiveActivityIntent Button from Shortcuts App
- While Running Github Actions Pipeline: No Signing Certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID
- Actionable notification api call not working in background
- Accessibility : Full keyboard access with scroll view in swiftui
- There is a problem with the request entity - You are not allowed to create 'iOS' profile with App ID 'XXXX'
- I am getting "binding has not yet been initialized" error when trying to connect firebase with flutter
Related Questions in SCENEKIT
- Create and customize T-shirt using SceneKit
- Multiple SCNActions
- How to Make Xcode Recognize Morph Targets in a DAE File Imported from Blender?
- ARKit combining ARImageAnchor position with offset values
- Fetching the animations added to a SCNNode
- RealityKit: VideoMaterial causing odd outline around transparent video?
- Can't add a SCNNode to the rootNode
- How to screenshot a SCNScene or SceneView?
- Issues with Vertical Stretching and Horizontal Movement in Metal Shading Language Ray Tracing Shader
- Why does AVPlayer doesn't orient video correctly when using SceneKit?
- How to load 3D model to UIView with better quality in iOS Swift?
- Several instances of 3D model with skinner, and duplication of weights/indices information
- SceneKit physicBody angularVelocity as local "body fixed" angular rates
- How to draw 3D circles/ring in RealityKit?
- SCNSkinner.boneIndices access generates GBytes of memory allocation - why?
Related Questions in ARKIT
- UE4: CodeSign Failed, get-task-allow entitlement doesn't match
- Is it possible to use Apple's ARKit to measure the length and width of an individual's foot to estimate shoe size?
- How can I detect plane and add model entity on it in visionOS?
- AR Scene Black Screen Issue in Android with AR Core AR Foundation and Niantic ARDK 3
- RealityKit - Add a line from one Model entity to center of screen as it moves
- Getting Call to main actor-isolated static method 'loadMainScene()' in a synchronous nonisolated context error in ARKit swiftui application
- Why custom created entity does not rotate with BodyAnchor's rotation?
- How to I wrap a UIKit view in SwiftUI with a delegate callback requiring a return value?
- How to Make Xcode Recognize Morph Targets in a DAE File Imported from Blender?
- ARKit not perfectly locking in user heading
- ARKit combining ARImageAnchor position with offset values
- how to get the bouding box dimension when using the object capture api in iOS17 after detecting the object
- ARKit Body Tracking head-body rotation inaccuracy when model turn back
- Unable to present an Immersive Space for id: Error Domain=FBSWorkspaceErrorDomain Code=1 "scene invalidated before create completion"
- RealityKit: VideoMaterial causing odd outline around transparent video?
Related Questions in SCNNODE
- How to get localCoordinates and localNormal of point of mesh(SCNNode) SCNCamera is looking at?
- Swift add custom geometry (view) to scnnode in SceneKit
- SceneKit - render surface normal of a geometry
- Swift Modify SCNode children
- Swift Prevent Scene point of view reset prior to Camera Action
- Execute function from SwiftUI view to view controller
- Performing gesture on view prevents camera action
- Detect touches and ignore other gestures Swift SceneKit
- Rotate and Move Camera around object does not work Swift SceneKit
- Swift - Detect Tap on child SCNNode not Parent
- Swift (SCNCamera) lock Globe rotation around axis
- Align SCNText Along SCNCylinder
- How to determine size of SCNPlane to cover entire SKScene
- How to run .fadeOut for mesh of the building without walls becoming semi-transparent during the animation? (SceneKit)
- How to Fix SCNNode Transform Problem with CABasicAnimation in SceneKit in Swift?
Related Questions in OCCLUSION
- evaluate CNN model for occlusion detection on cityperson dataset
- detect occluding 3d boxes from pov
- Is SLAM with occlusion possible in web-based AR apps without WebXR?
- Transparent Occlusion Shader in Unity URP
- Issues constructing a Texture2D from a byte[] extracted from an XRCpuImage in Unity
- Is there a good term for reconstructing partially-occluded 3D objects in Computer Vision by extrapolating edges?
- Check if a quad is fully covered by a set of others
- How do dense stereo matching algorithms, such as LEAStereo make disparity predictions at occluded regions?
- Occlusion culling works for dynamic objects as well
- Occlusion Culling for Grid Aligned Cells
- Three.js Visual indication or Effect to show when an object is occluded
- 2D overlapping rectangles occlusion
- Get the object or renderer displayed (rendered on top)
- Unity - prevent occlusion culling with far objects
- How can I linearly index a masked image
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
You can use material with clear color: