Add Shader (Fabric?) to Entity

I would like to create glsl to add to the emission(?) of an Entity which was loaded from a GLTF model. Specifically I want to add a procedural sparkle as f(fragcoord, time).

I've seen the material/appearance/fabric tutorials, and looked at the schema, but its still not clear how to do this specifically, mostly due to the lack of complete sandcastle-style examples. The terminology and relation between Material, MaterialAppearance, and Appearance is confusing as well. And I'm not sure how to reference and append to an Entity's model.material.materials(?)

A more basic question - how do you alter an Entity's appearance to any material, say flat emissive red, given it is a model loaded from gltf

I have no idea what I'm doing wrong here

var f= viewer.entities.add({
    name: ...,
    id: i,
    position: new Cesium.SampledPositionProperty(),
    orientation: new Cesium.SampledProperty(Cesium.Quaternion),
    model: {
        uri: ...,
        scale: 1,
        minimumPixelSize: 42,
        defer: false,
    },
});
  f.model.material= new Cesium.Material({
  fabric : {
    type : 'Color',
    uniforms : {
      color : new Cesium.Color(1.0, 0.0, 0.0, 0.5)
    }
  }
  });
  f.model.material.uniforms.color = Cesium.Color.WHITE;
}

It loads the textured GLTF fine, but shouldn't it be replacing the material?

Hello,

Sorry I missed your question before.

Cesium doesn’t have great support for editing the model’s material after it has been loaded. You can change values of the shader parameters, but you can’t set the material to a new type. If you want a different material for your model, you will have to include the shader code in the model’s glTF file.

If you look at the spec, a shader has a uri that can point to a glsl file.

If you did want to change a property of the material you can do it like this:

You can’t use the Entity API. Add a model using scene.primitives.add, as seen in this demo: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=development/3D%20Models.html&label=Development

Use the Model.getMaterial function to get the ModelMaterial you want to edit

Use ModelMaterial.setValue to change a value.

Best,

Hannah

Hm thats answers my question, its not a plausible solution.
I have multiple types of models which I need this effect applied to, perhaps the terrain as well.

I was hoping for materials as an easy approach, but now I think best approach is to render a particle cloud in screenspace with stencil stuff. I'll start a new thread.