Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/glsl-directional-light
A reusable GLSL directional light function
https://github.com/hughsk/glsl-directional-light
Last synced: about 2 months ago
JSON representation
A reusable GLSL directional light function
- Host: GitHub
- URL: https://github.com/hughsk/glsl-directional-light
- Owner: hughsk
- License: mit
- Created: 2014-04-27T18:09:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-04-27T18:16:02.000Z (over 10 years ago)
- Last Synced: 2024-04-24T00:43:53.145Z (5 months ago)
- Language: C
- Homepage: http://hughsk.github.io/glsl-directional-light
- Size: 262 KB
- Stars: 13
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# glsl-directional-light [![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #
A reusable GLSL directional light function.
The simplest case is to simply use:
``` glsl
dot(normal, direction) * light
```But this module also takes into account specualrity as well.
[view demo](http://hughsk.io/glsl-directional-light)
[![glsl-directional-light](http://imgur.com/vbOZta5.png)](http://hughsk.io/glsl-directional-light)
## Usage ##
[![glsl-directional-light](https://nodei.co/npm/glsl-directional-light.png?mini=true)](https://nodei.co/npm/glsl-directional-light)
Exports `vec3 directional_light()`, which takes the following arguments:
* `vec3 normal`: This point's normal vector.
* `vec3 light`: The light color.
* `vec3 surface`: The color of the material/surface being drawn.
* `vec3 lightDirection`: The direction of the light to cast – normalized.
* `mat4 modelMatrix`: The model matrix.
* `mat4 viewMatrix`: The view matrix.
* `vec3 viewPosition`: The position of the camera in world space.If you wish to include specular lighting too, simply add these two extra
parameters when calling the function:* `float shininess`: Set to lower values for matte, higher for gloss.
* `float specularity`: The amount by which to scale the specular light cast on
the object.## License ##
MIT. See [LICENSE.md](http://github.com/hughsk/glsl-directional-light/blob/master/LICENSE.md) for details.