Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Created January 13, 2017 01:40
Show Gist options
  • Save ayamflow/3189404c767facc6d8c74b79dac7ac88 to your computer and use it in GitHub Desktop.
Save ayamflow/3189404c767facc6d8c74b79dac7ac88 to your computer and use it in GitHub Desktop.
Spherical mapping
// from inear
http://www.inear.se/2011/09/set-a-sphere-on-fire-with-three-js/
float PI = 3.14159265;
float TWOPI = 6.28318531;
float BaseRadius = 1.0;
vec3 sphere( float u, float v) {
u *= PI;
v *= TWOPI;
vec3 pSphere;
pSphere.x = BaseRadius * cos(v) * sin(u);
pSphere.y = BaseRadius * sin(v) * sin(u);
pSphere.z = BaseRadius * cos(u);
return pSphere;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment