Commit 43941728 authored by Lky's avatar Lky

cleaning part 2. rebuilding interface

parent 59c2b960
#version 150
// this is how we receive the texture
uniform sampler2DRect tex;
uniform sampler2DRect tex1;
uniform sampler2DRect tex2;
uniform sampler2DRect tex3;
......@@ -9,9 +8,20 @@ uniform sampler2DRect tex3;
//uniform sampler2DRect noise_texture;
uniform float main_opacity;
uniform float opBC_ch1;
uniform float opBC_ch2;
uniform float opBC_ch3;
uniform float opacity_1;
uniform float contrast_1;
uniform float saturation_1;
uniform float scale_1;
uniform int x_pos_1;
uniform int y_pos_1;
uniform float opacity_2;
uniform float contrast_2;
uniform float saturation_2;
uniform float scale_2;
uniform int x_pos_2;
uniform int y_pos_2;
uniform float key_value_threshold;
uniform int key_hue_threshold;
......@@ -299,46 +309,48 @@ vec3 BlendColor(vec3 layer_1, vec3 layer_2, int blendmode) {
void main()
{
vec4 channel_1 = texture2DRect(tex1, vec2(texCoordVarying.x,texCoordVarying.y));
vec4 channel_2 = texture2DRect(tex2, vec2(texCoordVarying.x,texCoordVarying.y));
vec4 channel_1 = texture2DRect(tex1, vec2((texCoordVarying.x - x_pos_1) * scale_1, (texCoordVarying.y - y_pos_1) * scale_1));
vec4 channel_2 = texture2DRect(tex2, vec2((texCoordVarying.x - x_pos_2) * scale_2, (texCoordVarying.y - y_pos_2) * scale_2));
vec4 channel_3 = texture2DRect(tex3, texCoordVarying);
//vec4 channel_4 = texture2DRect(tex4, noiseTexCoord);
float sin_val = opBC_ch1;
float sin_val = opacity_1;
vec3 color;
vec3 color_layer_1, color_layer_2;
vec3 background_color = vec3(0,0,0);
color_layer_1 = mix(background_color, channel_1.rgb, opBC_ch1);
color_layer_1 = ContrastSaturationBrightness(color_layer_1,1,0,1);
color_layer_2 = mix(background_color, channel_2.rgb, opBC_ch2);
color_layer_2 = ContrastSaturationBrightness(color_layer_2,1,1,1);
color_layer_1 = mix(background_color, channel_1.rgb, opacity_1);
color_layer_1 = ContrastSaturationBrightness(color_layer_1,contrast_1,saturation_1,1);
color_layer_2 = mix(background_color, channel_2.rgb, opacity_2);
color_layer_2 = ContrastSaturationBrightness(color_layer_2,contrast_2,saturation_2,1);
// // UNCOMMENT TO GET THE THREE PANELS + HAND
// if (texCoordVarying.y/panel_height < 0.3) {
//
// color_layer_1 = ContrastSaturationBrightness(channel_1.rgb,1,1,1);
// 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_2,opBC_ch1);
// color_layer_2 = ContrastSaturationBrightness(channel_4.rgb,(opacity_1/2)+1,1,opacity_1/2);
// color_layer_2 = mix(vec3(0,0,0),color_layer_2,opacity_1);
//
// }
// else if (texCoordVarying.y/panel_height < 0.6) {
//
// color_layer_1 = ContrastSaturationBrightness(channel_2.rgb,1,1,1);
//
// 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_2,opBC_ch2);
// color_layer_2 = ContrastSaturationBrightness(channel_4.rgb,(opacity_2/2)+1,1,opacity_2/2);
// color_layer_2 = mix(vec3(0,0,0),color_layer_2,opacity_2);
//
// }
// else {
//
// color_layer_1 = ContrastSaturationBrightness(channel_3.rgb,1,1,1);
//
// 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_2,opBC_ch3);
// color_layer_2 = ContrastSaturationBrightness(channel_4.rgb,(opacity_3/2)+1,1,opacity_3/2);
// color_layer_2 = mix(vec3(0,0,0),color_layer_2,opacity_3);
// }
......
......@@ -54,17 +54,6 @@ void kanava::setSpeed(float value)
else if (speed == 0) {
hap_video.setPaused(true);
}
}
void kanava::setOpacity(int value)
{
opacity = value;
}
void kanava::setContrast(int value)
{
contrast = value;
}
void kanava::setInsideCrop(int value) {
......@@ -72,16 +61,6 @@ void kanava::setInsideCrop(int value) {
inner_fbo.allocate(hap_w - x_crop, hap_h, GL_RGB);
}
int kanava::getOpacity()
{
return opacity;
}
int kanava::getContrast()
{
return contrast;
}
ofTexture kanava::getTexture() {
return outer_fbo.getTexture();
}
#pragma once
#include "ofxHapPlayer.h"
#include "ofxTextureRecorder.h"
class kanava
{
......@@ -14,13 +13,8 @@ public:
void draw();
void setSpeed(float value);
void setOpacity(int value);
void setContrast(int value);
void setInsideCrop(int value);
int getOpacity();
int getContrast();
ofTexture getTexture();
int main_width, main_height;
......@@ -35,7 +29,6 @@ private:
int hap_w, hap_h;
float speed;
int opacity, contrast;
int x_crop, x_outside;
};
......
......@@ -3,18 +3,18 @@
#define WINDOWED
int main( )
int main()
{
ofGLWindowSettings settings;
ofGLWindowSettings settings;
#ifdef WINDOWED
settings.setSize(4096, 2160);
settings.setSize(4096, 2160);
settings.windowMode = OF_WINDOW; // OF_FULLSCREEN;//
#else
settings.windowMode = OF_FULLSCREEN;
#endif
settings.setGLVersion(4, 1);
ofCreateWindow(settings);
ofRunApp(new ofApp());
settings.setGLVersion(4, 1);
ofCreateWindow(settings);
ofRunApp(new ofApp());
}
This diff is collapsed.
#pragma once
#include "ofMain.h"
#include "ofxHapPlayer.h"
#include "ofxTextureRecorder.h"
#include "panel.h"
#include "kanava.h"
#include "ofxHapPlayer.h"
#include "ofxDatGui.h"
class ofApp : public ofBaseApp
......@@ -21,18 +20,10 @@ public:
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void windowResized(int w, int h);
void onButtonEvent(ofxDatGuiButtonEvent e);
void onSliderEvent(ofxDatGuiSliderEvent e);
panel main_console;
int flickering(int length_in, int length_out, int max_opacity=100, int min_opacity=0,int delay=0);
int framerate;
// ARDUINO SETUP
// ARDUINO
ofArduino ard;
bool bSetupArduino; // flag variable for setting up arduino once
......@@ -48,39 +39,44 @@ public:
int buttonNumber;
buttonStruct * list_of_buttons;
// INTERFACE
ofxDatGuiFolder* colorParameters_ch1;
ofParameter<int> brightness_ch1, saturation_ch1, contrast_ch1;
ofxDatGuiFolder* shift_ch1;
ofParameter<int> r_shift_ch1, g_shift_ch1, b_shift_ch1;
ofxDatGuiFolder* flickering_ch1;
ofParameter<int> length_in_ch1, length_out_ch1, max_opacity_ch1, min_opacity_ch1, delay_ch1;
ofParameter<bool> doFade_ch1;
ofxDatGuiFolder* geometry_ch1;
ofParameter<int> x_pos_ch1, y_pos_ch1, scale_ch1, rotation_ch1;
ofParameter<int> x_pos_ch2, y_pos_ch2, scale_ch2, rotation_ch2;
ofParameter<bool> doRandom_pos_ch1;
ofxDatGuiFolder* text_ch1;
ofxDatGuiTextInput* input_text;
void onTextInputEvent(ofxDatGuiTextInputEvent e);
ofTrueTypeFont font;
bool b_draw_stats;
bool b_draw_gui;
private:
void setupArduino(const int & version);
void digitalPinChanged(const int & pinNum);
void analogPinChanged(const int & pinNum);
void updateArduino();
string buttonState;
string potValue;
// DRAW
kanava * list_of_kanava;
int number_of_channels;
ofFbo main_fbo, fbo_frame;
int main_opacity;
int blendmode;
int key_hue; float key_value;
ofShader shader;
// INTERFACE
ofxDatGui* kanavaParameters;
struct KanavaFolder {
ofxDatGuiFolder* colorParameters;
ofxDatGuiFolder* autoAnimate;
ofParameter<int> opacity, saturation, contrast;
ofParameter<int> x_pos, y_pos, scale;
};
KanavaFolder * kanava_gui;
void changeInsideCrop(int channel, int value);
void onButtonEvent(ofxDatGuiButtonEvent e);
void onSliderEvent(ofxDatGuiSliderEvent e);
// ARDUINO
void setupArduino(const int & version);
void digitalPinChanged(const int & pinNum);
void analogPinChanged(const int & pinNum);
void updateArduino();
string buttonState;
string potValue;
};
#include "panel.h"
panel::panel()
{
setup();
}
panel::~panel()
{
}
void panel::setup(int channels_number)
{
ofSetVerticalSync(true); // to avoid tearing. Might make it false for glitches
shader.load("shadersGL4/shader");
main_fbo.allocate(1920, 1080, GL_RGB);
// fbo_frame is use for glitch lines
// :: has to be bigger than the kanava fbo.
fbo_frame.allocate(1920, 1080, GL_RGB);
fbo_frame.begin();
ofClear(0, 0, 0);
fbo_frame.end();
number_of_channels = channels_number;
string src = "rushes/fouquets.mov"; // main source for init
list_of_kanava = new kanava[number_of_channels];
for (int i = 0; i < number_of_channels; ++i) {
list_of_kanava[i].build(1280, 1080, src);
}
// BASIC PARAMETERS
blendmode = 0;
opBC_ch1 = 1; opBC_ch2 = 1; opBC_ch3 = 1;
speed_ch1 = 1; speed_ch2 = 1; speed_ch3 = 1;
main_opacity = 0.5;
key_hue = 120; key_value = 0.5;
}
void panel::update()
{
ofSetColor(255, 255, 255, 255);
for (int i = 0; i < number_of_channels; ++i) {
list_of_kanava[i].update();
}
}
void panel::draw()
{
// Basic info, written in the headbar
string windowName = ofToString(ofGetFrameRate()) + " - speeds: " + ofToString(speed_ch1) + "-" + ofToString(speed_ch2) + "-" + ofToString(speed_ch3);
ofSetWindowTitle(windowName);
// Setting up the main_fbo (shader)
main_fbo.begin();
ofClear(0, 0, 0);
shader.begin();
ofPushMatrix();
shader.setUniform1i("blendmode", blendmode);
shader.setUniform1f("main_opacity", main_opacity);
shader.setUniform1f("opBC_ch1", opBC_ch1);
shader.setUniform1f("opBC_ch2", opBC_ch2);
shader.setUniform1f("opBC_ch3", opBC_ch3);
shader.setUniform1i("key_hue_threshold", key_hue);
shader.setUniform1f("key_value_threshold", key_value);
// Manually done, for now
shader.setUniformTexture("tex1", list_of_kanava[0].getTexture(), 1);
shader.setUniformTexture("tex2", list_of_kanava[1].getTexture(), 2);
shader.setUniformTexture("tex3", list_of_kanava[1].getTexture(), 3);
// used for texcoord - independant from list of kanava
fbo_frame.draw(0,0);
ofPopMatrix();
shader.end();
main_fbo.end();
main_fbo.draw(0,0);
}
void panel::changeInsideCrop(int channel, int value)
{
if (channel < number_of_channels) {
list_of_kanava[channel].setInsideCrop(value);
}
else {
cout << "Invalid channel" << endl;
}
}
#pragma once
#include "ofxHapPlayer.h"
#include "ofxTextureRecorder.h"
#include "kanava.h"
class panel
{
public:
panel();
~panel();
void setup(int channels = 3);
void update();
void draw();
void changeInsideCrop(int channel, int value);
private:
kanava * list_of_kanava;
int number_of_channels;
ofFbo main_fbo, fbo_frame;
float opBC_ch1, opBC_ch2, opBC_ch3;
float speed_ch1, speed_ch2, speed_ch3;
float main_opacity;
int blendmode;
int key_hue; float key_value;
ofShader shader;
};
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