glFilters - v0.12.0
    Preparing search index...

    Function customShader

    • Create a filter from user-provided GLSL.

      The source is inserted as the body of main(). You have access to:

      • u_texture (sampler2D) — the input image
      • v_texCoord (vec2) — current texture coordinate
      • u_resolution (vec2) — image dimensions in pixels
      • u_texelSize (vec2) — 1.0 / u_resolution
      • any uniforms you declare via the uniforms parameter
      • any sampler2D uniforms you declare via the textures parameter

      Write your result to gl_FragColor.

      Example: customShader({ source: vec4 color = texture2D(u_texture, v_texCoord); gl_FragColor = vec4(color.r, 0.0, 0.0, color.a); , uniforms: {}, })

      Parameters

      • options: {
            source: string;
            textures?: Record<string, TextureUniformValue>;
            uniforms?: Record<string, number | number[]>;
        }

      Returns Filter