question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ModelExperimental` - Default material

See original GitHub issue

According to the glTF spec,

If material is undefined, then a default material MUST be used.

The “default material” is described here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#default-material

This should be easy to handle, there’s a couple things to check:

  • Ensure that the MaterialPipelineStage doesn’t throw an error if primitive.material is undefined. A no-op is probably okay
  • Ensure that the shader defaults match what is described in the spec
  • find a model to test with

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ptrgagscommented, Jun 22, 2022

Oh @jjhembd here’s A modified Sandcastle example that sets up the default material. Basically I (ab)used a CustomShader’s REPLACE_MATERIAL mode so the material is set to the default rather than what was in the glTF.

The relevant code is this part

// Modified this shader to use the default material
const textureUniformShader = new Cesium.CustomShader({
  lightingModel: Cesium.LightingModel.PBR,
  mode: Cesium.CustomShaderMode.REPLACE_MATERIAL,
  fragmentShaderText: `
    void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)
    {
    }
    `,
});

EDIT: Also note that the lighting looks weird for the default material since the normal is set to a constant +z direction. This was mainly because we haven’t implemented #6506

1reaction
ptrgagscommented, Jun 22, 2022

Hi @jjhembd,

Is there anywhere else I need to check to make sure we always get a default material?

At this point I think it’s really just ModelExperimentalFS.glsl that needs to be updated since that’s hard-coding defaults in the shader.

As far as the ModelComponents.Material() goes, I think we covered all the main cases in the above discussion, but I guess it doesn’t hurt to do a search through the code for ModelComponents.Material ModelComponents.MetallicRoughness and ModelComponents.SpecularGlossiness to double check nothing is hard-coding an unexpected default.

Also, in PntsLoader…

That’s a good question… .pnts not technically a glTF file in the first place (unlike .b3dm and .i3dm which wrap a .glb file). So I don’t think this particular case has a correct answer, it’s more about what we think looks good as a default. Might be good to compare Model vs ModelExperimental rendering the same .pnts model and try to make them match.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ModelExperimental - Cesium Documentation
Name, Type, Default, Description ... When true, back face culling is determined by the material's doubleSided property; when false, back face culling is ......
Read more >
CustomShader - Cesium Documentation - Mars3D
A user defined GLSL shader used with ModelExperimental as well as Cesium3DTileset . ... If present, this overrides the default lighting for the...
Read more >
CustomShader - Cesium Documentation
Name Type Default mode CustomShaderMode CustomShaderMode.MODIFY_MATERIAL lightingModel LightingModel isTranslucent Boolean false
Read more >
Changing all "In Model" materials to "default" material? - Reddit
I was wondering if anyone could help me with figuring this one out... I'm working with a large model (About 138 mb) of...
Read more >
cesium/CHANGES.md - UNPKG
enableModelExperimental` so tilesets with `Model` and `ModelExperimental` can be ... This ensures Cesium rendering is fast and smooth by default across all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found