@pixi/3d
    Preparing search index...

    Function createLightingBit

    • Advanced

      Builds a lighting ShaderBit around the shading math in opts

      Call it once at module scope and list the bit in a material's bitsGpu and bitsGl. CreateLightingBitOptions says what each snippet can read.

      Parameters

      Returns ShaderBit

      The composed lighting bit

      export const lambertLightingBit = createLightingBit({
      name: 'lambertLighting',

      preLighting: {
      gpu: 'var directLight = vec3<f32>(0.0);',
      gl: 'vec3 directLight = vec3(0.0);',
      },

      perLight: {
      gpu: 'directLight += albedo * light.color * nDotL * attenuation * shadow;',
      gl: 'directLight += albedo * light.color * nDotL * attenuation * shadow;',
      },

      postLighting: {
      gpu: 'finalColor = directLight;',
      gl: 'finalColor = directLight;',
      },
      });

      The PBR material's Cook-Torrance lighting and the toon material's toonLightingBit are built the same way.