Skip to content

Instantly share code, notes, and snippets.

@briend
briend / Makefile
Created April 14, 2020 03:10 — forked from wakita/Makefile
Metal compute shader example
SDK = xcrun -sdk macosx
all: compute.metallib compute
compute.metallib: Compute.metal
# Metal intermediate representation (.air)
$(SDK) metal -c -Wall -Wextra -std=osx-metal2.0 -o /tmp/Compute.air $^
# Metal library (.metallib)
$(SDK) metallib -o $@ /tmp/Compute.air
@briend
briend / gist:bb7f0e56416a98e4cf49588f80d8012d
Last active September 24, 2018 14:20
bounce spectral
import colour
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
color = np.array((1.00, 0.95, 0.90))
_WGM_EPSILON = 0.0001
@briend
briend / mix_colors.py
Created September 1, 2018 05:38
mix spectral colors
#this outputs 4 horizontal gradients in this order:
#spectral weighted geometric mean
#spectral arithmetic mean (normal)
#RGB weighted geometric mean
#RGB normal
#The illuminant is not weighted properly so these are incredibly bright
#also Meng does not constrain to <=1.0 so many RGB values will violate energy conservation
#Curiously the results are better without adapting samples to E before Meng recovery, and using D65 illuminant
#I think Meng would be better if we could intentionally bake the illuminant into the reflectance; choose D65, etc.
@briend
briend / cairo_pyglet.py
Created March 8, 2018 22:22 — forked from stuaxo/cairo_pyglet.py
Render cairo on pyglet... modified from http://ethanmiller.name/
# Draw cairo in a pyglet window - without an intermediate image file.
import ctypes
#import cairocffi as cairo # example will work with cairocffi instead too
import cairo
import time
from pyglet import app, clock, font, gl, image, window
WIDTH, HEIGHT = 400, 400