Class ClassicShadingShader

A shader part that implements classic shading models including Lambert, Blinn-Phong, and Phong shading. This class provides GLSL shader code for traditional lighting calculations with support for multiple light types (directional, point, and spot lights) and different shading models.

The shader supports:

  • Lambert diffuse shading
  • Blinn-Phong specular shading
  • Phong specular shading
  • Multiple light sources with configurable intensity and direction
  • Point lights, directional lights, and spot lights

Hierarchy (view full)

Properties

__webglResourceRepository?: WebGLResourceRepository = ...
vertexShaderBody: string = ...

Gets the vertex shader body code. Currently returns an empty string as classic shading is performed in the fragment shader.

Empty string for vertex shader body

materialElement: EnumIO = ShaderNode.PBRShading

The material element type associated with this shader

Accessors

  • get pixelShaderBody(): string
  • Gets the pixel (fragment) shader body code. Currently returns an empty string as the main shading logic is defined in pixelShaderDefinitions.

    Returns string

    Empty string for pixel shader body

  • get pixelShaderDefinitions(): string
  • Gets the pixel (fragment) shader definitions including uniforms, structs, and the main shading function. Defines the classic shading function that supports multiple lighting models:

    • Model 0: No shading (returns diffuse color as-is)
    • Model 1: Lambert diffuse only
    • Model 2: Blinn-Phong (diffuse + specular using half-vector)
    • Model 3: Phong (diffuse + specular using reflection vector)

    Returns string

    GLSL code string containing shader definitions and the classicShading function

  • get vertexShaderDefinitions(): string
  • Gets the vertex shader definitions. Currently returns an empty string as classic shading calculations are performed in the fragment shader.

    Returns string

    Empty string for vertex shader definitions

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

    • 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

    • 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

    • 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

    • 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

  • Generates fragment/pixel shader prerequisites including definitions and varying variable declarations. Creates appropriate code for both WebGL (GLSL) and WebGPU (WGSL) based on the current process approach.

    Parameters

    • shaderNodes: AbstractShaderNode[]

      Array of shader nodes used to generate varying variables for WebGPU

    Returns string

    The complete fragment shader prerequisites code string

  • Generates vertex shader prerequisites including definitions, vertex inputs, and uniform declarations. Creates appropriate code for both WebGL (GLSL) and WebGPU (WGSL) based on the current process approach.

    Parameters

    • shaderNodes: AbstractShaderNode[]

      Array of shader nodes used to generate varying variables for WebGPU

    Returns string

    The complete vertex shader prerequisites code string