rhodonite
    Preparing search index...

    Class Texture2DShader

    Base class that provides common shader functionality for both WebGL and WebGPU rendering approaches. This class handles shader code generation, vertex/fragment shader prerequisites, and cross-platform compatibility between WebGL and WebGPU shader languages (GLSL and WGSL).

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get attributeCompositions(): CompositionTypeEnum[]

      Gets the composition types for each vertex attribute used by this shader part. Subclasses should override this to define the data composition (scalar, vec2, vec3, etc.).

      Returns CompositionTypeEnum[]

      Array of composition type enums defining the data structure

    Methods

    • Generates variable assignment statement with proper type declaration. Creates appropriate syntax for both WebGL (GLSL) and WebGPU (WGSL) based on the current process approach.

      Parameters

      • engine: Engine

        The engine instance

      • varName: string

        The name of the variable to declare

      • inputSocket: Socket<string, CompositionTypeEnum, ComponentTypeEnum, SocketDefaultValue>

        The socket containing type and default value information

      Returns string

      The variable assignment statement string

    • Generates varying variable assignment statement for vertex shaders. Creates code to write varying variables that will be passed to fragment shader.

      Parameters

      • engine: Engine

        The engine instance

      • inputNode: AbstractShaderNode

        The shader node that provides the varying variable

      • varNames: string[]

        Array of variable names to assign

      • j: number

        Index of the current variable in the varNames array

      Returns string

      The varying variable assignment statement string for vertex shader

    • Generates the main function beginning code for vertex or fragment shaders. Handles differences between WebGL (GLSL) and WebGPU (WGSL) shader languages.

      Parameters

      • engine: Engine
      • isVertexStage: boolean

        True if generating code for vertex shader, false for fragment shader

      Returns string

      The shader code string for the main function beginning

    • Generates the main function ending code for vertex or fragment shaders. Handles differences between WebGL (GLSL) and WebGPU (WGSL) shader languages.

      Parameters

      • engine: Engine

        The engine instance

      • isVertexStage: boolean

        True if generating code for vertex shader, false for fragment shader

      Returns "\n return output;\n}\n" | "\n return rt0;\n}\n" | "\n}\n"

      The shader code string for the main function ending