Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glsl-diffuse-oren-nayar

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glsl-diffuse-oren-nayar

Oren-Nayar diffuse lighting model

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26
increased by420%
Maintainers
1
Weekly downloads
 
Created
Source

glsl-diffuse-oren-nayar

The Oren-Nayar diffuse lighting model implemented in GLSL.

Example

#pragma glslify: orenNayar = require(glsl-diffuse-orenNayar)

uniform vec3 lightPosition, eyePosition;

varying vec3 surfacePosition, surfaceNormal;

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

  //Surface properties
  vec3 normal = normalize(surfaceNormal);
  
  //Compute diffuse light intensity
  float power = orenNayar(
    lightDirection,
    viewDirection, 
    normal,
    0.3,
    0.7);

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

Usage

Install with npm:

npm install glsl-diffuse-oren-nayar

Then use with glslify.

API

#pragma glslify: orenNayar = require(glsl-diffuse-oren-nayar)
float orenNayar(vec3 lightDir, vec3 viewDir, vec3 normal, float roughness, float albedo)

Computes the diffuse intensity in the Lambertian model

  • lightDir is a unit length vec3 pointing from the surface point toward the light
  • viewDir is a unit length vec3 pointing toward the camera
  • normal is the unit length surface normal at the sample point
  • roughness is a parameter between 0 and 1 measuring the surface roughness. 0 for smooth, 1 for matte
  • albedo measures the intensity of the diffuse reflection. Values >0.96 do not conserve energy

Returns A float representing the diffuse light intensity

License

(c) 2014 Mikola Lysenko. MIT License

Keywords

FAQs

Package last updated on 15 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc