Skip to content

Instantly share code, notes, and snippets.

View sortofsleepy's full-sized avatar

Joe sortofsleepy

View GitHub Profile
// yMap is the Y texture, uvMap is the CrCb texture
vec4 capturedImageTextureY = texture2D(yMap, uv);
vec4 capturedImageTextureCbCr = texture2D(uvMap, uv);
mat4 transform = mat4(
1.0000, 1.0000, 1.0000, 0.0000,
0.0000, -0.3441, 1.7720, 0.0000,
1.4020, -0.7141, 0.0000, 0.0000,
-0.7010, 0.5291, -0.8860, 1.0000
);
// do this
vector<ARAnchor> mats;
for(int i = 0; i < session.currentFrame.anchors.count; ++i){
mats.push_back(session.currentFrame.anchors[i]);
}
// then access transforms from the "mats" variable.
// if you grab a transform from "mats", you shouldn't run into an out of bounds error because
@sortofsleepy
sortofsleepy / ofApp.cpp
Created April 21, 2018 10:22
Fullscreen quad + mesh scene testing
#include "ofApp.h"
//! vertex data to render the camera image
float kImagePlaneVertexData[8] = {
-1.0, -1.0,
1.0, -1.0,
-1.0, 1.0,
1.0, 1.0
};
float verts[16] = {
@sortofsleepy
sortofsleepy / Screen Shot 2018-06-27 at 4.04.41 PM.png
Last active June 27, 2018 23:19
oF borked project generator
Screen Shot 2018-06-27 at 4.04.41 PM.png
@sortofsleepy
sortofsleepy / test.cpp
Created March 26, 2019 18:49
Sample of how to call JS from Emscripten
#include <emscripten/bind.h>
using namespace emscripten;
// note - assuming you're including your own javascript
auto window = val::global("window");
// come up with a function to create a video element.
@sortofsleepy
sortofsleepy / snippits.glsl
Last active December 19, 2019 01:50
Useful glsl snippits
// Helps to scale image uvs to fit variable surfaces.
// Note - still need to test but sounds promising and basic idea appeared to work based on case study.
// adapted from description by @lhbzr
// https://tympanus.net/codrops/2019/12/18/case-study-portfolio-of-bruno-arizio/
vec2 scaleToFit(vec2 resolution,vec2 imageResolution){
vec2 ratio = vec2(
min((resolution.x / resolution.y) / (imageResolution.x / imageResolution.y), 1.0),
min((resolution.y / resolution.x) / (imageResolution.y / imageResolution.x), 1.0)
);
vec2 uv = gl_FragCoord.xy;
//uv = fragCoord.xy / iResolution.xy;
uv.y -= u_RenderSize.y / 2.0;
uv.x -= u_RenderSize.x / 2.0;
vec2 coords = uv;
vec4 color = vec4(1.0,1.0,0.0,1.0);
float radius = 20.0;
@sortofsleepy
sortofsleepy / array-setup.glsl
Last active September 30, 2019 22:47
Basic template for utilizing a texture as an array and setting it up with data at specific columns/rows
precision highp float;
// note - assuming OpenGL ES 2.0 - adjust as needed
// the number of items total you want to write out on each row
#define NUM 100
// the row of pixels to store, in this example positions
#define POSITION_ROW 2
@sortofsleepy
sortofsleepy / VIewController.h
Last active December 12, 2022 13:07
Basic setup of getting a Metal context up and running.
//
// ViewController.h
// metal.test
//
// Created by josephchow on 12/10/19.
// Copyright © 2019 josephchow. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Metal/Metal.h>
@sortofsleepy
sortofsleepy / main.cpp
Created January 11, 2020 16:57
How to initialize Cinder from main function instead of macro
int __stdcall WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/)\
{
HMODULE livepp = lpp::lppLoadAndRegister(L"../../../LivePP","project");
lpp::lppEnableAllCallingModulesSync(livepp);
lpp::lppInstallExceptionHandler(livepp);
cinder::app::RendererRef renderer(new ci::app::RendererGl);