Skip to content

Instantly share code, notes, and snippets.

View Reedbeta's full-sized avatar

Nathan Reed Reedbeta

View GitHub Profile
@Reedbeta
Reedbeta / sierpinski.py
Created June 29, 2014 05:08
Sierpinski carpet generator in Python
# Sierpinski carpet generator, in Python using Numpy and Pillow.
# Written by Nathan Reed, June 2014.
# This code is released into the public domain.
import numpy as np
from PIL import Image
numLevels = 6
imageSize = 3**numLevels
@Reedbeta
Reedbeta / hobbit.txt
Last active December 10, 2015 10:59
Hobbit review
I went to see the Hobbit in HFR 3D IMAX OMGWTF today. Movie verdict: 3 hours is too long to sit in
the theater. It's not necessarily too long for home viewing where you can get up and move around,
or pause the movie and take a break, but it's too long for the theater. That said, it's a well-made
film and PJ keeps the story moving along, so you'll be entertained, even if your eyes and butt are
sore as hell by the end of it!
Stereo 3D verdict: yep, I still hate it. Kill it with fire. Especially the parts where they flick
stuff at your face - it's such a stupid, cheap trick.
HFR verdict: really interesting experience. The picture is great - very clear and smooth and BRIGHT
if (FAILED(D3D11CreateDevice(
NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
#if _DEBUG
D3D11_CREATE_DEVICE_DEBUG,
#else
0,
#endif
NULL,
@Reedbeta
Reedbeta / gist:5794189
Last active December 18, 2015 13:59
Beckmann HLSL test
float beckmann1(float m : M, float NdotH : NDOTH) : SV_Target0
{
float oneOverMSquared = 1.0 / (m*m);
float NdotHSquared = NdotH * NdotH;
return exp((NdotHSquared - 1.0) / NdotHSquared * oneOverMSquared) * oneOverMSquared * (1.0 / 3.141592654) / (NdotHSquared * NdotHSquared);
}
mad r0.x, v0.y, v0.y, l(-1.000000)
mul r0.yz, v0.xxyx, v0.xxyx
div r0.x, r0.x, r0.z
@Reedbeta
Reedbeta / letter-swapper.js
Created May 14, 2017 21:31
Letter swapper Greasemonkey script. Just for shits and giggles.
// ==UserScript==
// @name Letter Swapper
// @namespace reedbeta.com
// @version 1
// @grant none
// @include *
// @exclude https://*.google.com/*
// ==/UserScript==
var swaps =
<?php
/*************************************************************************************
* hlsl.php
* -----
* Author: Nick Darnell (NickDarnell@gmail.com)
* Copyright: (c) 2010 Nick Darnell (NickDarnell@gmail.com)
* Release Version: 1.0
* Date Started: 6/30/2010
*
* HLSL language file for GeSHi.
@Reedbeta
Reedbeta / srgb.glsl
Created August 3, 2018 16:52
Conversion between sRGB and linear color encoding
vec3 sRGBToLinear(vec3 rgb)
{
// See https://gamedev.stackexchange.com/questions/92015/optimized-linear-to-srgb-glsl
return mix(pow((rgb + 0.055) * (1.0 / 1.055), vec3(2.4)),
rgb * (1.0/12.92),
lessThanEqual(rgb, vec3(0.04045)));
}
vec3 LinearToSRGB(vec3 rgb)
{
@Reedbeta
Reedbeta / comptr.h
Created February 8, 2018 20:29
Auto-releasing wrapper for COM pointers
// Auto-releasing wrapper for COM pointers
// Feel free to use this for whatever, I don't care
template <typename T>
struct comptr
{
T * p;
comptr(): p(nullptr) {}
comptr(T * other): p(other)
{ if (p) p->AddRef(); }
@Reedbeta
Reedbeta / antialias-test.py
Created July 25, 2014 06:03
Antialiasing test program
# Tests for antialiasing a high-frequency image in various ways
# Nathan Reed, July 2014
# Written for Python 3.4; requires numpy and Pillow to be installed
import concurrent.futures
import math
import multiprocessing
import numpy as np
import optparse
import random
#pragma once
// Intrusive Linked List (or Internal Linked List, etc)
// by Nathan Reed, 2020-01-18. Licensed CC0 https://creativecommons.org/publicdomain/zero/1.0/
//
// Use it like:
//
// class MyClass
// {
// ...