dacha
    Preparing search index...

    Class ShaderAbstract

    Base class for the shaders of the Mesh component.

    Extend it and name the class with DefineShader. Every method gets the material options of the mesh as options. A texture referenced by an asset field of the shader is loaded before the scene starts.

    Shaders

    Index
    assets: Assets

    The project assets.

    shaderName: string

    The name the configuration uses for the shader. DefineShader sets it, so a game usually does not assign it.

    • Runs when the renderer creates the shader. Returns the fragment shader code.

      Parameters

      • options: unknown

      Returns string

    • Runs every frame. When the returned string changes, the renderer creates the shader again. Optional.

      Parameters

      • name: string
      • options: unknown

      Returns string

    • Runs when the renderer creates the shader and every frame. Write your textures into textures, by the name of their sampler2D uniform. The keys written on the first call declare the textures of the shader, so write every key on every call. Optional.

      Parameters

      Returns void

      textures(textures: ShaderTextures, { mask }: MaskOptions) {
      textures.uMask = this.assets.get(Texture, mask)?.resource;
      }
    • Runs every frame. Write the new uniform values into uniforms. Optional.

      Parameters

      Returns void

    • Runs when the renderer creates the shader. Returns the vertex shader code.

      Parameters

      • options: unknown

      Returns string