Skip to content

Instantly share code, notes, and snippets.

Pieter Verhoeven SpineyPete

Block or report user

Report or block SpineyPete

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SpineyPete
SpineyPete / grid.styl
Last active Oct 6, 2019
Stylus Flexbox Grid System
View grid.styl
// -------
// Globals
// -------
pagewidth = 50rem
hgap = 1rem
vgap = 1rem
// ----------------
// Utlity Functions
@SpineyPete
SpineyPete / hemisphere_concentric.pde
Last active Mar 18, 2019
Concentric Hemisphere Point Generator (Processing 3 Sketch)
View hemisphere_concentric.pde
// Visualization of Shirley and Chui's Concentric Mapping
// projected onto a hemisphere -- e.g. for irradiance tracing.
// ===========================================================
// The amount of points is the square of this number
int POINTS_PER_AXIS = 16;
// Whether to generate a cosine or uniform covering
// of the hemisphere.
boolean COSINE_DISTRIBUTION = true;
@SpineyPete
SpineyPete / fibonacci.c
Created Jan 5, 2019
fibonacci number formula (untested)
View fibonacci.c
double fib(int n) {
const double sqrt5 = sqrt(5);
const double phi_a = (1 + sqrt5)/2;
const double phi_b = (1 - sqrt5)/2;
return (pow(phi_a, n) - pow(phi_b, n))/sqrt5;
}
@SpineyPete
SpineyPete / gist:0f2ae2bbfe7a222f01158c14a6279890
Created Dec 4, 2018
Adaptively Subdivided Fan (Processing 3.0)
View gist:0f2ae2bbfe7a222f01158c14a6279890
PVector clickPos = new PVector(0, 0);
PVector clickRadi = new PVector(100, 100);
void angler(
PVector arcPos, float arcRadi, float arcTurn, PVector arcDir,
float stepSize, boolean fixStep) {
float halfAngle = PI*arcTurn;
float totalAngle = TAU*arcTurn;
float totalSteps = totalAngle*arcRadi/stepSize;
View funkytype.js
// Makes text funky.
"use strict";
function funkyType(selector, args) {
function limitDecimals(n, decimals) {
decimals = Math.pow(10, decimals);
return Math.trunc(n * decimals) / decimals;
}
View srgb_gamma.glsl
// sRGB to/from linear-space conversions, by Ian Taylor
// source: http://chilliant.blogspot.be/2012/08/srgb-approximations-for-hlsl.html
// Alternate LinearToGamma(), without pow():
// srgb = 0.585122381 * sqrt(linear) +
// 0.783140355 * sqrt(sqrt(linear)) -
// 0.368262736 * sqrt(sqrt(sqrt(linear)));
vec3 LinearToGamma(in vec3 linear) {
return max(1.055f * pow3(linear, 0.416666667f) - 0.055f, 0);
View hdr_crosstalk.glsl
// Crosstalk makes HDR highlights tend towards white.
// This is more realistic and maintains definition in overexposed areas.
// --
// Threshold is the point at which the desaturation kicks in.
// Shallowness is the rate at which the color reaches pure white.
// Higher Shallowness values create a slower rise.
vec3 Crosstalk(vec3 color, float threshold, float shallowness) {
// Luminosity
float luma = color.r * 0.299 + color.g * 0.587 + color.b * 0.114;
View phong_metal.glsl
float PhongBase(vec3 viewdir, vec3 lightdir, vec3 normal) {
return max(-dot(viewdir, reflect(lightdir, normal)), 0.0);
}
// Analytic specular without ambient specular might look better like this.
float HalfPhongBase(vec3 viewdir, vec3 lightdir, vec3 normal) {
return -dot(viewdir, reflect(lightdir, normal)) / 2 + 0.5;
}
// Something to approximate the longer tail
@SpineyPete
SpineyPete / colorspaces.glsl
Last active Jun 9, 2017
Colorspace Conversions
View colorspaces.glsl
#version 330
// Colorspace conversions, I haven't checked the validity of this stuff.
// Some of them cause discolorations when transformed to and back so I'm
// probably doing wrong things that I don't understand -- Caveat emptor.
// CIELab XYZ
// ----------
// Matrices borrowed from Fundamentals Of Computer Graphics (3rd edition).
View tonemappers.glsl
#version 330
// Tonemapping
// -----------
// Some of these are attributed to certain games.
// But this is mostly secondhand info, so take it with a grain of salt.
vec3 Tonemap_Reinhard(vec3 x) {
// Simplest Reinhard tonemapper.
You can’t perform that action at this time.