Commit d54445c2 authored by Lky's avatar Lky

update with last shaders

parent 1320886b
#version 150
// this is how we receive the texture
uniform sampler2DRect tex1;
uniform sampler2DRect tex2;
uniform sampler2DRect tex3;
uniform sampler2DRect tex4;
uniform sampler2DRect noise_texture;
uniform float main_opacity;
uniform float opBC_ch1;
uniform float opBC_ch2;
......@@ -17,6 +20,7 @@ uniform int blendmode;
in vec2 brightContrast;
in vec2 texCoordVarying;
in vec2 noiseTexCoord;
out vec4 outputColor;
......@@ -248,7 +252,8 @@ void main()
vec4 channel_1 = texture2DRect(tex1, texCoordVarying);
vec4 channel_2 = texture2DRect(tex2, vec2(texCoordVarying.x,texCoordVarying.y));
vec4 channel_3 = texture2DRect(tex3, texCoordVarying);
vec4 channel_4 = texture2DRect(tex4, texCoordVarying);
vec4 channel_4 = texture2DRect(tex4, noiseTexCoord);
float sin_val = opBC_ch1;
......@@ -258,28 +263,26 @@ void main()
if (texCoordVarying.y/panel_height < 0.3) {
color_layer_1 = ContrastSaturationBrightness(channel_1.rgb,1,1,1);
color_layer_1 = mix(vec3(0,0,0),color_layer_1,main_opacity);
//color_layer_1 = mix(vec3(0,0,0),color_layer_1,main_opacity);
color_layer_2 = ContrastSaturationBrightness(channel_4.rgb,(opBC_ch1/2)+1,1,opBC_ch1/2);
color_layer_2 = mix(vec3(0,0,0),color_layer_1,opBC_ch1);
color_layer_2 = mix(vec3(0,0,0),color_layer_2,opBC_ch1);
}
else if (texCoordVarying.y/panel_height < 0.6) {
color_layer_1 = ContrastSaturationBrightness(channel_2.rgb,1,1,1);
color_layer_1 = mix(vec3(0,0,0),color_layer_1,main_opacity);
color_layer_2 = ContrastSaturationBrightness(channel_4.rgb,(opBC_ch2/2)+1,1,opBC_ch2/2);
color_layer_2 = mix(vec3(0,0,0),color_layer_1,opBC_ch2);
color_layer_2 = mix(vec3(0,0,0),color_layer_2,opBC_ch2);
}
else {
color_layer_1 = ContrastSaturationBrightness(channel_3.rgb,1,1,1);
color_layer_1 = mix(vec3(0,0,0),color_layer_1,main_opacity);
color_layer_2 = ContrastSaturationBrightness(channel_4.rgb,(opBC_ch3/2)+1,1,opBC_ch3/2);
color_layer_2 = mix(vec3(0,0,0),color_layer_1,opBC_ch3);
color_layer_2 = mix(vec3(0,0,0),color_layer_2,opBC_ch3);
}
/*
......@@ -297,10 +300,17 @@ void main()
12 - burn 1 - (1 - a) / b
*/
color = BlendColor(color_layer_1,color_layer_2,blendmode);
if(blendmode == 0) {
color = mix(color_layer_1,color_layer_2,main_opacity);
} else {
//color_layer_1 = mix(color_layer_1,vec3(0,0,0),main_opacity*2);
//color_layer_1 = mix(vec3(0,0,0),color_layer_2,main_opacity*2);
color = BlendColor(color_layer_1,color_layer_2,blendmode);
//vec3 color_mix = mix(color_layer_1,color_layer_2,main_opacity);
}
//color = mix(vec3(1,0,0),vec3(0,0,1),sin_val);
// note:: CSB goes from effect to negative (if mouseX from 1 to -1).
outputColor = vec4(color,1); //channel_2.r);
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ in vec2 texcoord;
// this is something we're creating for this shader
out vec2 brightContrast;
out vec2 texCoordVarying;
out vec2 noiseTexCoord;
out vec2 texCoord_ch1;
out vec2 texCoord_ch2;
......@@ -19,13 +20,35 @@ out vec2 texCoord_ch3;
uniform float mouseX;
uniform float mouseY;
uniform sampler2DRect noise_texture;
float rand(vec2 n)
{
return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);
}
void main()
{
// here we move the texture coordinates
brightContrast = vec2(mouseX, mouseY);
texCoordVarying = vec2(texcoord.x, texcoord.y);
vec4 noise_variation = texture2DRect(noise_texture, texCoordVarying);
float r = noise_variation.x;
vec4 modifiedPosition = position;
// we need to scale up the values we get from the texture
float scale = 100;
// use the displacement we created from the texture data
// to modify the vertex position
//modifiedPosition.x += noise_variation.x * noise_variation.x * scale;
//modifiedPosition.y += noise_variation.y * noise_variation.y * scale;
modifiedPosition.xy += vec2(mouseX*scale,mouseY*scale);// noise_variation.x * noise_variation.y * scale;
noiseTexCoord.xy = texCoordVarying.xy - vec2(200 * mouseX - 200,800*mouseY);
// send the vertices to the fragment shader
gl_Position = modelViewProjectionMatrix * position;
}
\ No newline at end of file
#include "ofMain.h"
#include "ofApp.h"
#define WINDOWED_
int main( )
{
ofGLWindowSettings settings;
#ifdef WINDOWED
settings.setSize(4096, 2160);
settings.windowMode = OF_WINDOW; //OF_FULLSCREEN;//
settings.windowMode = OF_WINDOW; // OF_FULLSCREEN;//
#else
settings.windowMode = OF_FULLSCREEN;
#endif
settings.setGLVersion(4, 1);
ofCreateWindow(settings);
......
#include "ofApp.h"
#define INTERFACE_
#define ARDUINO_
#define WRITE_INFO
static int prev_frame = 0;
static bool db = false;
......@@ -27,12 +28,15 @@ void ofApp::setup()
fbo_ch1.allocate(main_w, main_h, GL_RGB);
fbo_ch2.allocate(main_w, main_h, GL_RGB);
fbo_ch3.allocate(main_w, main_h, GL_RGB);
fbo_noise.allocate(1080, 1080, GL_RGB);
gray = new unsigned char[w*h];
grayTex.allocate(w,h,GL_LUMINANCE);
recording = false;
record_actual_frame = 0;
playing_record = false;
noise_img.allocate(60, 20, OF_IMAGE_GRAYSCALE);
/*ofxTextureRecorder::Settings settings(main_fbo.getTexture());
settings.imageFormat = OF_IMAGE_FORMAT_JPEG;
......@@ -72,8 +76,8 @@ void ofApp::setup()
opacity_1 = 255; opacity_2 = 255; opacity_3 = 255;
extension_3channel = 100;
opBC_ch1 = 0; opBC_ch2 = 0; opBC_ch3 = 0;
main_opacity = 1;
opBC_ch1 = 1; opBC_ch2 = 1; opBC_ch3 = 1;
main_opacity = 0;
//// GETTING FILES NAMES
//ofDirectory dir;
......@@ -106,7 +110,13 @@ void ofApp::setup()
hap_ch3.play();
hap_ch3.setLoopState(OF_LOOP_NORMAL);
hap_noise.load("rushes/noise_1500_1080.mov");
hap_noise.play();
hap_noise.setSpeed(4);
hap_noise.setLoopState(OF_LOOP_NORMAL);
background_image.load(background_path);
font.load("fonts/Datalegreya-Thin.otf", 20);
#ifdef INTERFACE
// Adding all the interfacey
......@@ -192,6 +202,21 @@ void ofApp::update()
}*/
}
/*float noiseScale = ofMap(mouseX, 0, ofGetWidth(), 0, 0.1);
float noiseVel = ofGetElapsedTimef();
ofPixels & pixels = noise_img.getPixels();
int w = noise_img.getWidth();
int h = noise_img.getHeight();
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
int i = y * w + x;
float noiseVelue = ofNoise(x * noiseScale, y * noiseScale, noiseVel);
pixels[i] = 255 * noiseVelue;
}
}
noise_img.update();*/
ofSetColor(255, 255, 255, 255);
fbo_ch1.begin();
......@@ -209,9 +234,57 @@ void ofApp::update()
hap_ch3.draw(0, 0);
fbo_ch3.end();
fbo_noise.begin();
ofClear(0, 0, 0);
hap_noise.draw(0, 0, 3000,2160);
fbo_noise.end();
if(recording){
recorded_sequence.push_back((int)hap_ch1.getCurrentFrame());
}
switch (blendmode) {
case 0:
blendName = "superimposition";
break;
case 1:
blendName = "multiply";
break;
case 2:
blendName = "screen";
break;
case 3:
blendName = "darken";
break;
case 4:
blendName = "lighten";
break;
case 5:
blendName = "difference";
break;
case 6:
blendName = "negation";
break;
case 7:
blendName = "exclusion";
break;
case 8:
blendName = "overlay";
break;
case 9:
blendName = "hard light";
break;
case 10:
blendName = "soft light";
break;
case 11:
blendName = "dodge";
break;
case 12:
blendName = "burn";
break;
}
}
//--------------------------------------------------------------
......@@ -220,9 +293,11 @@ void ofApp::draw()
float sin_val = opBC_ch1;// sin(actual_frame * PI / 180);
string windowName = ofToString(ofGetFrameRate()) + " - speeds: "+ ofToString(speed_ch1) + "-"+ofToString(speed_ch2) + "-"+ ofToString(speed_ch3) + " : opBC: " + "-" + ofToString(opBC_ch1) + "-" + ofToString(opBC_ch2) + "-" + ofToString(opBC_ch3) + " - blendmode::" + ofToString(blendmode);
ofSetWindowTitle(windowName);/
ofSetWindowTitle(windowName);
ofBackground(0,0,0);
ofScale(1.3);
ofBackground(0,0,0);
ofSetColor(255,255,255);
main_fbo.begin();
......@@ -242,6 +317,9 @@ void ofApp::draw()
ofPushMatrix();
shader.setUniform1f("mouseX", 5*mouseX/ofGetHeight());
shader.setUniform1f("mouseY", 5*mouseY/ofGetWidth());
shader.setUniform1i("blendmode", blendmode);
shader.setUniform1f("main_opacity", main_opacity);
......@@ -257,6 +335,8 @@ void ofApp::draw()
shader.setUniformTexture("tex3", fbo_ch3.getTexture(), 3);
shader.setUniformTexture("tex4", background_image.getTexture(), 4);
shader.setUniformTexture("noise_texture", fbo_noise.getTexture(), 5);
fbo_ch3.draw(0,0);
......@@ -266,7 +346,10 @@ void ofApp::draw()
main_fbo.end();
extension_3channel = sin_val;
main_fbo.getTexture().drawSubsection(0, 0, ofGetWidth(), ofGetHeight(), -1000, 0);
main_fbo.getTexture().drawSubsection(0, 0, ofGetWidth(), 1500, -1000, 0);
//main_fbo.draw(800, 0, 1080*1, 1500*1.3);
//fbo_noise.draw(0, 0);
#ifdef INTERFACE
colorParameters_ch1->draw();
......@@ -280,6 +363,10 @@ void ofApp::draw()
ofSetColor(ofColor::black);
font.drawString(str, bounds.x-bounds.width/2, bounds.y-bounds.height/2);
#endif
#ifdef WRITE_INFO
font.drawString(ofToString(ofGetFrameRate()) + "\nspeeds: {" + ofToString(speed_ch1) + "," + ofToString(speed_ch2) + "," + ofToString(speed_ch3) + "}\nopBC: {" + ofToString(opBC_ch1) + "," + ofToString(opBC_ch2) + "," + ofToString(opBC_ch3) + "} \nblendmode::" + blendName + " \nmain_opacity::" + ofToString(main_opacity), 100, 100);
#endif
}
......@@ -366,7 +453,7 @@ void ofApp::keyPressed(int key){
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
ofHideCursor();
}
//--------------------------------------------------------------
......@@ -380,6 +467,7 @@ void ofApp::mouseDragged(int x, int y, int button)
void ofApp::mousePressed(int x, int y, int button)
{
ofVec2f mouse(x,y);
ofShowCursor();
}
......
......@@ -27,6 +27,7 @@ public:
int flickering(int length_in, int length_out, int max_opacity=100, int min_opacity=0,int delay=0);
ofxHapPlayer hap_ch1, hap_ch2, hap_ch3;
ofxHapPlayer hap_noise;
bool b_draw_stats;
bool b_draw_gui;
......@@ -49,8 +50,8 @@ public:
unsigned char * gray;
ofFbo main_fbo;
ofFbo fbo_ch1, fbo_ch2, fbo_ch3, ofFbo_ch4;
ofFbo fbo_background;
ofImage background_image;
ofFbo fbo_background, fbo_noise;
ofImage noise_img, background_image;
bool recording, playing_record;
int record_actual_frame;
......@@ -90,6 +91,7 @@ public:
float speed_ch1, speed_ch2, speed_ch3;
float main_opacity;
float opBC_ch1, opBC_ch2, opBC_ch3, extension_3channel;
string blendName;
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment