# glsl-diffuse-lambert

> Lambertian diffuse lighting for GLSL

Latest version **1.0.0** (published 2014-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install glsl-diffuse-lambert
pnpm add glsl-diffuse-lambert
yarn add glsl-diffuse-lambert
bun add glsl-diffuse-lambert
```

## 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 | 1.0.0 |
| Published | 2014-10-12 |
| First published | 2014-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | glsl, lambert, diffuse, lighting, glslify |

## Links

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

## Recent versions

- 1.0.0 (latest) — 2014-10-12

## README

# glsl-diffuse-lambert

A simple Lambertian diffuse lighting model (somewhat trivial, but included for completeness).

# Example

```glsl
#pragma glslify: lambert = require(glsl-diffuse-lambert)

uniform vec3 lightPosition;

varying vec3 surfacePosition, surfaceNormal;

void main() {
  //Light geometry
  vec3 lightDirection = normalize(lightPosition - surfacePosition);

  //Surface properties
  vec3 normal = normalize(surfaceNormal);
  
  //Compute diffuse light intensity
  float power = lambert(
    lightDirection, 
    normal);

  gl_FragColor = vec4(power,power,power,1.0);
}
```

# Usage

Install with npm:

```
npm install glsl-diffuse-lambert
```

Then use with [glslify](https://github.com/stackgl/glslify).

# API

```glsl
#pragma glslify: lambert = require(glsl-diffuse-lambert)
```

##### `float lambert(vec3 lightDir, vec3 normal)`
Computes the diffuse intensity in the Lambertian model

* `lightDir` is a *unit length* `vec3` pointing from the surface point toward the light
* `normal` is the *unit length* surface normal at the sample point

**Returns** A `float` representing the diffuse light intensity

# License
(c) 2014 Mikola Lysenko. MIT License

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