#version 330 core

in vec2 UV;

out vec4 color;

uniform sampler2D fb_texture;
uniform sampler1D cmap;
uniform float min_val;
uniform float scale;
uniform float cmap_min;
uniform float cmap_max;
uniform float cmap_log;

void main(){
   float scaled = texture(fb_texture, UV).x * scale + min_val;
   float cm = cmap_min;
   float cp = cmap_max;

   if (cmap_log > 0.5) {
      scaled = log(scaled) / log(10.f);
   }
   color = texture(cmap, (scaled - cm) / (cp - cm));
}
