From b9a62eb1aa211a0720059ceb2dee3f37d1033700 Mon Sep 17 00:00:00 2001 From: Troy James Sobotka Date: Tue, 28 Apr 2020 08:59:55 -0700 Subject: [PATCH] Add lines Adding waveform lines. Still requires scaling to fit in arbitrary range. --- app/shaders/rgbwaveform.frag | 12 ++++++------ app/widget/scope/waveform/waveform.cpp | 27 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/shaders/rgbwaveform.frag b/app/shaders/rgbwaveform.frag index 3e1d0fd40..94537a703 100644 --- a/app/shaders/rgbwaveform.frag +++ b/app/shaders/rgbwaveform.frag @@ -6,8 +6,7 @@ uniform sampler2D ove_maintex; uniform vec2 ove_resolution; uniform vec2 ove_viewport; - -uniform float threshold; +uniform vec3 luma_coeffs; in vec2 ove_texcoord; @@ -33,6 +32,7 @@ void main(void) { int y_lim = int(ove_resolution.y); vec3 cur_col = vec3(0.0); + vec3 cur_lum = vec3(0.0); for (int i = 0; i < y_lim; i++) { cur_col = texture2D( ove_maintex, @@ -47,10 +47,10 @@ void main(void) { // OCIO configuration or the RGB to XYZ matrix and multiplying // the above step approach by the luminance weights. // EG: - // cur_lum = cur_col * lum_coeffs; - // - // col += step(vec3(ove_texcoord.y - increment), cur_lum) * - // step(cur_lum, vec3(ove_texcoord.y + increment)); + cur_lum = vec3(dot(cur_col, luma_coeffs)); + + col += step(vec3(ove_texcoord.y - increment), cur_lum) * + step(cur_lum, vec3(ove_texcoord.y + increment)) * intensity; } diff --git a/app/widget/scope/waveform/waveform.cpp b/app/widget/scope/waveform/waveform.cpp index 0ce873bc5..530be3981 100644 --- a/app/widget/scope/waveform/waveform.cpp +++ b/app/widget/scope/waveform/waveform.cpp @@ -21,6 +21,10 @@ #include "waveform.h" +#include +#include +#include + #include "node/node.h" #include "render/backend/opengl/openglrenderfunctions.h" @@ -95,6 +99,22 @@ void WaveformScope::paintGL() color_service()->ProcessOpenGL(); + QVector ire_lines(6); + + for (int i=1; i <= 5; i++) { + ire_lines[i].setLine( + 0.0, height() * (i * 0.20), width(), height() * + (i * 0.20)); + } + ire_lines[0].setLine(0.0, 0.0, width(), 0.0); + ire_lines[5].setLine(0.0, height() - 1.0, width(), height() - 1.0); + + QPainter p(this); + p.setCompositionMode(QPainter::CompositionMode_Plus); + + p.setPen(Qt::red); + p.drawLines(ire_lines); + texture_.Release(); framebuffer_.Release(); @@ -107,8 +127,11 @@ void WaveformScope::paintGL() pipeline_->setUniformValue("ove_resolution", texture_.width(), texture_.height()); pipeline_->setUniformValue("ove_viewport", width(), height()); - // The general size of a pixel - pipeline_->setUniformValue("threshold", 2.0f / static_cast(height())); + GLfloat luma[3] = {0.0, 0.0, 0.0}; + + color_manager()->GetDefaultLumaCoefs(luma); + // qDebug() << "LUMA" << luma[0] << " " << luma[1] << " " << luma[2]; + pipeline_->setUniformValue("luma_coeffs", luma[0], luma[1], luma[2]); pipeline_->release();