Skip to content

Commit

Permalink
working on adding the animation shader…
Browse files Browse the repository at this point in the history
  • Loading branch information
CorpusCallosum committed Jan 4, 2014
1 parent 44cf7f3 commit 29a5962
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CloudsSecondaryDisplayController::CloudsSecondaryDisplayController(){
color = false;
stringCounter = 0;
tx = .1;
shader.load("shaders/animation");
}

void CloudsSecondaryDisplayController::setup(){
Expand Down Expand Up @@ -307,8 +308,12 @@ void CloudsSecondaryDisplayController::draw(){
//only draw speaker info if there is a speaker, duh
if(hasSpeaker){
//DRAW BIO LAYOUT, need to draw this first, text goes over it

//use shader to animate the alpha
//shader.begin();
//shader.setUniform1f("alphaAmt", tx);
bioLayout.draw();
//shader.end();


////speaker name
string firstName, lastName;
Expand Down Expand Up @@ -385,12 +390,10 @@ void CloudsSecondaryDisplayController::draw(){
string title = ofToUpper(currentExample.title);
hudLabelMap[meshProjectTitle->id]->draw();


////artist name
string name = currentExample.creatorName;
hudLabelMap[meshProjectArtist->id]->draw();


////project description
hudLabelMap[meshProjectDescription->id]->draw();

Expand All @@ -406,6 +409,10 @@ void CloudsSecondaryDisplayController::draw(){

}

void CloudsSecondaryDisplayController::reloadShader(){
shader.load("shaders/animation");
}

/*void CloudsSecondaryDisplayController::drawBioLayout(){
}*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CloudsSecondaryDisplayController {
void setup();
void update();
void drawOverlay();
void reloadShader();

void saveGuiSettings();
void toggleGuis();
Expand Down Expand Up @@ -70,7 +71,7 @@ class CloudsSecondaryDisplayController {

ofxOscReceiver receiver;

ofFbo displayTarget;
ofFbo displayTarget, gui;

float pFontSize, h3FontSize;

Expand Down Expand Up @@ -111,5 +112,9 @@ class CloudsSecondaryDisplayController {
map<string, CloudsHUDLabel*> hudLabelMap;

ofShader shader;

ofShader lineAnimate;



};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
185CE9B5184A5FC800F43977 /* ofxFTGLFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 185CE99F184A5FC800F43977 /* ofxFTGLFont.cpp */; };
185CE9B6184A5FC800F43977 /* ofxFTGLSimpleLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 185CE9A1184A5FC800F43977 /* ofxFTGLSimpleLayout.cpp */; };
235C96A91874F97E004523AB /* CloudsHUDLabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235C96A81874F97E004523AB /* CloudsHUDLabel.cpp */; };
235C96BB187784D9004523AB /* line_animate.frag in Sources */ = {isa = PBXBuildFile; fileRef = 235C96B9187784D9004523AB /* line_animate.frag */; };
235C96BC187784D9004523AB /* line_animate.vert in Sources */ = {isa = PBXBuildFile; fileRef = 235C96BA187784D9004523AB /* line_animate.vert */; };
BBAB23CB13894F3D00AA2426 /* GLUT.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = BBAB23BE13894E4700AA2426 /* GLUT.framework */; };
E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4328148138ABC890047C5CB /* openFrameworksDebug.a */; };
E45BE97B0E8CC7DD009D7055 /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9710E8CC7DD009D7055 /* AGL.framework */; };
Expand Down Expand Up @@ -198,6 +200,8 @@
185CE9A2184A5FC800F43977 /* ofxFTGLSimpleLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxFTGLSimpleLayout.h; sourceTree = "<group>"; };
235C96A71874F97E004523AB /* CloudsHUDLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CloudsHUDLabel.h; path = ../../RGBD/HUD/CloudsHUDLabel.h; sourceTree = "<group>"; };
235C96A81874F97E004523AB /* CloudsHUDLabel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CloudsHUDLabel.cpp; path = ../../RGBD/HUD/CloudsHUDLabel.cpp; sourceTree = "<group>"; };
235C96B9187784D9004523AB /* line_animate.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = line_animate.frag; path = ../../ShaderLineExample/bin/data/shaders/line_animate.frag; sourceTree = "<group>"; };
235C96BA187784D9004523AB /* line_animate.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = line_animate.vert; path = ../../ShaderLineExample/bin/data/shaders/line_animate.vert; sourceTree = "<group>"; };
BBAB23BE13894E4700AA2426 /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = ../../../libs/glut/lib/osx/GLUT.framework; sourceTree = "<group>"; };
E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = openFrameworksLib.xcodeproj; path = ../../../libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj; sourceTree = SOURCE_ROOT; };
E45BE9710E8CC7DD009D7055 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = "<absolute>"; };
Expand Down Expand Up @@ -662,6 +666,15 @@
path = src;
sourceTree = "<group>";
};
235C96B8187784CB004523AB /* shaders */ = {
isa = PBXGroup;
children = (
235C96B9187784D9004523AB /* line_animate.frag */,
235C96BA187784D9004523AB /* line_animate.vert */,
);
name = shaders;
sourceTree = "<group>";
};
BB4B014C10F69532006C3DED /* addons */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -750,6 +763,7 @@
E4B69E1C0A3A1BDC003C02F2 /* src */ = {
isa = PBXGroup;
children = (
235C96B8187784CB004523AB /* shaders */,
E4B69E1D0A3A1BDC003C02F2 /* main.cpp */,
E4B69E1F0A3A1BDC003C02F2 /* testApp.h */,
E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */,
Expand Down Expand Up @@ -1515,6 +1529,8 @@
/* Begin PBXProject section */
E4B69B4C0A3A1720003C02F2 /* Project object */ = {
isa = PBXProject;
attributes = {
};
buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "CloudsSecondaryDisplay" */;
compatibilityVersion = "Xcode 2.4";
developmentRegion = English;
Expand Down Expand Up @@ -1621,6 +1637,7 @@
E72446E116573AD000D70E01 /* ofxEasingQuad.cpp in Sources */,
E72446E216573AD000D70E01 /* ofxEasingQuart.cpp in Sources */,
E72446E316573AD000D70E01 /* ofxEasingQuint.cpp in Sources */,
235C96BC187784D9004523AB /* line_animate.vert in Sources */,
E72446E416573AD000D70E01 /* ofxEasingSine.cpp in Sources */,
E72446E516573AD000D70E01 /* ofxTween.cpp in Sources */,
E704D01417B3BB3600F77528 /* CloudsRGBDCamera.cpp in Sources */,
Expand Down Expand Up @@ -1677,6 +1694,7 @@
E70CDD5F1868D49200955691 /* ofxOscReceiver.cpp in Sources */,
E70CDD601868D49200955691 /* ofxOscSender.cpp in Sources */,
E70CEC7518696B5400955691 /* CloudsSecondaryDisplayController.cpp in Sources */,
235C96BB187784D9004523AB /* line_animate.frag in Sources */,
E7A4DC31186B6900002F5371 /* CloudsSVGMesh.cpp in Sources */,
E7FEFD5C1875F47D009533A7 /* ofxBillboard.cpp in Sources */,
);
Expand Down
20 changes: 20 additions & 0 deletions CloudsSecondaryDisplay/bin/data/shaders/animation.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//varying float alphaAmt = 0.5;


void main(){
//this is the fragment shader
//this is where the pixel level drawing happens
//gl_FragCoord gives us the x and y of the current pixel its drawing

//we grab the x and y and store them in an int
float xVal = gl_FragCoord.x;
float yVal = gl_FragCoord.y;

//we use the mod function to only draw pixels if they are every 2 in x or every 4 in y
//if( mod(xVal, 2.0) == 0.5 && mod(yVal, 4.0) == 0.5 ){
// gl_FragColor = gl_Color;
//}else{
gl_FragColor.a = .5;
//}

}
4 changes: 4 additions & 0 deletions CloudsSecondaryDisplay/bin/data/shaders/animation.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void main() {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
15 changes: 15 additions & 0 deletions CloudsSecondaryDisplay/bin/data/shaders/line_animate.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 120

uniform float percent;
varying float normPos;

float map(float value, float inputMin, float inputMax, float outputMin, float outputMax) {;
return ((value - inputMin) / (inputMax - inputMin) * (outputMax - outputMin) + outputMin);
}

void main() {
// if(percent < normPos){
// discard;
// }
gl_FragColor = vec4( vec3( 1.- map(normPos, percent-.01, percent+.01, 0., 1.0)) , 1.0);
}
16 changes: 16 additions & 0 deletions CloudsSecondaryDisplay/bin/data/shaders/line_animate.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@



uniform float percent;
varying float normPos;

void main(void)
{
vec4 pos = gl_Vertex;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * pos;
gl_FrontColor = gl_Color;

normPos = gl_Normal.x;


}
27 changes: 27 additions & 0 deletions CloudsSecondaryDisplay/bin/data/shaders/simpleBlurHorizontal.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
uniform sampler2DRect src_tex_unit0;
uniform float blurAmnt;

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

//horizontal blur
//from http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/

vec4 color;

color += 1.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * -4.0, 0.0));
color += 2.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * -3.0, 0.0));
color += 3.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * -2.0, 0.0));
color += 4.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * -1.0, 0.0));

color += 5.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt, 0));

color += 4.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * 1.0, 0.0));
color += 3.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * 2.0, 0.0));
color += 2.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * 3.0, 0.0));
color += 1.0 * texture2DRect(src_tex_unit0, st + vec2(blurAmnt * 4.0, 0.0));

color /= 25.0;
gl_FragColor = color;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void main() {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
27 changes: 27 additions & 0 deletions CloudsSecondaryDisplay/bin/data/shaders/simpleBlurVertical.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
uniform sampler2DRect src_tex_unit0;
uniform float blurAmnt;

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

//vertical blur
//from http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/

vec4 color;

color += 1.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * 4.0));
color += 2.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * 3.0));
color += 3.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * 2.0));
color += 4.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * 1.0));

color += 5.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt) );

color += 4.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * -1.0));
color += 3.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * -2.0));
color += 2.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * -3.0));
color += 1.0 * texture2DRect(src_tex_unit0, st + vec2(0.0, blurAmnt * -4.0));

color /= 25.0;
gl_FragColor = color;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void main() {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}
5 changes: 5 additions & 0 deletions CloudsSecondaryDisplay/src/testApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ void testApp::keyPressed(int key){
// cout << "SENT CLIP " << parser.getAllClips()[exampleIndex].getLinkName() << " WITH EXAMPLE " << parser.getAllClips()[exampleIndex].projectExampleTitle << endl;
}
}

if(key == 'R'){
//reload shader
secondaryDisplay.reloadShader();
}

}

Expand Down
6 changes: 4 additions & 2 deletions ShaderLineExample/emptyExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@
/* Begin PBXProject section */
E4B69B4C0A3A1720003C02F2 /* Project object */ = {
isa = PBXProject;
attributes = {
};
buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "emptyExample" */;
compatibilityVersion = "Xcode 2.4";
developmentRegion = English;
Expand Down Expand Up @@ -342,7 +344,7 @@
"-lpthread",
"-mtune=native",
);
SDKROOT = macosx;
SDKROOT = macosx10.8;
};
name = Debug;
};
Expand Down Expand Up @@ -376,7 +378,7 @@
"-lpthread",
"-mtune=native",
);
SDKROOT = macosx;
SDKROOT = macosx10.8;
};
name = Release;
};
Expand Down

0 comments on commit 29a5962

Please sign in to comment.