Skip to content

Commit

Permalink
adding scramblesuit for freeka
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemcdonald committed Nov 1, 2011
1 parent 410dd47 commit cc36204
Show file tree
Hide file tree
Showing 10 changed files with 1,574 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ScrambleSuit/Project.xcconfig
@@ -0,0 +1,9 @@
//THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
//THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
OF_PATH = ../../..

//THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
#include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"

OTHER_LDFLAGS = $(OF_CORE_LIBS)
HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) "../../../addons/ofxOpenCv/libs/opencv/include/"
1,081 changes: 1,081 additions & 0 deletions ScrambleSuit/ScrambleSuit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions ScrambleSuit/bin/data/BlurAlpha.frag
@@ -0,0 +1,21 @@
uniform sampler2DRect tex;
uniform vec2 direction;
uniform int k;

void main() {
vec2 st = gl_TexCoord[0].st;

float curWeight = float(k + 1);
float alpha = curWeight * texture2DRect(tex, st).a;
float count = curWeight;
for(int i = 0; i < k; i++) {
vec2 cur = float(i) * direction;
curWeight = float(k - i + 1); // linear dropoff blur
alpha += curWeight * (texture2DRect(tex, st + cur).a + texture2DRect(tex, st - cur).a);
count += curWeight * 2.;
}

alpha /= count; // normalize blur
alpha = clamp((alpha * 2.) - 1., 0., 1.); // scale for inner edges only
gl_FragColor = vec4(texture2DRect(tex, st).rgb, alpha);
}
14 changes: 14 additions & 0 deletions ScrambleSuit/bin/data/Clone.frag
@@ -0,0 +1,14 @@
uniform sampler2DRect src, srcBlur, dstBlur;

void main() {
vec2 pos = gl_TexCoord[0].st;
vec4 srcColor = texture2DRect(src, pos);
vec4 srcColorBlur = texture2DRect(srcBlur, pos);
vec4 dstColorBlur = texture2DRect(dstBlur, pos);
if(srcColor.a == 1. && srcColorBlur.a == 1. && dstColorBlur.a == 1.) {
vec3 offset = (dstColorBlur.rgb - srcColorBlur.rgb);
gl_FragColor = vec4(srcColor.rgb + offset, 1.);
} else {
gl_FragColor = vec4(0.);
}
}
30 changes: 30 additions & 0 deletions ScrambleSuit/bin/data/MaskBlur.frag
@@ -0,0 +1,30 @@
uniform sampler2DRect tex, mask;
uniform vec2 direction;
uniform int k;

void main() {
vec2 pos = gl_TexCoord[0].st;
vec4 baseMask = texture2DRect(mask, pos);
if(baseMask.r == 1.) {
float curWeight = float(k);
vec4 sum = curWeight * texture2DRect(tex, pos);
float weights = curWeight;
for(int i = k; i > 0; i--) {
vec2 curOffset = float(i) * direction;
vec4 leftMask = texture2DRect(mask, pos - curOffset);
vec4 rightMask = texture2DRect(mask, pos + curOffset);
bool valid = leftMask.r == 1. && rightMask.r == 1.;
if(valid) {
curWeight = float(k - i + 1); // linear dropoff blur
vec4 curTex =
texture2DRect(tex, pos + curOffset) +
texture2DRect(tex, pos - curOffset);
sum += curWeight * curTex;
weights += 2. * curWeight;
}
}
gl_FragColor = sum / weights;
} else {
gl_FragColor = vec4(0.);
}
}
41 changes: 41 additions & 0 deletions ScrambleSuit/bin/data/Voronoi.frag
@@ -0,0 +1,41 @@
uniform sampler2DRect points;
uniform int count;
const float zoom = 2.;
const float sharpness = 20.;
const float eps = 1.;

uniform sampler2DRect tex0, tex1, tex2, tex3, tex4;

vec2 getPoint(int i) {
// need .5 offset to lookup the middle of the bin
vec2 st = vec2(.5 + float(i), 0.);
return texture2DRect(points, st).st;
}

void main(void) {
vec2 st = gl_TexCoord[0].st;
st = (st - .5) / zoom + .5;

float d0 = length(getPoint(0) - st);
float d1 = length(getPoint(1) - st);
float d2 = length(getPoint(2) - st);
float d3 = length(getPoint(3) - st);
float d4 = length(getPoint(4) - st);

d0 = pow(eps / d0, sharpness);
d1 = pow(eps / d1, sharpness);
d2 = pow(eps / d2, sharpness);
d3 = pow(eps / d3, sharpness);
d4 = pow(eps / d4, sharpness);

vec2 facest = gl_TexCoord[0].st * 256.;
gl_FragColor =
d0 * texture2DRect(tex0, facest) +
d1 * texture2DRect(tex1, facest) +
d2 * texture2DRect(tex2, facest) +
d3 * texture2DRect(tex3, facest) +
d4 * texture2DRect(tex4, facest);

float sum = d0 + d1 + d2 + d3 + d4;
gl_FragColor /= sum;
}
20 changes: 20 additions & 0 deletions ScrambleSuit/openFrameworks-Info.plist
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.openFrameworks</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
8 changes: 8 additions & 0 deletions ScrambleSuit/src/main.cpp
@@ -0,0 +1,8 @@
#include "testApp.h"
#include "ofAppGlutWindow.h"

int main() {
ofAppGlutWindow window;
ofSetupOpenGL(&window, 1280, 720, OF_WINDOW);
ofRunApp(new testApp());
}

0 comments on commit cc36204

Please sign in to comment.