...
 
Commits (4)
#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 float brightContrast;
out vec2 texCo
// this is coming from our C++ code
uniform float mouseX;
void main()
{
// here we move the texture coordinates
brightContrast = mouseX; //vec2(mouseX, mouseX);
// 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 tex1;
uniform sampler2DRect tex2;
uniform sampler2DRect tex3;
uniform sampler2DRect mask_tex1;
uniform sampler2DRect mask_tex2;
uniform sampler2DRect mask_tex3;
in vec2 brightContrast;
in vec2 texCoordVarying;
out vec4 outputColor;
/*
** Hue, saturation, luminance
*/
vec3 RGBToHSL(vec3 color)
{
vec3 hsl; // init to 0 to avoid warnings ? (and reverse if + remove first part)
float fmin = min(min(color.r, color.g), color.b); //Min. value of RGB
float fmax = max(max(color.r, color.g), color.b); //Max. value of RGB
float delta = fmax - fmin; //Delta RGB value
hsl.z = (fmax + fmin) / 2.0; // Luminance
if (delta == 0.0) //This is a gray, no chroma...
{
hsl.x = 0.0; // Hue
hsl.y = 0.0; // Saturation
}
else //Chromatic data...
{
if (hsl.z < 0.5)
hsl.y = delta / (fmax + fmin); // Saturation
else
hsl.y = delta / (2.0 - fmax - fmin); // Saturation
float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;
float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;
float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;
if (color.r == fmax )
hsl.x = deltaB - deltaG; // Hue
else if (color.g == fmax)
hsl.x = (1.0 / 3.0) + deltaR - deltaB; // Hue
else if (color.b == fmax)
hsl.x = (2.0 / 3.0) + deltaG - deltaR; // Hue
if (hsl.x < 0.0)
hsl.x += 1.0; // Hue
else if (hsl.x > 1.0)
hsl.x -= 1.0; // Hue
}
return hsl;
}
float HueToRGB(float f1, float f2, float hue)
{
if (hue < 0.0)
hue += 1.0;
else if (hue > 1.0)
hue -= 1.0;
float res;
if ((6.0 * hue) < 1.0)
res = f1 + (f2 - f1) * 6.0 * hue;
else if ((2.0 * hue) < 1.0)
res = f2;
else if ((3.0 * hue) < 2.0)
res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;
else
res = f1;
return res;
}
vec3 HSLToRGB(vec3 hsl)
{
vec3 rgb;
if (hsl.y == 0.0)
rgb = vec3(hsl.z); // Luminance
else
{
float f2;
if (hsl.z < 0.5)
f2 = hsl.z * (1.0 + hsl.y);
else
f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);
float f1 = 2.0 * hsl.z - f2;
rgb.r = HueToRGB(f1, f2, hsl.x + (1.0/3.0));
rgb.g = HueToRGB(f1, f2, hsl.x);
rgb.b= HueToRGB(f1, f2, hsl.x - (1.0/3.0));
}
return rgb;
}
/*
** Contrast, saturation, brightness
** Code of this function is from TGM's shader pack
** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057
*/
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con)
{
// Increase or decrease theese values to adjust r, g and b color channels seperately
const float AvgLumR = 0.5;
const float AvgLumG = 0.5;
const float AvgLumB = 0.5;
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
vec3 brtColor = color * brt;
vec3 intensity = vec3(dot(brtColor, LumCoeff));
vec3 satColor = mix(intensity, brtColor, sat);
vec3 conColor = mix(AvgLumin, satColor, con);
return conColor;
}
void main()
{
vec4 channel_1 = texture2DRect(tex1, texCoordVarying);
vec4 channel_2 = texture2DRect(tex2, texCoordVarying);
float r = channel_1.r;
float g = channel_1.g;
float b = channel_1.b;
vec3 color = ContrastSaturationBrightness(vec3(r,g,b),0.5,0,1);
// note:: CSB goes from effect to negative (if mouseX from 1 to -1).
outputColor = vec4(channel_1.rgb,1); //channel_2.r);
}
\ No newline at end of file
#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;
// this is coming from our C++ code
uniform float mouseX;
uniform float mouseY;
void main()
{
// here we move the texture coordinates
brightContrast = vec2(mouseX, mouseY);
texCoordVarying = vec2(texcoord.x, texcoord.y);
// send the vertices to the fragment shader
gl_Position = modelViewProjectionMatrix * position;
}
\ No newline at end of file
This diff is collapsed.
......@@ -4,6 +4,8 @@
#include "ofxHPVPlayer.h"
#include "ofxTextureRecorder.h"
#include "ofxDatGui.h"
#include "MenuItem.h"
#include "RangeSliderItem.h"
#include "ParamSliderItem.h"
......@@ -27,9 +29,18 @@ 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);
int flickering(int length_in, int length_out, int max_opacity=100, int min_opacity=0,int delay=0);
ofxHPVPlayer hpvPlayer;
ofxHPVPlayer hpvChannel_2;
ofxHPVPlayer hpv_ch1;
ofxHPVPlayer hpv_ch2;
ofxHPVPlayer hpv_ch3;
ofImage mask_prep;
ofImage mask_ch1, mask_ch2, mask_ch3;
std::map<std::string, MenuItem *> ui_items;
RangeSliderItem * range_slider;
......@@ -37,22 +48,57 @@ public:
bool b_draw_stats;
bool b_draw_gui;
int framerate;
int actual_frame;
ofTrueTypeFontExt gui_font;
vector<string> video_names;
float potar_1, potar_2, potar_4, potar_0, potar_10, potar_11;
int opacity_1, opacity_2;
int opacity_1, opacity_2, opacity_3;
ofTexture videoTexture;
int w, h;
//ofTexture * hpvTexture;
ofxTextureRecorder recorder;
ofFbo fbo;
bool recording;
ofTexture grayTex;
ofPixels pixels;
unsigned char * gray;
ofFbo fbo_ch;
ofFbo fbo_ch1, fbo_ch2, fbo_ch3;
bool recording, playing_record;
int record_actual_frame;
vector<int> recorded_sequence;
ofPixels videoPixels;
ofImage testImg;
int testValue;
ofShader shader;
ofArduino ard;
bool bSetupArduino; // flag variable for setting up arduino once
// 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<bool> doRandom_pos_ch1;
ofxDatGuiFolder* text_ch1;
ofxDatGuiTextInput* input_text;
void onTextInputEvent(ofxDatGuiTextInputEvent e);
ofTrueTypeFont font;
private:
......@@ -63,5 +109,5 @@ private:
string buttonState;
string potValue;
};