Get the latest tech news
From 0 to glTF with WebGPU: Basic Materials and Textures
April 28, 2024 Now that we can load up complex scene hierarchies from glTF files and render them correctly, let’s start getting some more interesting colors on screen! glTF defines a physically based BRDF, with support for metallic and roughness properties, along with normal, emission and occlusion texture maps. There are a number of extensions on top of this basic material model (the KHR_materials_* extensions) that add even more advanced material definitions.
Today we’re going to take the first step of loading the base glTF material parameters and textures from the glB file and passing them to our shader. We can now define a GLTFSampler class which will take these GLTF sampler parameters and convert them to their WebGPU equivalents, although for now we’re ignoring mip maps. Since the GLTFTexture is what’s going to be stored by the material, it’s convenient to implement setUsage on it as well to simply pass the usage flag through to the referenced image.
Or read this on Hacker News