VideoTexture
VideoTexture is the engine-level live video binding source. It accepts an HTMLVideoElement or VideoFrame and resolves the concrete core binding that matches the shader slot used by the current draw.
For the copied-vs-external texture tradeoff, see Working With Video Textures.
Usage
import {Model, VideoTexture} from '@luma.gl/engine';
const videoTexture = new VideoTexture(device, {source: video});
const model = new Model(device, {
source,
bindings: {videoTexture}
});
For WebGL, bind through a normal GLSL sampler:
uniform sampler2D videoTexture;
vec4 color = texture(videoTexture, uv);
For copied WebGPU sampling, use a normal WGSL texture:
@group(0) @binding(auto) var videoTexture: texture_2d<f32>;
@group(0) @binding(auto) var videoTextureSampler: sampler;
let color = textureSample(videoTexture, videoTextureSampler, uv);
For native WebGPU video sampling, opt into texture_external:
@group(0) @binding(auto) var videoTexture: texture_external;
@group(0) @binding(auto) var videoTextureSampler: sampler;
let color = textureSampleBaseClampToEdge(videoTexture, videoTextureSampler, uv);
Behavior
- WebGL
sampler2Dand WebGPUtexture_2dresolve to copied lumaTextureresources. - WebGPU
texture_externalresolves to a nativeGPUExternalTexturewhen the browser accepts the import. A copiedTexturecannot satisfy that WebGPU slot; use atexture_2d<f32>shader binding for the copied path. HTMLVideoElementsources are ready only after they expose nonzero video dimensions and current frame data.VideoFramesources are ready immediately. Frames are caller-owned;VideoTexturenever callsVideoFrame.close().setSource()replaces the current source. Same-size copied frames reuse the same texture identity; size changes recreate the copied texture and invalidate bind-group identity.
Remarks
- Shader binding type selects the representation. There is no single native external-texture shader declaration shared by GLSL and WGSL.
texture_externalis for base-level clamp-style external sampling. Upload into an ordinaryTexturewhen the shader needs mipmaps, repeat addressing, or ordinarytextureSamplesemantics.- Future copied DOM sources such as HTML-in-Canvas textures and experimental
WebXRCameraTextureuse the sameTextureBindingSourceframework without makingVideoTexturetheir public API.