KHR_materials_unlit defines an unlit shading model for use in glTF 2.0 materials.

Illustration

Figure: Unlit materials are useful for flat shading, stylized effects, and for improving performance on mobile devices. Source: Model by Hayden VanEarden.

Unlit (also "Shadeless" or "Constant") materials provide a simple alternative to the Physically Based Rendering (PBR) shading models provided by the core specification. Unlit materials are often useful for cheaper rendering on performance-contrained devices, e.g. mobile phones. Additionally, unlit materials can be very useful in achieving stylized, non-photo-realistic effects like hand painted illustrative styles or baked toon shaders.

Properties:

Example

The MaterialsUnlit class provides a single ExtensionProperty type, Unlit, which may be attached to any Material instance. For example:

import { MaterialsUnlit, Unlit } from '@gltf-transform/extensions';

// Create an Extension attached to the Document.
const unlitExtension = document.createExtension(MaterialsUnlit);

// Create an Unlit property.
const unlit = unlitExtension.createUnlit();

// Attach the property to a Material.
material.setExtension('KHR_materials_unlit', unlit);

Hierarchy

  • Extension
    • MaterialsUnlit

Properties

extensionName: "KHR_materials_unlit" = ...
prereadTypes: PropertyType[]

Before reading, extension should be called for these Property types. Most extensions don't need to implement this.

prewriteTypes: PropertyType[]

Before writing, extension should be called for these Property types. Most extensions don't need to implement this.

readDependencies: string[]

Dependency IDs needed by this extension, to be installed before I/O.

Methods

  • dispose(): void
  • Disables and removes the extension from the Document.

  • Installs dependencies required by the extension.

  • isRequired(): boolean
  • Indicates to the client whether it is OK to load the asset when this extension is not recognized. Optional extensions are generally preferred, if there is not a good reason to require a client to completely fail when an extension isn't known.

  • preread(_readerContext: ReaderContext, _propertyType: PropertyType): MaterialsUnlit
  • Used by the PlatformIO utilities when reading a glTF asset. This method may optionally be implemented by an extension, and should then support any property type declared by the Extension's Extension.prereadTypes list. The Extension will be given a ReaderContext instance, and is expected to update either the context or its JSONDocument with resources known to the Extension. Most extensions don't need to implement this.

  • prewrite(_writerContext: WriterContext, _propertyType: PropertyType): MaterialsUnlit
  • Used by the PlatformIO utilities when writing a glTF asset. This method may optionally be implemented by an extension, and should then support any property type declared by the Extension's Extension.prewriteTypes list. The Extension will be given a WriterContext instance, and is expected to update either the context or its JSONDocument with resources known to the Extension. Most extensions don't need to implement this.

  • Indicates to the client whether it is OK to load the asset when this extension is not recognized. Optional extensions are generally preferred, if there is not a good reason to require a client to completely fail when an extension isn't known.

  • register(): void
  • Performs first-time setup for the extension. Must be idempotent.

Function symbol, f(📦) → 📦, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy TypeDoc documentation Copyright 2020 under MIT license