Skip to content

Releases: CodyJasonBennett/shaderkit

v0.5.0

16 Feb 12:11
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.4.1...v0.5.0

v0.4.1

13 Feb 23:51
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.4.0...v0.4.1

v0.4.0

13 Feb 11:28
Compare
Choose a tag to compare

What's Changed

This release follows up v0.3.0 with a visitor API to recurse AST. Useful for reflecting or modifying a shader program.

import { type Program, parse, visit, generate } from 'shaderkit'

// https://github.com/CodyJasonBennett/shaderkit#ast
const program: Program = parse(glsl)

// optionally reflect program here (e.g. collect all global uniforms)
const uniforms: string[] = []
visit(program, {
  VariableDeclarator(node) {
    if (node.qualifiers.includes('uniform')) {
      uniforms.push(node.id.name)
    }
  },
})

// optionally modify program here (e.g. remove version header)
visit(program, {
  PreprocessorStatement(node, ancestors) {
    const parent = ancestors.at(-1)
    if (node.name === 'version' && parent?.type === 'Program') {
      parent.body.splice(parent.body.indexOf(node), 1)
    }
  },
})

// Compile back into GLSL
const output: string = generate(program, { target: 'GLSL' })

Full Changelog: v0.3.1...v0.4.0

v0.3.1

13 Feb 05:22
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.3.0...v0.3.1

v0.3.0

13 Feb 04:37
Compare
Choose a tag to compare

What's Changed

This release includes a rewrite to the AST parser and generator, with minor fixes to the tokenizer and minifier (note this will be rewritten once WGSL AST is implemented #21).

Both GLSL and WGSL are supported by the tokenizer and minifier, but only GLSL is supported so far by the parser and generator (#20).

This enables code modification and reflection of GLSL programs, although a visitor API does not yet exist, and AST nodes must be manually recursed.

import { type Program, parse, generate } from 'shaderkit'

// https://github.com/CodyJasonBennett/shaderkit#ast
const program: Program = parse(glsl)

// optionally reflect program here (e.g. collect all global uniforms)
const uniforms: string[] = []
for (const node of program.body) {
  if (node.type === 'VariableDeclaration') {
    for (const declaration of node.declarations) {
      if (declaration.qualifiers.includes('uniform') {
        uniforms.push(declaration.id.name)
      }
    }
  }
}

// optionally modify program here (e.g. remove version header)
if (program.body[0].type === 'PreprocessorStatement') program.body.shift()

// Compile back into GLSL
const output: string = generate(program, { target: 'GLSL' })

Full Changelog: v0.2.1...v0.3.0

v0.2.1

26 Dec 09:18
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.2.0...v0.2.1

v0.2.0

21 Nov 14:20
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.1.14...v0.2.0

v0.1.14

08 Nov 08:58
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.1.13...v0.1.14

v0.1.13

07 Nov 19:22
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.1.12...v0.1.13

v0.1.12

07 Nov 18:06
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.1.11...v0.1.12