Skip to content

Instantly share code, notes, and snippets.

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 / 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
}
@aferriss
aferriss / commonprofile.metal
Created October 9, 2018 19:02 — forked from j-j-m/commonprofile.metal
Can't access GL Uniforms in Metal shader modifier? Apple docs for SCNShadable written in terms of GL? Pulling your hair out?... this will help.
////////////////////////////////////////////////
// CommonProfile Shader v2
#import <metal_stdlib>
using namespace metal;
#ifndef __SCNMetalDefines__
#define __SCNMetalDefines__
@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;
@aferriss
aferriss / cover-contain-math.js
Created July 11, 2018 04:38
Cover and contain math functions
function cover(imgWidth, imgHeight, containerWidth, containerHeight){
let wRatio = containerWidth / imgWidth;
let hRatio = containerHeight / imgHeight;
let coverRatio = Math.max(wRatio, hRatio);
return [imgWidth * coverRatio, imgHeight * coverRatio];
}
function contain(imgWidth, imgHeight, containerWidth, containerHeight){
@aferriss
aferriss / filterExample.js
Created May 30, 2018 22:08
How to use wrap and filter funcs
let canvas;
let img;
function preload(){
img = loadImage("img.jpg");
}
function setup() {
// shaders require WEBGL mode to work
canvas = createCanvas(windowWidth, windowHeight, WEBGL);