This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decodingTable = new Uint8Array(256) | |
for c, i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | |
decodingTable[c.charCodeAt(0)] = i | |
base64decode = (string) -> | |
last = string[string.length-2...string.length] | |
if last == '==' | |
remainder = 2 | |
else if last[1] == '=' | |
remainder = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from struct import unpack | |
from zlib import decompress | |
class BufferStream: | |
def __init__(self, data): | |
self.pos = 0 | |
self.data = data | |
def get(self, amount): | |
result = self.data[self.pos:self.pos+amount] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maskEval = (src) -> | |
whitelist = ['Math', 'performance'] | |
names = [] | |
for name of window | |
if name not in whitelist | |
names.push name | |
names = names.join(',') | |
return eval("(function(){var #{names};return #{src};})").call({}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function countFiles { | |
for i in $(pwd)/* ; do | |
if [ -d "$i" ]; then | |
echo $(find $i -type f | wc -l) $i | |
fi | |
done | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## create backup of home! ## | |
## part 1 before reboot, update system ## | |
apt-get update | |
apt-get upgrade | |
shutdown -r now | |
## part 2 after first reboot install nvidia driver that works ## | |
apt-add-repository ppa:ubuntu-x-swat/x-updates | |
apt-get update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preprocess: (source) -> | |
lines = [] | |
result = [] | |
filename = 'no file' | |
lineno = 1 | |
for line in source.split('\n') | |
match = line.match /#line (\d+) (.*)/ | |
if match | |
lineno = parseInt(match[1], 10)+1 | |
filename = match[2] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec2 pack16(float value){ | |
float f = clamp(value, 0.0, 1.0)*255.0; | |
float digitLow = fract(f); | |
float digitHigh = floor(f)/255.0; | |
return vec2(digitHigh, digitLow); | |
} | |
float unpack16(vec2 value){ | |
return value.x+value.y/255.0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float checkerSphere(){ | |
vec3 normal = normalize(vNormal); | |
float c = (acos(normal.y)/PI)*20.0; | |
float dc = fwidth(c); | |
c = mod(c, 2.0); | |
c = smoothstep(0.5-dc, 0.5+dc, c) - smoothstep(1.5-dc, 1.5+dc, c); | |
vec2 dir = normalize(normal.xz); | |
float t = (atan(dir.x, dir.y)/TAU)*40.0; | |
float dt = fwidth(t); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float lambertNDF(vec3 normal, vec3 dir, float roughness){ | |
float exponent = getLambertExponent(roughness*PI*0.5); | |
float lambert = max(0.0, dot(normal, dir)); | |
return pow(lambert, exponent); | |
} | |
float ggxNDF(vec3 normal, vec3 dir, float roughness){ | |
float a = roughness*roughness; | |
float d = max(0.000001, dot(normal, dir)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec3 shade(vec3 color, float roughness, float metallness){ | |
float fresnelFactor = 0.93; | |
float specularFactor = 0.65; | |
vec3 normal = normalize(vNormal); | |
vec3 eyeDir = getEyeDir(); | |
vec3 N = normal; | |
vec3 V = -eyeDir; | |
vec3 reflected = reflect(eyeDir, normal); |
OlderNewer