Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sheen implementation method? #227

Closed
echadwick-artist opened this issue Nov 9, 2019 · 12 comments
Closed

Sheen implementation method? #227

echadwick-artist opened this issue Nov 9, 2019 · 12 comments

Comments

@echadwick-artist
Copy link
Contributor

What is the glTF syntax for adding sheen to an existing asset?

I've exported a model from Max2Babylon into glTF ASCII format, and am trying to manually add the sheen parameters. I'd like to share the asset, with sheen enabled.

Here's the asset without sheen:
image

With sheen enabled, using the BabylonJS Sandbox:
image

The sheen sample code from BabylonJS: https://doc.babylonjs.com/how_to/physically_based_rendering_master#sheen

My blind and fruitless attempt to integrate it into the glTF file:
image

chair_gltf_sheen.zip

Thanks for any help!

@bghgary
Copy link

bghgary commented Nov 12, 2019

The proposed spec is here: KhronosGroup/glTF#1688

You can see an example JSON: https:/BabylonJS/MeshesLibrary/blob/master/Sheen/Cloth.gltf#L157-L164

                "KHR_materials_sheen": {
                    "sheenFactor": 1.0,
                    "sheenColor": [
                        0.0235294117647059,
                        0.0352941176470588,
                        0.2745098039215686
                    ]
                },

Let me know if you need more help.

@emackey
Copy link
Member

emackey commented Nov 12, 2019

Note that the proposed spec is not final. In particular, it uses the term "factor" in a way that is inconsistent with the rest of glTF. I think it needs a bit of renaming things to fix it.

@echadwick-artist
Copy link
Contributor Author

Thanks!

Sheen isn't appearing, and there's a Validation error:

    "code": "UNDECLARED_EXTENSION",
    "message": "Extension was not declared in extensionsUsed.",
    "severity": 0,
    "pointer": "/materials/0/extensions/KHR_materials_sheen"

Sorry for the noobishness. What's the proper syntax to declare the extension?

chair_edited.zip

@emackey
Copy link
Member

emackey commented Nov 12, 2019

glTF has a pair of root-level arrays of strings, one array called extensionsUsed and another extensionsRequired. If you use an extension anywhere in the glTF, its name must appear in the list of extensionsUsed.

If the model cannot be displayed correctly in any glTF viewer that does not support a particular extension, then the extension must be declared in both extensionsUsed and extensionsRequired. Conforming viewers should reject glTF models that require unknown or unsupported extensions.

@emackey
Copy link
Member

emackey commented Nov 12, 2019

Also your first material in chair_edited has a stray comma after "alphaMode": "OPAQUE", ,

@emackey
Copy link
Member

emackey commented Nov 12, 2019

@echadwick-wayfair Try this:

chair_gltf_edited_v2.zip

Drop the GLB file here: https://sandbox.babylonjs.com/

@echadwick-artist
Copy link
Contributor Author

That worked great. Thank you!

How did you generate the GLB?

I need to submit a bug for the BabylonJS guys, the Sandbox's exporter seems to be resetting the Occlusion UV1 assignment to UV0, and tossing the sheen settings.

@emackey
Copy link
Member

emackey commented Nov 12, 2019

@echadwick-wayfair I'm using VSCode with my own "glTF Tools" extension (plugin) added to it, and I can't recommend it enough for hand-editing glTF files. I also have the "Prettify JSON" extension by Mohsen Azimi installed, which is how I auto-formatted the glTF's JSON (Ctrl-A, Ctrl-K, Ctrl-F).

I made the GLB by right-clicking the title bar tab for the glTF file and picking "Export to GLB" from the context menu. It can import and export GLBs, using code contributed to my extension by Microsoft. It also shows live output from the official glTF Validator in the document problems window at the bottom. There's also a 3D preview, but that doesn't have Sheen or other PBR Next things in it yet.

@emackey
Copy link
Member

emackey commented Nov 12, 2019

and tossing the sheen settings

Keep in mind that the sheen settings are experimental and may change before they become ratified. Don't build out any graphics tool pipeline with the draft sheen extension, as its output will likely become obsolete soon.

@echadwick-artist
Copy link
Contributor Author

Thanks Ed. I'm working on this for the Khronos 3D Commerce group, helping develop standards, so yeah everything's in flux and that's fine.

I would like to share files with the working group to demonstrate different sheen material settings. What's the best way for content creators to do so, at present? Did you do any edits to the source for the GLB file? Does the JSON in the GLTF overwrite all material settings inside the GLB binary, or only some of them?

@emackey
Copy link
Member

emackey commented Nov 12, 2019 via email

@echadwick-artist
Copy link
Contributor Author

Thanks for the help! I am able to edit files easily now to test Sheen, and share results.

My process:

  1. Export glTF from 3ds Max using Max2Babylon.
  2. Open .glTF in a JSON syntax formatter, like https://jsonformatter.org/json-pretty-print
  3. Edit to include the lines you added, adjusting values as needed.
  4. Drag-n-drop .gltf/.bin/etc. into the glTF Validator to check for errors. http://github.khronos.org/glTF-Validator/
  5. Drag-n-drop .gltf/.bin/etc. into the Sandbox to view.

gltf_sheen_damask.zip

screenshot BabylonJS Sandbox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants