# glsl-light

> GLSL struct for a light source

Latest version **2.0.0** (published 2016-03-12) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2016-03-12 |
| First published | 2016-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | freeman-lab |
| Maintainers | freeman-lab |
| Keywords | glsl, light, webgl, glslify |

## Links

- npm: https://www.npmjs.com/package/glsl-light
- Repository: https://github.com/freeman-lab/glsl-light
- Homepage: https://github.com/freeman-lab/glsl-light#readme
- Issues: https://github.com/freeman-lab/glsl-light/issues
- npm.io page: https://npm.io/package/glsl-light

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2016-03-12
- 1.0.1 — 2016-03-09

## README

# glsl-light

GLSL struct for a light source. Designed for use as a shader component with [`glslify`](https://github.com/stackgl/glslify).

## install

To make avaialble in your project

```javascript
npm install glsl-light --save
```

## example

Define a light in your shader

```glsl
pragma glslify: Light = require('glsl-light')
uniform Light light;
```

Then set their properties on a `shader` created using `gl-shader`

```javascript
shader.uniforms.light = {
	position: [0.0, 0.0, 0.0, 1.0],
	color: [1.0, 0.0, 1.0],
	intensity: 1,
	radius: 20.0,
	ambient: 0.5,
	visible: false
}
```

## API

Inside your shader just declare the struct type with

```glsl
pragma glslify: SceneLight = require('glsl-light')
```

and use as you like, e.g. to set a `uniform` or construct a variable.

The attributes and types on the struct are

```javascript
position // vec4
color // vec3
intensity // float
radius // float
ambient // float
visible // bool
```

You can use these in your shader code however you want, but typically:
- `position` controls the position of the light, with the fourth element differentiating between a point or spot light (`0.0`) or a directional light (`1.0`) 
- `color` and `intensity` will together define the luminance, which can exceed 1.0
- `radius` controls the extent of the light
- `ambient` is the amount of ambient light associated with this light source
- `visible` is a flag to set the light on or off

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