How to apply a video to a model?

Hi,
I’m trying to set a video for a model using a CustomShader,
but I don’t understand how to create a UniformTexture for a video correctly.

const videoElement = document.getElementById("video");

const videoTextureShader = new Cesium.CustomShader({
  uniforms: {
    // user-defined texture
    u_video: {
      type: Cesium.UniformType.SAMPLER_2D,
      value: new Cesium.TextureUniform({
        url: videoElement, 
      }),
    },
  },
  // Apply the texture to the model, but move the texture coordinates
  // a bit over time so it's animated.
  fragmentShaderText: `
    void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material)
    {
        material.diffuse = texture(u_video, fsInput.attributes.texCoord_0).rgb;
    }
    `,
});

HI @Logrus, thanks for the question.

I don’t believe we have any easy way to use a video for the material of a model. We do offer it as an option for some entities which you can see in the Video Sandcastle but not for models.

You might have some luck looking through the code for how we support that in Material, Texture and PostProcessStage for inspiration.

1 Like

Ok, Thanks