Skip to content

Instantly share code, notes, and snippets.

View mfirmin's full-sized avatar

Michael Firmin mfirmin

View GitHub Profile
@mfirmin
mfirmin / float16ToNumber.js
Last active February 22, 2024 09:56
Converting Float16 (stored as the bits of a Uint16) into a Javascript Number
// This function converts a Float16 stored as the bits of a Uint16 into a Javascript Number.
// Adapted from: https://gist.github.com/martinkallman/5049614
// input is a Uint16 (eg, new Uint16Array([value])[0])
function float16ToNumber(input) {
// Create a 32 bit DataView to store the input
const arr = new ArrayBuffer(4);
const dv = new DataView(arr);
// Set the Float16 into the last 16 bits of the dataview
@mfirmin
mfirmin / triangulate.py
Last active April 19, 2023 12:09
Batch Triangulation of .obj files with Blender
# This script triangulates each .obj file in the input directory
# using Blender's Python API (https://docs.blender.org/api/current/index.html)
# It assumes that that the input/ and output/ directories exist
# Run with `blender --background --python triangulate.py`
# Tested with Blender 2.81
# Note: Before running, make sure the default scene is empty by opening Blender,
# selecting and deleting everything (light, camera, & cube),
# and selecting File -> defaults -> Save startup file
@mfirmin
mfirmin / twitterize.sh
Created February 23, 2021 23:06
ffmpeg command to convert a video created with Kazam into a format twitter will allow you to upload
ffmpeg -y -i input_file.mp4 -c:v libx264 -c:a aac -strict experimental -tune fastdecode -pix_fmt yuv420p -b:a 192k -ar 48000 output_file.mp4
@mfirmin
mfirmin / GLSL-Noise.md
Created March 4, 2021 17:42 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@mfirmin
mfirmin / mp4ToGif.sh
Created March 24, 2021 22:57
mp4 to high quality gif
ffmpeg -i input.mp4 -vf "fps=10,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif