From bb8e93da97a7c7cf4623e79048a8cab59dc4f3d3 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Sun, 27 Mar 2016 20:27:32 +0300 Subject: [PATCH] Enable filtering for ALS lower quality terrain, water and model shaders --- Effects/model-default.eff | 1 + Effects/terrain-default.eff | 42 +++++++++++++++++++++++++++++ Effects/water-inland.eff | 43 ++++++++++++++++++++++++++++++ Effects/water.eff | 44 +++++++++++++++++++++++++++++++ Shaders/model-ALS-base.frag | 4 ++- Shaders/terrain-ALS-detailed.frag | 4 ++- Shaders/terrain-ALS-detailed.vert | 7 +++++ Shaders/water-ALS-base.frag | 4 +++ 8 files changed, 147 insertions(+), 2 deletions(-) diff --git a/Effects/model-default.eff b/Effects/model-default.eff index fbca771f1..75603684f 100644 --- a/Effects/model-default.eff +++ b/Effects/model-default.eff @@ -114,6 +114,7 @@ Shaders/model-ALS-base.frag Shaders/hazes.frag Shaders/secondary_lights.frag + Shaders/noise.frag Shaders/filters-ALS.frag diff --git a/Effects/terrain-default.eff b/Effects/terrain-default.eff index 15a45ccdf..0c45b20d1 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -923,6 +923,7 @@ Shaders/terrain-ALS-detailed.frag Shaders/noise.frag Shaders/hazes.frag + Shaders/filters-ALS.frag visibility @@ -1029,6 +1030,47 @@ float season + + + gamma + float + gamma + + + brightness + float + brightness + + + use_night_vision + bool + use_night_vision + + + use_IR_vision + bool + use_IR_vision + + + use_filtering + bool + use_filtering + + + delta_T + float + delta_T + + + display_xsize + int + display_xsize + + + display_ysize + int + display_ysize + quality_level int diff --git a/Effects/water-inland.eff b/Effects/water-inland.eff index a590509c9..684594e13 100644 --- a/Effects/water-inland.eff +++ b/Effects/water-inland.eff @@ -1103,6 +1103,8 @@ Shaders/water-ALS.vert Shaders/water-ALS-base.frag Shaders/hazes.frag + Shaders/noise.frag + Shaders/filters-ALS.frag + + gamma + float + gamma + + + brightness + float + brightness + + + use_filtering + bool + use_filtering + + + use_night_vision + bool + use_night_vision + + + use_IR_vision + bool + use_IR_vision + + + delta_T + float + delta_T + sea_r @@ -1300,6 +1333,16 @@ int 0 + + display_xsize + int + display_xsize + + + display_ysize + int + display_ysize + diff --git a/Effects/water.eff b/Effects/water.eff index 9387c1c68..afe517c11 100644 --- a/Effects/water.eff +++ b/Effects/water.eff @@ -610,6 +610,7 @@ float landing_light3_offset + gamma float @@ -1095,6 +1096,8 @@ Shaders/water-ALS.vert Shaders/water-ALS-base.frag Shaders/hazes.frag + Shaders/noise.frag + Shaders/filters-ALS.frag + + gamma + float + gamma + + + brightness + float + brightness + + + use_filtering + bool + use_filtering + + + use_night_vision + bool + use_night_vision + + + use_IR_vision + bool + use_IR_vision + + + delta_T + float + delta_T + sea_r @@ -1297,6 +1331,16 @@ int 1 + + display_xsize + int + display_xsize + + + display_ysize + int + display_ysize + diff --git a/Shaders/model-ALS-base.frag b/Shaders/model-ALS-base.frag index 49380d97f..b07997519 100644 --- a/Shaders/model-ALS-base.frag +++ b/Shaders/model-ALS-base.frag @@ -53,7 +53,7 @@ vec3 rayleigh_out_shift(in vec3 color, in float outscatter); vec3 get_hazeColor(in float light_arg); vec3 searchlight(); vec3 landing_light(in float offset, in float offsetv); - +vec3 filter_combined (in vec3 color) ; float luminance(vec3 color) { @@ -313,6 +313,8 @@ fragColor.rgb = mix(hazeColor + secondary_light * fog_backscatter(mvisibility), } +fragColor.rgb = filter_combined(fragColor.rgb); + gl_FragColor = fragColor; } diff --git a/Shaders/terrain-ALS-detailed.frag b/Shaders/terrain-ALS-detailed.frag index 8616a2a52..d3a9d0e6a 100644 --- a/Shaders/terrain-ALS-detailed.frag +++ b/Shaders/terrain-ALS-detailed.frag @@ -53,7 +53,7 @@ float Noise3D(in vec3 coord, in float wavelength); float fog_func (in float targ, in float alt); vec3 get_hazeColor(in float light_arg); - +vec3 filter_combined (in vec3 color) ; @@ -494,6 +494,8 @@ fragColor.rgb = mix(clamp(hazeColor,0.0,1.0) , clamp(fragColor.rgb,0.0,1.0),tran } +fragColor.rgb = filter_combined(fragColor.rgb); + gl_FragColor = fragColor; diff --git a/Shaders/terrain-ALS-detailed.vert b/Shaders/terrain-ALS-detailed.vert index 692817b49..242212b3f 100644 --- a/Shaders/terrain-ALS-detailed.vert +++ b/Shaders/terrain-ALS-detailed.vert @@ -40,6 +40,8 @@ uniform float ground_scattering; uniform float eye_alt; uniform float moonlight; +uniform bool use_IR_vision; + uniform mat4 osg_ViewMatrixInverse; float earthShade; @@ -268,6 +270,11 @@ float shade_depth = 1.0 * smoothstep (0.6,0.95,ground_scattering) * (1.0-smooth light_ambient.rgb = light_ambient.rgb * (1.0 - shade_depth); light_diffuse.rgb = light_diffuse.rgb * (1.0 + 1.2 * shade_depth); +if (use_IR_vision) + { + light_ambient.rgb = max(light_ambient.rgb, vec3 (0.5, 0.5, 0.5)); + } + // default lighting based on texture and material using the light we have just computed diffuse_term = diffuse_color* light_diffuse; diff --git a/Shaders/water-ALS-base.frag b/Shaders/water-ALS-base.frag index bb32c5cab..1a5d203c1 100644 --- a/Shaders/water-ALS-base.frag +++ b/Shaders/water-ALS-base.frag @@ -62,6 +62,7 @@ const float EarthRadius = 5800000.0; float fog_func (in float targ, in float alt); vec3 get_hazeColor(in float light_arg); +vec3 filter_combined (in vec3 color) ; /////// functions ///////// @@ -551,6 +552,9 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo } + + finalColor.rgb = filter_combined(finalColor.rgb); + gl_FragColor = finalColor; }