# glsl-gamma

> gamma-to-linear convenience utilities

Latest version **2.0.0** (published 2015-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install glsl-gamma
pnpm add glsl-gamma
yarn add glsl-gamma
bun add glsl-gamma
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2015-05-17 |
| First published | 2015-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | ecosystem:stackgl, glsl, gamma, sRGB, correct, texture, linear, space |

## Links

- npm: https://www.npmjs.com/package/glsl-gamma
- Repository: https://github.com/stackgl/glsl-gamma
- Issues: https://github.com/stackgl/glsl-gamma/issues
- npm.io page: https://npm.io/package/glsl-gamma

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2015-05-17
- 1.0.2 — 2015-05-17
- 1.0.1 — 2015-05-17
- 1.0.0 — 2015-05-17

## README

# glsl-gamma

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

Convenience utilities for working in linear space when dealing with sRGB textures.

```glsl
#pragma glslify: toLinear = require('glsl-gamma/in')
#pragma glslify: toGamma  = require('glsl-gamma/out')

void main() {
  //sample into linear space
  vec4 color = toLinear(texture2D(uTexture, vUv));

  //do linear space transforms on RGB...

  //output to sRGB color buffer
  gl_FragColor = toGamma(color);
}
```

Currently all gamma operates on a `2.2` constant.

## Usage

[![NPM](https://nodei.co/npm/glsl-gamma.png)](https://nodei.co/npm/glsl-gamma/)

#### `toLinear = require('glsl-gamma/in')`
##### `genType = toLinear(genType color)`

Take a sRGB value and return its linear form. For `vec4`, the alpha component is left unchanged.

This is also the default export of `glsl-gamma`.

#### `toGamma = require('glsl-gamma/out')`
##### `genType = toGamma(genType color)`

Takes a linear value and return its gamma-corrected (sRGB) form. For `vec4`, the alpha component is left unchanged.

## License

MIT. See [LICENSE.md](http://github.com/stackgl/glsl-gamma/blob/master/LICENSE.md) for details.

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