Giter Club home page Giter Club logo

Comments (6)

warrenm avatar warrenm commented on September 4, 2024

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.

warrenm avatar warrenm commented on September 4, 2024

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.

kourion11 avatar kourion11 commented on September 4, 2024

Thank you!

from gltfkit2.

warrenm avatar warrenm commented on September 4, 2024

Do you consider this issue resolved, or is there more to do here?

from gltfkit2.

warrenm avatar warrenm commented on September 4, 2024

This issue will be automatically closed in seven days if no further reply is received.

from gltfkit2.

warrenm avatar warrenm commented on September 4, 2024

Closing.

from gltfkit2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.