• Create a shader from the supplied source code. Note that this function adds additional shader blocks to both vertex and fragment shaders, which allow the shader to use more features and compile on both WebGL and WebGPU. Specifically, these blocks are added, and should not be part of provided vsCode and fsCode: shader version, shader precision, commonly used extensions.


    • device: GraphicsDevice

      The graphics device.

    • vsCode: string

      The vertex shader code.

    • fsCode: string

      The fragment shader code.

    • uniqueName: string

      Unique name for the shader. If a shader with this name already exists, it will be returned instead of a new shader instance.

    • Optionalattributes: {}

      Object detailing the mapping of vertex shader attribute names to semantics SEMANTIC_*. This enables the engine to match vertex buffer data as inputs to the shader. Defaults to undefined, which generates the default attributes.

      • OptionaluseTransformFeedback: boolean | Record<string, string | boolean | string[]> = false

        Whether to use transform feedback. Defaults to false.

      • OptionalshaderDefinitionOptions: {
            fragmentOutputTypes: string | string[];
            useTransformFeedback: boolean;
        } = {}

        Additional options that will be added to the shader definition.

        • fragmentOutputTypes: string | string[]

          Fragment shader output types, which default to vec4. Passing a string will set the output type for all color attachments. Passing an array will set the output type for each color attachment.

        • useTransformFeedback: boolean

          Whether to use transform feedback. Defaults to false.

      Returns Shader

      The newly created shader.