2016-03-14 09:43:55 +00:00
|
|
|
// -*-C++-*-
|
|
|
|
|
|
|
|
// This is a library of filter functions
|
|
|
|
|
|
|
|
// Thorsten Renk 2016
|
|
|
|
|
|
|
|
#version 120
|
|
|
|
|
|
|
|
uniform float gamma;
|
|
|
|
uniform float brightness;
|
2016-03-17 12:40:37 +00:00
|
|
|
uniform float delta_T;
|
|
|
|
uniform float osg_SimulationTime;
|
2016-03-14 09:43:55 +00:00
|
|
|
|
|
|
|
uniform bool use_filtering;
|
|
|
|
uniform bool use_night_vision;
|
2016-03-17 12:40:37 +00:00
|
|
|
uniform bool use_IR_vision;
|
2016-03-14 09:43:55 +00:00
|
|
|
|
2016-03-17 12:40:37 +00:00
|
|
|
uniform int display_xsize;
|
|
|
|
uniform int display_ysize;
|
|
|
|
|
|
|
|
float Noise2D(in vec2 coord, in float wavelength);
|
2016-03-14 09:43:55 +00:00
|
|
|
|
|
|
|
vec3 gamma_correction (in vec3 color) {
|
|
|
|
|
|
|
|
|
|
|
|
float value = length(color)/1.732;
|
|
|
|
return pow(value, gamma) * color;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 brightness_adjust (in vec3 color) {
|
|
|
|
|
|
|
|
return clamp(brightness * color, 0.0, 1.0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 night_vision (in vec3 color) {
|
|
|
|
|
|
|
|
float value = length(color)/1.732;
|
|
|
|
|
2016-03-17 12:40:37 +00:00
|
|
|
vec2 center = vec2 (float(display_xsize) * 0.5, float(display_ysize) * 0.5);
|
|
|
|
float noise = Noise2D( vec2 (gl_FragCoord.x + 100.0 * osg_SimulationTime, gl_FragCoord.y + 300.0 * osg_SimulationTime), 4.0);
|
|
|
|
|
|
|
|
float fade = 1.0 - smoothstep( 0.3 * display_ysize, 0.55 * display_ysize, length(gl_FragCoord.xy -center));
|
|
|
|
|
|
|
|
return vec3 (0.0, 1.0, 0.0) * value * (0.5 + 0.5 * noise) * fade;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vec3 IR_vision (in vec3 color) {
|
|
|
|
|
|
|
|
float value = length(color)/1.732;
|
|
|
|
value = 1.0 - value;
|
|
|
|
|
|
|
|
float T_mapped = smoothstep(-10.0, 10.0, delta_T);
|
|
|
|
|
|
|
|
float gain = mix(T_mapped, value, 0.7);
|
|
|
|
//float gain = 0.2 * T_mapped + 0.8 * value * T_mapped;
|
|
|
|
if (delta_T < -10.0) {gain = 0.0;}
|
|
|
|
|
|
|
|
|
|
|
|
return vec3 (0.7, 0.7, 0.7) * gain;
|
2016-03-14 09:43:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 filter_combined (in vec3 color) {
|
|
|
|
|
|
|
|
if (use_filtering == false)
|
|
|
|
{
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
color = brightness_adjust(color);
|
|
|
|
|
|
|
|
if (use_night_vision)
|
|
|
|
{
|
|
|
|
color = night_vision(color);
|
|
|
|
}
|
|
|
|
|
2016-03-17 12:40:37 +00:00
|
|
|
else if (use_IR_vision)
|
|
|
|
{
|
|
|
|
color = IR_vision(color);
|
|
|
|
}
|
|
|
|
|
2016-03-14 09:43:55 +00:00
|
|
|
return gamma_correction (color);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|