Search code examples
gltf

Shaders in gltf 2.0


I have previously worked on gltf 1.0 and is now trying to update my application to render gltf2.0 sample models provided by khronos. I understand that shaders(glsl) and techniques are no longer part of the core properties in gltf 2.0.

So my question is that:

  1. Are shader information now separated from .gltf? I know there is KHR_technique_webgl extensions which consist of the technique and shader properties(exactly like how gltf1.0 represent shader), are we suppose to be use that if our material arent pbr?

  2. How do rendering engines now grab shader information from normal .gltf now(without the extensions)? Do we do it like old school way ie loading our own shader and manually map the model attributes to shaders attribute?


Solution

  • The KHR_technique_webgl extension will eventually be finished, and will provide a way to include custom shaders with your glTF2.0 model. But as of this writing, the extension is not fully defined and tools cannot implement it.

    The more general case (and recommended if it suits your needs) would be to use PBR or Blinn-Phong materials. These are declared abstractly in glTF, so that rendering engines can build their own shaders for these material types, and will generally integrate better with engines' own lighting and/or shadows.