From 5dd999b406cc8ef985ed85be4cce8e98a5da3cc6 Mon Sep 17 00:00:00 2001 From: Troy James Sobotka Date: Mon, 27 Apr 2020 23:17:54 -0700 Subject: [PATCH] First working pass of Waveform Remove the sum, add some commments, and make it scale to the full window. TODO: * Hook up CM. * Add UI for intensity * Add lines at 20% increments, plus under / overshoot? * Add UI for increments. --- app/shaders/rgbwaveform.frag | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/app/shaders/rgbwaveform.frag b/app/shaders/rgbwaveform.frag index dbdf0cdc0..3e1d0fd40 100644 --- a/app/shaders/rgbwaveform.frag +++ b/app/shaders/rgbwaveform.frag @@ -6,8 +6,6 @@ uniform sampler2D ove_maintex; uniform vec2 ove_resolution; uniform vec2 ove_viewport; -varying vec2 ove_texcoord; - uniform float threshold; @@ -17,10 +15,21 @@ out vec4 fragColor; void main(void) { vec3 col = vec3(0.0); - float increment = 1.0 / 255.0; + // Set an increment default to 10 bit encodings. This would likely be + // better served as a UI control, as waveforms will change their combing + // based on how granular the increment is set. For example, it can be + // challenging to spot 8 bit combing with an increment of 1. / 2.^8 - 1. + float increment = 1.0 / (pow(2, 10) - 1.0); float maxb = ove_texcoord.y + increment; float minb = ove_texcoord.y - increment; + // Intensity would make sense to also expose via the UI, as a density + // slider allows you to peek past certain values or reveal very low + // values. Hard coding it for now, as there isn't a clear way to have + // the various bit depth / code values always display at a consistent + // emission output strength. + float intensity = 0.10; + int y_lim = int(ove_resolution.y); vec3 cur_col = vec3(0.0); @@ -31,10 +40,18 @@ void main(void) { ).rgb; col += step(vec3(ove_texcoord.y - increment), cur_col) * - step(cur_col, vec3(ove_texcoord.y + increment)); + step(cur_col, vec3(ove_texcoord.y + increment)) * intensity; + + // TODO: Implement proper luma / luminance based values. + // This is simply taking the luminance weights derived from the + // 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)); - //float l = dot(x, x); - //col += step(l, maxb*maxb)*step(minb*minb, l) / (ove_resolution.y * 0.125); } gl_FragColor = vec4(col, 1.0);