Skip to content

Easily generate an environment map, or skybox, of Earth atmosphere given a 3D vector representing the direction of the sun.

License

Notifications You must be signed in to change notification settings

wwwtyro/regl-atmosphere-envmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

regl-atmosphere-envmap

Easily generate an environment map, or skybox, of Earth atmosphere given a 3D vector representing the direction of the sun.

Install

npm install regl-atmosphere-envmap

Usage

const createAtmosphereRenderer = require("regl-atmosphere-envmap");

const renderAtmosphere = createAtmosphereRenderer(regl);

const envMap = renderAtmosphere(opts);

createAtmosphereRenderer takes a regl context as a parameter, and returns the function renderAtmosphere.

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

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

  • sunDirection: the vector that points from the origin to the sun, 3D vector, default [0, 0.25, -1.0]
  • resolution: the resolution of each square face of the environment cubemap if cubeFBO is not provided, int, default 1024
  • cubeFBO: the regl framebufferCube object that will be returned, default regl.framebufferCube(opts.resolution)

About

Easily generate an environment map, or skybox, of Earth atmosphere given a 3D vector representing the direction of the sun.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published