RenderMaterial constructor
our renderer class object
parameters used to create our RenderMaterial
The type of the Material
The universal unique id of the Material
The Renderer used
Array of bind groups used by this Material This array respects a specific order:
Array of texture bind groups used by this Material
Array of bind groups created using the uniforms and storages parameters when instancing this Material
Array of cloned bind groups created by this Material
Object containing all uniforms inputs handled by this Material
Object containing all read only or read/write storages inputs handled by this Material
Array of DOMTexture handled by this Material
Render pipeline entry used by this RenderMaterial
Mandatory geometry attributes to pass to the render pipeline entry
Options used to create this RenderMaterial
Get whether the renderer is ready, our pipeline entry and pipeline have been created and successfully compiled
Get the main texture bind group created by this Material to manage all textures related struct
Get the RenderMaterial pipeline buffers cache key based on its BindGroup cache keys and eventually attributes cache keys.
Get whether this RenderMaterial uses the renderer camera and lights bind group.
Called when the device has been lost to prepare everything for restoration. Basically set all the GPUBuffer to null so they will be reset next time we try to render
Called when the device has been restored to recreate our samplers, textures and bind groups.
Get the complete code of a given shader including all the WGSL fragment code snippets added by the pipeline
Optional
shaderType: FullShadersType = 'full'shader to get the code from
Get the added code of a given shader, i.e. all the WGSL fragment code snippets added by the pipeline
Optional
shaderType: FullShadersType = 'vertex'shader to get the code from
Process all BindGroup struct and add them to the corresponding objects based on their binding types. Also store them in a inputsBindings array to facilitate further access to struct.
Clones a BindGroup from a list of buffers Useful to create a new bind group with already created buffers, but swapped
parameters used to clone the bind group
Optional
bindthe BindGroup to clone
Optional
bindings?: BindGroupBindingElement[]our input binding buffers
Optional
keepwhether we should keep original bind group layout or not
Get a corresponding BindGroup or TextureBindGroup from one of its binding name/key
the binding name/key to look for
Destroy a bind group, only if it is not used by another object
bind group to eventually destroy
Look for a binding by name in all input bindings
the binding name or key
Look for a buffer binding by name in all input bindings
the binding name or key
Force setting a given buffer binding shouldUpdate flag to true
to update it at next render
Optional
bufferBindingName: stringthe buffer binding name
Optional
bindingName: stringthe binding name
Prepare our textures array and set the TextureBindGroup
Add a texture to our array, and add it to the textures bind group only if used in the shaders (avoid binding useless data)
texture to add
Destroy a DOMTexture or Texture, only if it is not used by another object or cached.
DOMTexture or Texture to eventually destroy
Add a sampler to our array, and add it to the textures bind group only if used in the shaders (avoid binding useless data)
sampler to add
Map a Buffer's GPU buffer and put a copy of the data into a Float32Array
Map the content of a BufferBinding GPU buffer and put a copy of the data into a Float32Array
The name of the input bindings from which to map the GPU buffer
Map the content of a specific buffer element belonging to a BufferBinding GPU buffer and put a copy of the data into a Float32Array
parameters used to get the result
The name of the input bindings from which to map the GPU buffer
The name of the buffer element from which to extract the data afterwards
Called before rendering the Material. First, check if we need to create our bind groups or pipeline Then render the domTextures Finally updates all the bind groups
Set the current pipeline
current pass encoder
Use the renderer pipelineManager to only set the bind groups that are not already set.
current pass encoder
Render the material if it is ready: Set the current pipeline and set the bind groups
current pass encoder
Set or reset this RenderMaterial renderer. Will also update the renderer camera bind group if needed.
New Renderer or GPUCurtains instance to use.
Set (or reset) the current pipelineEntry. Use the renderer pipelineManager to check whether we can get an already created RenderPipelineEntry from cache or if we should create a new one.
Compile the RenderPipelineEntry
Check if attributes and all bind groups are ready, create them if needed, set RenderPipelineEntry bind group buffers and compile the pipeline.
Set or reset one of the rendering options. Should be use with great caution, because if the render pipeline has already been compiled, it can cause a pipeline flush.
new rendering options properties to be set
Compute geometry if needed and get all useful geometry properties needed to create attributes buffers
the geometry to draw
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.