Coder Social home page Coder Social logo

Comments (16)

pjcozzi avatar pjcozzi commented on June 14, 2024

CC #15 - related issue for spec.

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

@pjcozzi @RemiArnaud @tparisi we need to specify how shaders are generated. With premultiplied alpha or not ? that's a context info on WebGL. Where should we put this in glTF ? in profile ? a root property to carry all context infos ? any suggestion ?

from gltf.

pjcozzi avatar pjcozzi commented on June 14, 2024

Why does glTF need to support the WebGL context-level premultiplied alpha?

Why not just support UNPACK_PREMULTIPLY_ALPHA_WEBGL for textures?

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

Shader are normally written/thought with or without premultiplied , this goes not only for texture but for computed colors in shaders too. We must support both and tell developers how the context should be set to be able to render correctly provided shaders.

from gltf.

pjcozzi avatar pjcozzi commented on June 14, 2024

This really feels outside the scope of glTF. This is an asset format, not a scene format. I don't know how we expect assets to dictate how the context should be created. That implies that I'm able to create/recreate the context when I encounter the asset. ha. Not likely for real apps.

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

The following comments only applies when developers want to use shaders generated by the converter. (or any other tool...).

Here is how I see things:

  • It is not an option for glTF to enforce support for only pre-multiplied or not by SPEC. (you didn't suggest that, but I want this to be explicit).
  • The converter should provide options to generate shaders for pre-multiplied alpha or not.
  • 2 assets shouldn't be merged in a scene if one has shaders generated using pre-multiplied and one not. It will look wrong. How can a developer could check this ?
  • Say I have a glTF asset with custom shader, I want to update shaders in this glTF asset as post processing step, how do I know if the shaders have been generated with pre-multiplied on ? And this would not fit in the details property because it would be mandatory and global.

Overall, I understand what your concern is @pjcozzi but if we provide shaders, pre-multiplied alpha is an implementation details that is one aspect driving how shaders are generated.

And shaders are implementation... so we shouldn't be surprised that kind of details surface eventually.
Wherever it is and how it is specified (could be a hint ?) should be exposed somewhere in the glTF file.

Before going further about the way to implement this, I'd like we agree on the principle.

Also I mentioned, again a converter option, let's have a configuration file to manage options better #166

from gltf.

pjcozzi avatar pjcozzi commented on June 14, 2024

Ah, I see. This is really just asset-level metadata on how the shader was generated. OK with me. (Also good info on this topic here).

Do you have JSON examples for your proposals? If this were a root-level property, what potential future properties would it include?

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

Well, I have an urgent need for this, so I'll add a converter option and and extra in asset which looks to be a good candidate until we reach an agreement for this.
something like:

    "asset": {        
        "generator": "collada2gltf@042d7d2a3782aaf6d86961d052fc53bea8b3e424",
        "extras" : {
           "premultipliedAlpha" : true
        }
    },

Toggling premultipliedAlpha will impact the generated shaders and states (blend func).

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

Also, after this change the default in the converter will change.
We were generating states for non-premultiplied alpha, but we will align with WebGL who has premultipliedAlpha switched on...

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

just pushed the change (merged from mini branch premulatiplied-alpha-rework) e7a5277

from gltf.

pjcozzi avatar pjcozzi commented on June 14, 2024

@fabrobinet do you have any ideas for what the final JSON should look like?

Perhaps it is as simple as

"asset": {        
    "generator": "collada2gltf@042d7d2a3782aaf6d86961d052fc53bea8b3e424",
    "premultipliedAlpha" : true
},

Or do you see premultipliedAlpha being on a sub-property of asset?

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

@pjcozzi Yes, that's what I had in mind, but I have put an extras before we reached agreement.
@RemiArnaud , @tparisi OK with you ? I plan to move forward quickly on this low-hanging fruit.

from gltf.

pjcozzi avatar pjcozzi commented on June 14, 2024

I'm working on the schema now (in the new schema branch). Can we move premultipliedAlpha directly under asset for dev-6?

"asset": {        
    "generator": "collada2gltf@042d7d2a3782aaf6d86961d052fc53bea8b3e424",
    "premultipliedAlpha" : true
},

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

Fixed in dev-6.

from gltf.

pjcozzi avatar pjcozzi commented on June 14, 2024

@fabrobinet OK to close?

from gltf.

fabrobinet avatar fabrobinet commented on June 14, 2024

yes

from gltf.

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.