Skip to content

Instantly share code, notes, and snippets.

@aferriss
aferriss / levels.glsl
Created April 26, 2017 23:20
GLSL Photoshop Style Levels Adjustment
vec3 gammaCorrect(vec3 color, float gamma){
return pow(color, vec3(1.0/gamma));
}
vec3 levelRange(vec3 color, float minInput, float maxInput){
return min(max(color - vec3(minInput), vec3(0.0)) / (vec3(maxInput) - vec3(minInput)), vec3(1.0));
}
vec3 finalLevels(vec3 color, float minInput, float gamma, float maxInput){
return gammaCorrect(levelRange(color, minInput, maxInput), gamma);
@aferriss
aferriss / countdown.expression
Created March 23, 2018 20:41
Countdown timer expression in AE in minutes and secs
rate = -1;
clockStart = 420; // num seconds
function padZero(n){
if (n < 10) return "0" + n else return "" + n
}
clockTime = Math.max(clockStart + rate*(time - inPoint),0);
t = Math.floor(clockTime);
@aferriss
aferriss / loadVideo.js
Created July 25, 2018 20:06
Load a Video with Promise
module.exports = {
videos : function(asset){
return new Promise(function(resolve, reject){
var vElement = document.createElement('video');
vElement.autoplay = true;
vElement.muted = true;
vElement.loop = true;
vElement.playsinline = true;
vElement.playsInline = true;
I am attesting that this GitHub handle aferriss is linked to the Tezos account tz1fo8NbDccJmuKdoadh245XtnVfnSHMTDFf for tzprofiles
sig:edsigtYpnKj64qSuk7bJUn61YrwqVftRLHQzG9Zg1pcyTKpud7b5wzrDCaafgWYH9dGCCL2Ae2Bgj4piL32nWEm5ZnRWf5ZmQ2W
@aferriss
aferriss / gaussianblur.frag
Created July 30, 2020 16:10
Gaussian Blur
// gaussian blur filter modified from Filip S. at intel
// https://software.intel.com/en-us/blogs/2014/07/15/an-investigation-of-fast-real-time-gpu-based-image-blur-algorithms
// this function takes three parameters, the texture we want to blur, the uvs, and the texelSize
vec3 gaussianBlur( sampler2D t, vec2 texUV, vec2 stepSize ){
// a variable for our output
vec3 colOut = vec3( 0.0 );
// stepCount is 9 because we have 9 items in our array , const means that 9 will never change and is required loops in glsl
const int stepCount = 9;
@aferriss
aferriss / ffmpeg loop video
Last active July 3, 2020 23:55
ffmpeg loop video
for i in {1..60}; do printf "file '%s'\n" 128Mov2.mp4 >>list.txt; done
ffmpeg -f concat -i list.txt -c copy output.mp4
@aferriss
aferriss / envAnchor.h
Last active February 6, 2019 18:44
Env anchor struct
typedef struct {
ofVec3f position;
ofMatrix4x4 transform;
NSUUID * uuid;
AREnvironmentProbeAnchor * rawAnchor;
vector<ofTexture> environmentTextures;
// All corevideo objs cause crash
// vector<CVOpenGLESTextureRef> openglTextures;
}EnvironmentAnchorObject;
@aferriss
aferriss / encodeDecode.py
Created January 18, 2019 21:53
Encode an int to a normalized rgb value and back again.
base = 256
def encode(val):
r = val / (base * base)
g = (val / base) % base
b = val % base
return [float(r)/255.0, float(g)/255.0, float(b)/255.0]
def dot(K, L):
if len(K) != len(L):
return 0
@aferriss
aferriss / text.swift
Last active November 20, 2018 00:51
letters
var index = 0
var originalText = "Love"
var text = originalText
/// Letters is just an array of structs with information about character, fontSize, character width/height
var textPathLength = letters.map({$0.width}).reduce(0, +) /// The total length of my word before I start adding letters
while textPathLength.f < perimeter {
text += originalText[index]
@aferriss
aferriss / matrixAR.swift
Last active November 13, 2018 21:43
Matrix for AR
projectionMatrix = arCameraData.projectionMatrix
viewMatrix = arCameraData.viewMatrix
var floorDepthMap : [Float] = []
if let tempDepthMap = groundPlaneDepthMap {
floorDepthMap = tempDepthMap
}