Comments (6)
You're going to need to fix this further up your pipeline, or dig into the code to adapt it to your needs.
The framework maps glTF properties to SceneKit properties as closely as it can, but it's not possible to vary the opacity of a node by setting its base color factor's alpha channel. There's simply nowhere for that information to go in SceneKit.
One possible solution would be to preprocess any textures that need to be transparent by multiplying them by their respective factors. In the Christmas Ball example, this would entail modulating baseColor_1.png by the alpha of its base color factor (0.4681818).
Another possible solution is to adapt the loader to carry information about the base color factor into the SceneKit conversion routine and use shader modifiers to apply it to the corresponding material. This is an intrusive change and one that I've wanted to try for a long time, but haven't gotten around to yet.
In addition to the above suggestions, if you find you get better results from dual-layer blending, you can modify all alpha-blended materials to use it upon import rather than targeting specific materials in specific assets. Just iterate over the materials in the GLTFSceneSource
before performing conversion:
let source = GLTFSCNSceneSource(asset: asset)
for material in source.materials {
if material.blendMode == .alpha {
material.transparencyMode = .dualLayer
}
}
To be clear, setting the transparency mode by itself won't solve your issues with opacity; it's a supplemental suggestion that may improve image quality after fixing your alpha channel woes.
from gltfkit2.
Okay, I have some maybe-good news for you. I implemented better handling of base color factor modulation via shader modifiers, and the Christmas Ball asset looks better by default, without having to do any runtime modifications.
You should be aware that macOS Sonoma 14.0 (and iOS 17.0, I think) have a bug in SceneKit that affects transparency, so you may notice differences in how assets render on these OS versions.
In the meantime, you should find that things look better as of ce58ae6 if you want to give it a try.
from gltfkit2.
Thank you!
from gltfkit2.
Do you consider this issue resolved, or is there more to do here?
from gltfkit2.
This issue will be automatically closed in seven days if no further reply is received.
from gltfkit2.
Closing.
from gltfkit2.
Related Issues (20)
- Display of KHR_materials_transmission HOT 17
- Model broke app HOT 13
- Support for SPM HOT 7
- Texture coordinate sets are not mapped deterministically to SceneKit geometry sources HOT 5
- Skinned, morphed, normal-mapped models have incorrect lighting in SceneKit HOT 15
- Add Mac Catalyst Xcode Destination HOT 3
- Building for 'macCatalyst', but linking in dylib (Cocoa.tbd) built for 'macOS' HOT 1
- Crash when loading animation HOT 4
- GLTFAssetReader convertBuffers crashes during asset loading HOT 8
- GLTFRealityKitLoader bad material rendering on some GLB Files HOT 19
- Crash when converting model containing 8-bit sparse accessor indices HOT 3
- How to use GLTFDracoMeshDecompressor need example HOT 5
- GPU instancing extension support? HOT 5
- Temperance bone direction HOT 4
- Inquiry Regarding Privacy Compliance HOT 1
- Add support for anisotropy in RealityKit converter
- Apple new Privacy manifest files In May HOT 4
- Broken surfaces in RealityKit HOT 3
- App crashes on iOS 15.x device stating dyld[7200]: Symbol not found: HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gltfkit2.