PokéRogue
    Preparing search index...

    Class ShaderProgramFactory

    The ShaderProgramFactory is a utility class used to create and cache Phaser.Renderer.WebGL.Wrappers.WebGLProgramWrapper objects for the WebGL renderer. It assembles compiled shader programs from a base shader combined with optional additions and feature flags, then stores the result under a unique key so that the same combination is never compiled more than once. Use this class when you need to obtain a shader program that may vary at runtime based on renderer capabilities or pipeline configuration.

    Index
    programs: object

    A map of shader programs, identified by a unique key.

    The key of each shader program is made up of the following components:

    • The key of the base shader program.
    • The key of each shader addition, in addition order.
    • The key of each enabled shader feature, sorted alphabetically.
    renderer: WebGLRenderer

    The WebGLRenderer that owns this ShaderProgramFactory.

    • Creates a shader program based on the given configuration settings.

      Parameters

      • name: string

        The unique key of the shader program.

      • base: BaseShaderConfig

        The base shader configuration.

      • Optionaladditions: ShaderAdditionConfig[]

        An array of shader addition configurations.

      • Optionalfeatures: string[]

        An array of enabled shader feature keys.

      Returns WebGLProgramWrapper

      The newly compiled and cached shader program wrapper.

    • Returns a unique key for a shader program based on the given configuration settings.

      The key is made up of the following components:

      • The key of the base shader program.
      • The key of each shader addition, in addition order.
      • The key of each enabled shader feature, sorted alphabetically.

      Parameters

      • base: BaseShaderConfig

        The base shader configuration.

      • Optionaladditions: ShaderAdditionConfig[]

        An array of shader addition configurations.

      • Optionalfeatures: string[]

        An array of enabled shader feature keys.

      Returns string

      The unique cache key for this shader configuration.

    • Returns a compiled shader program for the given configuration. If a program matching the derived key already exists in the cache it is returned immediately; otherwise a new program is compiled, stored in the cache, and returned.

      Parameters

      • base: BaseShaderConfig

        The base shader configuration.

      • Optionaladditions: ShaderAdditionConfig[]

        An array of shader addition configurations.

      • Optionalfeatures: string[]

        An array of enabled shader feature keys.

      Returns WebGLProgramWrapper

      The compiled shader program wrapper.

    • Checks whether a compiled shader program with the given key already exists in the internal cache.

      Parameters

      • key: string

        The unique key of the shader program.

      Returns boolean

      true if a shader program with this key exists in the cache, otherwise false.