rhodonite
    Preparing search index...

    Class EndShader

    EndShader class provides the final output functions for both vertex and fragment shaders. This class handles the final position output in vertex shaders and color output in fragment shaders, supporting both WebGL and WebGPU rendering approaches.

    Hierarchy (View Summary)

    Index

    Properties

    __instance: EndShader
    materialElement: EnumIO = ShaderNode.PBRShading

    Accessors

    • get vertexShaderBody(): string

      Gets the vertex shader body code. Currently returns empty string as no additional vertex processing is needed.

      Returns string

      Empty shader body string

    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

    • Gets the pixel/fragment shader body code. Currently returns empty string as no additional fragment processing is needed.

      Returns string

      Empty shader body string

    • Gets the pixel/fragment shader function definitions for color output and discard. Returns appropriate function definition based on the current process approach (WebGL/WebGPU).

      Parameters

      Returns
          | "\n fn outColor(inColor: vec4<f32>) {\n rt0 = inColor;\n }\n "
          | "\n void outColor(in vec4 inColor) {\n rt0 = inColor;\n }\n "

      Shader code string containing the outColor and conditionalDiscard function definitions

    • Gets the vertex shader function definitions for position output. Returns appropriate function definition based on the current process approach (WebGL/WebGPU).

      Parameters

      Returns
          | "\n fn outPosition(inPosition: vec4<f32>) {\n output.position = inPosition;\n }\n "
          | "\n void outPosition(in vec4 inPosition) {\n gl_Position = inPosition;\n }\n "

      Shader code string containing the outPosition function definition