Moon Rendering

Ported parts of a previous OpenGL 3.3 project to WebGL. It should have been the whole solar system but I didn't feel like porting everything to this limited platform. So here is just the moon, with some nice textures.

You see a regular UV sphere with the diffuse texture from https://www.solarsystemscope.com/textures/.
On top a high resolution normal map from Guillermo Abramson at https://fisica.cab.cnea.gov.ar/estadistica/abramson/celestia/.

A directional light for lighting the scene.

Dithering in GLSL

vec3 dither(float x, float y, vec3 color)
{
	int bayer[64] = {
		 0, 48, 12, 60,  3, 51, 15, 63,
		32, 16, 44, 28, 35, 19, 47, 31,
		 8, 56,  4, 52, 11, 59,  7, 55,
		40, 24, 36, 20, 43, 27, 39, 23,
		 2, 50, 14, 62,  1, 49, 13, 61,
		34, 18, 46, 30, 33, 17, 45, 29,
		10, 58,  6, 54,  9, 57,  5, 53,
		42, 26, 38, 22, 41, 25, 37, 21 };

	int xx = int(mod(x, 8));
    int yy = int(mod(y, 8));
	int index = xx + yy * 8;

	float limit = bayer[index] / 64.0;
	
	vec3 newcolor = vec3(0.0, 0.0, 0.0);
	if(color.r > limit)
		newcolor.r = 1.0;
	if(color.g > limit)
		newcolor.g = 1.0;
	if(color.b > limit)
		newcolor.b = 1.0;
	return newcolor;
}

// Usage
outColor.rgb = dither(gl_FragCoord.x,
                      gl_FragCoord.y,
                      inputColor.rgb);
            

How to Timelapse with ffmpeg

Set your camera fully manual, this is important! That means aperture, exposure time, ISO, focus, white balance. You don't want your camera to adjust anything as post processing will be hell. Expose and focus how you see fit. If you expect dramatic changes in light, maybe over/underexpose a tiny bit to shift your dynamic range in between the expected light levels.

Mount the camera on a tripod, configure your intervalometer and start shooting. In post-processing be careful to apply the same settings to all photos or to interpolate between your keyframes. We don't want any sudden changes. Then export all the images, with the name containing a monotonic rising number: IMG_0001.jpeg, IMG_0002.jpeg, ...

Feed the image sequence to the timelapse tool of choice or use "ffmpeg" like real men (and woman). If the tool of your choice already is ffmpeg: well done, I am proud! The whole point of this text actually was to showcase ffmpeg. All other software is based on it anyways, so why not use the real thing in the first case?

On using ffmeg, for your convenience, some examples:

ffmpeg -r 25 -f image2 -start_number 2589 -i DSC%05d.jpg -s 1920x1080 -vcodec libx264 -crf 25 -pix_fmt yuv420p output.mp4
ffmpeg -r 25 -f image2 -start_number 3971 -i IMG_%04d.JPG -vf scale=-1:1080 -vcodec libx264 -crf 25 -pix_fmt yuv420p -profile:v main output.mp4
Both output a h264/mp4 video with 25fps, the second one even ensures it works on low-end and old smartphones.
First takes DSC02589.jpg - DSCXXXXX.jpg as source.
Second takes IMG_3971.jpg - IMG_XXXX.jpg as source.

About the arguments:

-r [1..X] Framerate
-f Input/Output Format
-s WxH Output Resolution - Method #1
-vf scale=WxH Output Resolution - Method #2
-start_number For the placeholder in -i
-vcodec Video Codec for the output
-crf Quality. Lower is better, but 15-25 is sane.
-pix_fmt Pixel Format for the output
-profile:v main For max. compatibility