Create a Material specifically built to draw the vertices of a Geometry. Internally used by all kind of Meshes.

Render pipeline

A RenderMaterial automatically creates a RenderPipelineEntry. Once all the BindGroup have been created, they are sent with the shaders code and the rendering options to the RenderPipelineEntry, which is in turns responsible for creating the GPURenderPipeline.

After the GPURenderPipeline has been successfully compiled, the RenderMaterial is considered to be ready.

Hierarchy (view full)

Constructors

Properties

type: string

The type of the Material

uuid: string

The universal unique id of the Material

renderer: Renderer

The Renderer used

bindGroups: AllowedBindGroups[]

Array of bind groups used by this Material This array respects a specific order:

  1. The textures bind groups
  2. The bind group created using uniforms and storages parameters if any
  3. Additional bind groups parameters if any
texturesBindGroups: TextureBindGroup[]

Array of texture bind groups used by this Material

inputsBindGroups: BindGroup[]

Array of bind groups created using the uniforms and storages parameters when instancing this Material

clonedBindGroups: AllowedBindGroups[]

Array of cloned bind groups created by this Material

uniforms: Record<string, Record<string, BufferBindingInput>>

Object containing all uniforms inputs handled by this Material

storages: Record<string, Record<string, BufferBindingInput>>

Object containing all read only or read/write storages inputs handled by this Material

inputsBindings: Map<string, BindGroupBindingElement>

Map of bindings created using the uniforms and storages parameters when instancing this Material

domTextures: DOMTexture[]

Array of DOMTexture handled by this Material

textures: Texture[]

Array of Texture handled by this Material

samplers: Sampler[]

Array of Sampler handled by this Material

pipelineEntry: RenderPipelineEntry

Mandatory geometry attributes to pass to the render pipeline entry

Options used to create this RenderMaterial

Accessors

  • get ready(): boolean
  • Get whether the renderer is ready, our pipeline entry and pipeline have been created and successfully compiled

    Returns boolean

Methods

  • Get the complete code of a given shader including all the WGSL fragment code snippets added by the pipeline

    Parameters

    Returns string

    • The corresponding shader code
  • Render the material if it is ready: Set the current pipeline and set the bind groups

    Parameters

    • pass: GPURenderPassEncoder | GPUComputePassEncoder

      current pass encoder

    Returns void