Commit: ca46178c0ca44c1d0163491816e93c945a4728bd
Parent: 31d87b20c004a9f15766223dff9c89d985a344cf
Author: Randy Palamar
Date: Mon, 14 Apr 2025 20:05:01 -0600
ui: make gamma apply in both log scale and power scale
The observable effect is different but it still makes sense to
allow it in both modes.
Diffstat:
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/shaders/render.glsl b/shaders/render.glsl
@@ -24,13 +24,12 @@ void main()
float threshold_val = pow(10.0f, u_threshold / 20.0f);
smp = clamp(smp, 0.0f, threshold_val);
smp = smp / threshold_val;
+ smp = pow(smp, u_gamma);
if (u_log_scale) {
smp = 20 * log(smp) / log(10);
smp = clamp(smp, -u_db_cutoff, 0) / -u_db_cutoff;
smp = 1 - smp;
- } else {
- smp = pow(smp, u_gamma);
}
//v_out_colour = vec4(hsv2rgb(vec3(360 * smp, 0.8, 0.95)), 1);
diff --git a/ui.c b/ui.c
@@ -1604,14 +1604,13 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
if (remaining_width > view->dynamic_range.name_width || !drew_coordinates) {
f32 max_prefix_width = MAX(view->threshold.name_width, view->dynamic_range.name_width);
- b32 log_scale = view->log_scale->u.b32;
- f32 items = log_scale ? 2 : 3;
+ f32 items = 3;
v2 end = add_v2(vr.pos, vr.size);
f32 start_y = MAX(end.y - 4 - items * text_spec.font->baseSize, vr.pos.y);
end.y -= text_spec.font->baseSize;
v2 at = {.x = vr.pos.x + 4, .y = start_y};
- if (!log_scale && at.y < end.y) at.y += draw_text(view->gamma.name, at, &text_spec).y;
+ if (at.y < end.y) at.y += draw_text(view->gamma.name, at, &text_spec).y;
if (at.y < end.y) at.y += draw_text(view->threshold.name, at, &text_spec).y;
if (at.y < end.y) at.y += draw_text(view->dynamic_range.name, at, &text_spec).y;
@@ -1621,7 +1620,7 @@ draw_beamformer_frame_view(BeamformerUI *ui, Arena a, Variable *var, Rect displa
v2 size;
f32 max_center_width = 0;
- if (!log_scale && at.y < end.y) {
+ if (at.y < end.y) {
size = draw_variable(ui, a, &view->gamma, at, mouse, RULER_COLOUR, text_spec);
max_center_width = MAX(size.w, max_center_width);
at.y += size.h;