Skip to content

Instantly share code, notes, and snippets.

View .zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/mrange/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
View settings.json
{
"editor.fontSize": 40,
"editor.fontLigatures": false,
"editor.tabSize": 2,
"editor.renderWhitespace": "all",
"files.trimTrailingWhitespace": true,
"editor.codeLens": false,
"editor.rulers": [
40,
80,
@mrange
mrange / experiment.glsl
Last active Mar 21, 2021
experimenting
View experiment.glsl
#define RESOLUTION resolution
#define SCA(x) vec2(sin(x), cos(x))
#define PI pi
#define TAU tau
#define TIME time
#define TTIME (TAU*TIME)
#define RESOLUTION resolution
#define ROT(a) mat2(cos(a), sin(a), -sin(a), cos(a))
#define PSIN(a) (0.5+0.5*sin(a))
#define L2(x) dot(x, x)
@mrange
mrange / parser.fs
Last active Mar 18, 2021
F# simple and slow parser combinators
View parser.fs
// Inspired by: http://www.cs.nott.ac.uk/~pszgmh/monparsing.pdf
// A Parser is a function that given a string and an index into that string
// produces a parsed value and the index of the first unparsed character in the string
type Parser<'T> = P of (string -> int -> ('T*int) option)
module Parser =
open System
// Runs the parser on a string
View amiga1.glsl
#define TOLERANCE 0.0001
#define NORM_OFF 0.001
#define MAX_RAY_LENGTH 12.0
#define MAX_RAY_MARCHES 65
#define MAX_SHADOW_MARCHES 15
#define MAX_REFLECTIONS 5
#define PI 3.141592654
#define TAU (2.0*PI)
#define ROT(a) mat2(cos(a), sin(a), -sin(a), cos(a))
#define TIME iTime
View atari.glsl
// License CC0: Tribute to my old Atari
// That's where it started for me
#define TIME iTime
#define RESOLUTION iResolution
#define PI 3.141592654
#define TAU (2.0*PI)
#define L2(x) dot(x, x)
#define ROT(a) mat2(cos(a), sin(a), -sin(a), cos(a))
#define TTIME (TAU*TIME)
View atari.glsl
#define RESOLUTION resolution
#define PI 3.141592654
#define TAU (2.0*TAU)
// IQ's polynomial min
float pmin(float a, float b, float k) {
float h = clamp(0.5+0.5*(b-a)/k, 0.0, 1.0);
return mix(b, a, h) - k*h*(1.0-h);
}
View heart.glsl
#define RESOLUTION resolution
#define TIME time
#define PI 3.141592654
#define TAU (2.0*PI)
#define PSIN(x) (0.5+0.5*sin(x))
#define TTIME (TAU*TIME)
float pmin(float a, float b, float k) {
float h = clamp(0.5+0.5*(b-a)/k, 0.0, 1.0);
return mix(b, a, h) - k*h*(1.0-h);
@mrange
mrange / fractals.glsl
Created Feb 28, 2021
sunday fractals II
View fractals.glsl
// License CC0: Sunday Fractals 2
// Inspired by: http://www.fractalforums.com/new-theories-and-research/very-simple-formula-for-fractal-patterns/
// SABS from ollj
#define RESOLUTION resolution
#define TIME time
#define PI 3.141592654
#define TAU (2.0*PI)
#define LESS(a,b,c) mix(a,b,step(0.,c))
#define SABS(x,k) LESS((.5/(k))*(x)*(x)+(k)*.5,abs(x),abs(x)-(k))
View spacebase.glsl
// License CC0: Menger sponge space base
// Tweaking menger sponges revealed a space based hidden inside
#define TIME iTime
#define TOLERANCE 0.0001
#define MAX_RAY_LENGTH 9.0
#define HIT_SKY 1E6
#define MAX_RAY_MARCHES 100
#define LESS(a,b,c) mix(a,b,step(0.,c))
#define SABS(x,k) LESS((.5/(k))*(x)*(x)+(k)*.5,abs(x),abs(x)-(k))