basic temperature effect added

This commit is contained in:
itsmattkc
2018-10-19 22:52:48 +11:00
parent 074570a2d0
commit 2a44fa5dd3
9 changed files with 81 additions and 8 deletions
+4 -1
View File
@@ -27,12 +27,13 @@
#include "effects/video/cropeffect.h"
#include "effects/video/flipeffect.h"
#include "effects/video/boxblureffect.h"
#include "effects/video/waveeffect.h"
#include "effects/video/temperatureeffect.h"
#include "effects/audio/paneffect.h"
#include "effects/audio/volumeeffect.h"
#include "effects/audio/audionoiseeffect.h"
#include "effects/audio/toneeffect.h"
#include "effects/video/waveeffect.h"
#include <QCheckBox>
#include <QGridLayout>
@@ -59,6 +60,7 @@ void init_effects() {
video_effect_names[VIDEO_FLIP_EFFECT] = "Flip";
video_effect_names[VIDEO_BOXBLUR_EFFECT] = "Box Blur";
video_effect_names[VIDEO_WAVE_EFFECT] = "Wave";
video_effect_names[VIDEO_TEMPERATURE_EFFECT] = "Temperature";
audio_effect_names[AUDIO_VOLUME_EFFECT] = "Volume";
audio_effect_names[AUDIO_PAN_EFFECT] = "Pan";
@@ -80,6 +82,7 @@ Effect* create_effect(int effect_id, Clip* c) {
case VIDEO_FLIP_EFFECT: return new FlipEffect(c);
case VIDEO_BOXBLUR_EFFECT: return new BoxBlurEffect(c);
case VIDEO_WAVE_EFFECT: return new WaveEffect(c);
case VIDEO_TEMPERATURE_EFFECT: return new TemperatureEffect(c);
}
} else {
switch (effect_id) {
+1
View File
@@ -34,6 +34,7 @@ enum VideoEffects {
VIDEO_FLIP_EFFECT,
VIDEO_BOXBLUR_EFFECT,
VIDEO_WAVE_EFFECT,
VIDEO_TEMPERATURE_EFFECT,
VIDEO_EFFECT_COUNT
};
+1
View File
@@ -7,5 +7,6 @@
<file>solideffect.frag</file>
<file>boxblureffect.frag</file>
<file>waveeffect.frag</file>
<file>temperatureeffect.frag</file>
</qresource>
</RCC>
+36
View File
@@ -0,0 +1,36 @@
#version 110
// adapted from Tanner Helland's temperature algorithm
// (http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/)
uniform float temperature;
uniform mediump float amount_val;
uniform sampler2D myTexture;
varying vec2 vTexCoord;
void main(void) {
vec4 textureColor = texture2D(myTexture, vTexCoord);
// red value
float red = (temperature <= 66.0) ? 1.0 : min(1.0, max(0.0, (329.698727446 * (pow(temperature - 60.0, -0.1332047592)))/255.0));
// green value
float green = min(1.0, max(0.0, ((temperature <= 66.0) ? (99.4708025861 * log(temperature) - 161.1195681661) : 288.1221695283 * (pow(temperature - 60.0, -0.0755148492)))/255.0));
// blue value
float blue = (temperature >= 66.0) ? 1.0 : min(1.0, max(0.0, (138.5177312231 * log(temperature - 10.0) - 305.0447927307)/255.0));
gl_FragColor = vec4(
textureColor.r*red,
textureColor.g*green,
textureColor.b*blue,
textureColor.a
);
/*gl_FragColor = vec4(
red,
green,
blue,
1.0
);*/
}
+1 -1
View File
@@ -10,7 +10,7 @@ uniform sampler2D myTexture;
varying vec2 vTexCoord;
void main(void) {
float offset = sin((vTexCoord.x+evolution)*frequency)*intensity;
float offset = sin((vTexCoord.x-evolution)*frequency)*intensity;
float y = vTexCoord.y-offset;
if (y < 0.0 || y > 1.0) {
-4
View File
@@ -4,10 +4,6 @@
#include <QLabel>
#include <QGridLayout>
#include <QOpenGLFunctions>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QXmlStreamAttributes>
InvertEffect::InvertEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_INVERT_EFFECT) {
enable_shader = true;
+19
View File
@@ -0,0 +1,19 @@
#include "temperatureeffect.h"
TemperatureEffect::TemperatureEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_TEMPERATURE_EFFECT) {
enable_shader = true;
temp_val = add_row("Temperature:")->add_field(EFFECT_FIELD_DOUBLE);
temp_val->set_double_minimum_value(2000);
temp_val->set_double_default_value(5200);
temp_val->set_double_maximum_value(40000);
connect(temp_val, SIGNAL(changed()), this, SLOT(field_changed()));
vertPath = ":/shaders/common.vert";
fragPath = ":/shaders/temperatureeffect.frag";
}
void TemperatureEffect::process_shader(double timecode) {
glslProgram->setUniformValue("temperature", (GLfloat) (temp_val->get_double_value(timecode)*0.01));
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef TEMPERATUREEFFECT_H
#define TEMPERATUREEFFECT_H
#include "../effect.h"
class TemperatureEffect : public Effect {
Q_OBJECT
public:
TemperatureEffect(Clip* c);
void process_shader(double timecode);
private:
EffectField* temp_val;
};
#endif // TEMPERATUREEFFECT_H
+4 -2
View File
@@ -83,7 +83,8 @@ SOURCES += \
project/marker.cpp \
dialogs/speeddialog.cpp \
dialogs/mediapropertiesdialog.cpp \
effects/video/waveeffect.cpp
effects/video/waveeffect.cpp \
effects/video/temperatureeffect.cpp
HEADERS += \
mainwindow.h \
@@ -145,7 +146,8 @@ HEADERS += \
dialogs/speeddialog.h \
dialogs/speeddialog.h \
dialogs/mediapropertiesdialog.h \
effects/video/waveeffect.h
effects/video/waveeffect.h \
effects/video/temperatureeffect.h
FORMS += \
mainwindow.ui \