# glsl-token-transpile-300

> transpiles GLSL tokens from v100 to v300 es

Latest version **1.1.1** (published 2016-02-11) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install glsl-token-transpile-300
pnpm add glsl-token-transpile-300
yarn add glsl-token-transpile-300
bun add glsl-token-transpile-300
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2016-02-11 |
| First published | 2015-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | glsl, es, 300, webgl2, webgl, gl, stackgl, glslify, token, tokenize |

## Links

- npm: https://www.npmjs.com/package/glsl-token-transpile-300
- Repository: https://github.com/Jam3/glsl-token-transpile-300
- Issues: https://github.com/Jam3/glsl-token-transpile-300/issues
- npm.io page: https://npm.io/package/glsl-token-transpile-300

## Dependencies (2)

- [glsl-version-regex](https://npm.io/package/glsl-version-regex.md) ^1.0.0
- [glsl-token-inject-block](https://npm.io/package/glsl-token-inject-block.md) ^1.1.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2016-02-11
- 1.1.0 — 2016-02-11
- 1.0.3 — 2015-06-25
- 1.0.2 — 2015-06-25
- 1.0.1 — 2015-06-25
- 1.0.0 — 2015-06-25

## README

# glsl-token-transpile-300

[![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)

## RENAMED!

:warning:

This has been renamed to [glsl-100-to-300](http://github.com/Jam3/glsl-100-to-300/blob/).

---


Transpile GLSL source tokens from version `"100"` (WebGL1) to `"300 es"` (WebGL2).

## Example

Source:

```js
var transpile = require('glsl-token-transpile-300')
var tokenize = require('glsl-tokenizer')
var stringify = require('glsl-token-string')

var tokens = transpile.fragment(tokenize(inputShader))
console.log(stringify(tokens))
```

Input fragment shader:

```glsl
#version 100
varying vec2 vUv;
uniform sampler2D iChannel0;

void main() {
  vec4 fragColor = vec4(0.5);
  gl_FragColor = texture2D(iChannel0, vUv);
}
```

The resulting WebGL2 shader:

```glsl
#version 300 es
in vec2 vUv;
out vec4 fragColor_1;
uniform sampler2D iChannel0;

void main() {
  vec4 fragColor = vec4(0.5);
  fragColor_1 = texture(iChannel0, vUv);
}
```

## Usage

[![NPM](https://nodei.co/npm/glsl-token-transpile-300.png)](https://www.npmjs.com/package/glsl-token-transpile-300)

Operates on [GLSL tokens](https://www.npmjs.com/package/glsl-tokenizer), but ignoring `column`, `position` and `line`.

#### `transpile.vertex(tokens)`

Transpiles the `tokens` array from a vertex shader and modifies them in place, to allow the code to run in a WebGL2 context.

In this case, `varying` will be converted to `out`.

Returns the `tokens` array.

#### `transpile.fragment(tokens)`

Same as above, but handles fragment shaders, where `varying` will be converted to `in`.

## Limitations

Currently, if you have variable names that are using WebGL2 builtins, e.g. `texture` or `transpose`, your shader will not run.

## License

MIT, see [LICENSE.md](http://github.com/Jam3/glsl-token-transpile-300/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/glsl-token-transpile-300 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
