Socket
Book a DemoInstallSign in
Socket

glsl-diffuse-lambert

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glsl-diffuse-lambert

Lambertian diffuse lighting for GLSL

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

glsl-diffuse-lambert

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

Example

#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.

API

#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

Keywords

glsl

FAQs

Package last updated on 12 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts