Quickly get a spinning Earth-like planet on a black background in GLSL. This is not distance field rendering, just a 2D effect.
precision mediump float;
uniform float iGlobalTime;
uniform vec3 iResolution;
#pragma glslify: planet = require('glsl-earth')
void main() {
vec2 uv = gl_FragCoord.xy / iResolution.xy;
//the rotation
vec2 rot = vec2(iGlobalTime*0.03, iGlobalTime*0.01);
//% of screen
float size = 0.75;
//create our planet
vec3 color = planet(uv, iResolution.xy, size, rot);
gl_FragColor.rgb = color;
gl_FragColor.a = 1.0;
}
PRs welcome for improvements/optimizations.
Gets a planet based on the screen uv
and resolution
. The size
is how big the planet shoul be, where 1.0 fits the screen. rotation
is how much to rotate the planet.
The same as above but with no rotation.
The same as above but with no rotation and a default size of 1.0
MIT, see LICENSE.md for details.