Commit 59c2b960 authored by Lky's avatar Lky

big cleaning, part1

parent 8b005336
#version 150
// these are for the programmable pipeline system and are passed in
// by default from OpenFrameworks
uniform mat4 modelViewProjectionMatrix;
in vec4 position;
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;
out vec2 texCoord_ch3;
// this is coming from our C++ code
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
#version 150
// this is how we receive the texture
uniform sampler2DRect tex;
uniform sampler2DRect tex1;
uniform sampler2DRect tex2;
uniform sampler2DRect tex3;
uniform sampler2DRect tex4;
uniform sampler2DRect noise_texture;
//uniform sampler2DRect noise_texture;
uniform float main_opacity;
uniform float opBC_ch1;
......@@ -17,19 +16,16 @@ uniform float opBC_ch3;
uniform float key_value_threshold;
uniform int key_hue_threshold;
uniform int panel_width;
uniform int panel_height;
uniform int blendmode;
in vec2 brightContrast;
//in vec2 brightContrast;
in vec2 texCoordVarying;
in vec2 noiseTexCoord;
out vec4 outputColor;
// this is coming from our C++ code
uniform float mouseX;
uniform float mouseY;
//uniform float mouseX;
//uniform float mouseY;
/*
** Hue, saturation, luminance
......@@ -303,11 +299,11 @@ vec3 BlendColor(vec3 layer_1, vec3 layer_2, int blendmode) {
void main()
{
vec4 channel_1 = texture2DRect(tex1, texCoordVarying);
vec4 channel_1 = texture2DRect(tex1, vec2(texCoordVarying.x,texCoordVarying.y));
vec4 channel_2 = texture2DRect(tex2, vec2(texCoordVarying.x,texCoordVarying.y));
vec4 channel_3 = texture2DRect(tex3, texCoordVarying);
vec4 channel_4 = texture2DRect(tex4, noiseTexCoord);
//vec4 channel_4 = texture2DRect(tex4, noiseTexCoord);
float sin_val = opBC_ch1;
......@@ -316,7 +312,7 @@ void main()
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,1,1);
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);
......
......@@ -7,17 +7,17 @@ uniform mat4 modelViewProjectionMatrix;
in vec4 position;
in vec2 texcoord;
// this is something we're creating for this shader
out float brightContrast;
out vec2 texCo
out vec2 texCoordVarying;
// this is coming from our C++ code
uniform float mouseX;
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 = mouseX; //vec2(mouseX, mouseX);
texCoordVarying = vec2(texcoord.x, texcoord.y);
// send the vertices to the fragment shader
gl_Position = modelViewProjectionMatrix * position;
......
#include "kanava.h"
kanava::kanava()
{
}
kanava::~kanava()
{
}
void kanava::build(int w, int h, string path)
{
// ALLOCATIONS
hap_w = w; hap_h = h;
x_crop = 0; x_outside = 0;
inner_fbo.allocate(hap_w - x_crop, hap_h, GL_RGB);
outer_fbo.allocate(w, h, GL_RGB);
hap_video.load(path);
hap_video.play();
hap_video.setLoopState(OF_LOOP_NORMAL);
}
void kanava::update()
{
// first Fbo, for hap file
inner_fbo.begin();
ofClear(50, 0, 0);
hap_video.draw(x_crop, 0);
inner_fbo.end();
// second Fbo, to crop - build glitches
outer_fbo.begin();
ofClear(0, 50, 0);
inner_fbo.getTexture().drawSubsection(x_outside, 0, 1920, 1080, x_crop, 0); // Differentiate crop with or without glitches
outer_fbo.end();
}
void kanava::draw()
{
outer_fbo.draw(0, 0);
}
void kanava::setSpeed(float value)
{
speed = value;
if (speed != 0) {
hap_video.setSpeed(speed);
}
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) {
x_crop = 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
{
public:
kanava();
~kanava();
void build(int w = 1920, int h = 1080, string path = "rushes/fouquets.mov");
void update();
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;
private:
int number_of_channels;
ofFbo inner_fbo, outer_fbo;
ofxHapPlayer hap_video;
ofTexture texture;
int hap_w, hap_h;
float speed;
int opacity, contrast;
int x_crop, x_outside;
};
This diff is collapsed.
......@@ -3,6 +3,7 @@
#include "ofMain.h"
#include "ofxHapPlayer.h"
#include "ofxTextureRecorder.h"
#include "panel.h"
#include "ofxDatGui.h"
......@@ -23,48 +24,13 @@ public:
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);
ofxHapPlayer hap_ch1, hap_ch2, hap_ch3;
ofxHapPlayer hap_noise;
bool b_draw_stats;
bool b_draw_gui;
int framerate;
int actual_frame;
vector<string> video_names;
float potar_0, potar_1, potar_2, potar_4, potar_10, potar_11, potar_12, potar_14;
int count_1, count_2, count_3, count_4, count_5;
int opacity_1, opacity_2, opacity_3;
int blendmode;
ofTexture videoTexture;
int w, h;
int main_w, main_h;
//ofTexture * hapTexture;
ofxTextureRecorder recorder;
ofTexture grayTex;
ofPixels pixels;
unsigned char * gray;
ofFbo main_fbo;
ofFbo fbo_ch1, fbo_ch2, fbo_ch3, ofFbo_ch4;
ofFbo fbo_background, fbo_noise;
ofImage noise_img, background_image;
bool recording, playing_record;
int record_actual_frame;
vector<int> recorded_sequence;
ofPixels videoPixels;
ofImage testImg;
int testValue;
ofShader shader;
int key_hue; float key_value;
// ARDUINO SETUP
ofArduino ard;
......@@ -78,10 +44,10 @@ public:
};
void stateOfButton(buttonStruct *someButton);
float potar_0, potar_1, potar_2, potar_4, potar_10, potar_11, potar_12, potar_14;
int buttonNumber;
buttonStruct * list_of_buttons;
// INTERFACE
ofxDatGuiFolder* colorParameters_ch1;
......@@ -104,18 +70,8 @@ public:
void onTextInputEvent(ofxDatGuiTextInputEvent e);
ofTrueTypeFont font;
// 3-Panels Masks
int panelWidth, panelHeight;
float speed_ch1, speed_ch2, speed_ch3;
int factor_speed_ch1, factor_speed_ch2, factor_speed_ch3;
float main_opacity;
float opBC_ch1, opBC_ch2, opBC_ch3, extension_3channel;
string blendName;
// Setup for tests
int x_gl, x_main, x_ch1;
int x_sub, w_sub, sx_sub;
int w_fbo;
bool b_draw_stats;
bool b_draw_gui;
private:
......
#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