render_2d.frag.glsl (992B)
1 /* See LICENSE for license details. */ 2 3 /* input: h [0,360] | s,v [0, 1] * 4 * output: rgb [0,1] */ 5 vec3 hsv2rgb(vec3 hsv) 6 { 7 vec3 k = mod(vec3(5, 3, 1) + hsv.x / 60, 6); 8 k = max(min(min(k, 4 - k), 1), 0); 9 return hsv.z - hsv.z * hsv.y * k; 10 } 11 12 void main() 13 { 14 ivec3 out_data_dim = textureSize(u_texture, 0); 15 16 //vec2 min_max = texelFetch(u_out_data_tex, ivec3(0), textureQueryLevels(u_out_data_tex) - 1).xy; 17 18 /* TODO(rnp): select between x and y and specify slice */ 19 vec3 tex_coord = vec3(texture_coordinate.x, 0.5, texture_coordinate.y); 20 float smp = length(texture(u_texture, tex_coord).xy); 21 float threshold_val = pow(10.0f, u_threshold / 20.0f); 22 smp = clamp(smp, 0.0f, threshold_val); 23 smp = smp / threshold_val; 24 smp = pow(smp, u_gamma); 25 26 if (u_log_scale) { 27 smp = 20 * log(smp) / log(10); 28 smp = clamp(smp, -u_db_cutoff, 0) / -u_db_cutoff; 29 smp = 1 - smp; 30 } 31 32 //v_out_colour = vec4(hsv2rgb(vec3(360 * smp, 0.8, 0.95)), 1); 33 v_out_colour = vec4(smp, smp, smp, 1); 34 }