Skip to content

wwwtyro/regl-irradiance-envmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

regl-irradiance-envmap

Easily generate an irradiance environment map from an existing environment map.

Demo

Install

npm install regl-irradiance-envmap

Usage

const createIrradianceRenderer = require("regl-irradiance-envmap");

const renderIrradiance = createIrradianceRenderer(regl);

const irradianceMap = renderIrradiance(envMap, opts);

createIrradianceRenderer takes a regl context as a parameter, and returns the function renderIrradiance.

renderIrradiance takes an envMap and opts parameter and returns a regl framebufferCube object that can be immediately used as a samplerCube in your shaders, or passed back into the renderIrradiance function to update it.

The envMap parameter is a regl framebufferCube or cube (cubemap) object that you provide.

The opts parameter is an object with the following (optional) members:

  • samples: The number of random samples to take for each pixel in the environment map, int, 128
  • diffusivity: How diffuse the sample rays are. 0.0 is perfectly reflective, 1.0 is perfectly diffusive, float, default 0.5
  • resolution: The resolution of each square face of the environment cubemap if cubeFBO is not provided, int, default 128
  • cubeFBO: The regl framebufferCube object that will be returned, default regl.framebufferCube(opts.resolution)

About

Easily generate an irradiance environment map from an existing environment map.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors