1
0
Fork 0

Preparation for filtering (gamma, brightness, night vision) for ALS

This commit is contained in:
Thorsten Renk 2016-03-14 11:43:55 +02:00
parent 47b4c1db3d
commit 5bd2faab04
11 changed files with 216 additions and 12 deletions

View file

@ -17,6 +17,10 @@
<lightning-pos-x><use>/environment/lightning/lightning-pos-x</use></lightning-pos-x>
<lightning-pos-y><use>/environment/lightning/lightning-pos-y</use></lightning-pos-y>
<lightning-range><use>/environment/lightning/lightning-range</use></lightning-range>
<use_filtering><use>/sim/rendering/als-filters/use-filtering</use></use_filtering>
<gamma><use>/sim/rendering/als-filters/gamma</use></gamma>
<brightness><use>/sim/rendering/als-filters/brightness</use></brightness>
<use_night_vision><use>/sim/rendering/als-filters/use-night-vision</use></use_night_vision>
</parameters>
<technique n="9">
@ -63,6 +67,7 @@
<program>
<vertex-shader>Shaders/3dcloud-ALS.vert</vertex-shader>
<fragment-shader>Shaders/3dcloud-ALS.frag</fragment-shader>
<fragment-shader>Shaders/filters-ALS.frag</fragment-shader>
<attribute>
<name>usrAttr1</name>
<index>10</index>
@ -142,6 +147,26 @@
<type>float</type>
<value><use>lightning-range</use></value>
</uniform>
<uniform>
<name>gamma</name>
<type>float</type>
<value><use>gamma</use></value>
</uniform>
<uniform>
<name>brightness</name>
<type>float</type>
<value><use>brightness</use></value>
</uniform>
<uniform>
<name>use_filtering</name>
<type>bool</type>
<value><use>use_filtering</use></value>
</uniform>
<uniform>
<name>use_night_vision</name>
<type>bool</type>
<value><use>use_night_vision</use></value>
</uniform>
<!--<vertex-program-two-side>true</vertex-program-two-side>-->
</pass>
</technique>

View file

@ -33,6 +33,10 @@
<landing_light1_offset><use>/sim/rendering/als-secondary-lights/landing-light1-offset-deg</use></landing_light1_offset>
<landing_light2_offset><use>/sim/rendering/als-secondary-lights/landing-light2-offset-deg</use></landing_light2_offset>
<landing_light3_offset><use>/sim/rendering/als-secondary-lights/landing-light3-offset-deg</use></landing_light3_offset>
<use_filtering><use>/sim/rendering/als-filters/use-filtering</use></use_filtering>
<gamma><use>/sim/rendering/als-filters/gamma</use></gamma>
<brightness><use>/sim/rendering/als-filters/brightness</use></brightness>
<use_night_vision><use>/sim/rendering/als-filters/use-night-vision</use></use_night_vision>
<air_pollution><use>/environment/air-pollution-norm</use></air_pollution>
</parameters>
<technique n="8">
@ -63,6 +67,7 @@
<fragment-shader>Shaders/skydome-ALS.frag</fragment-shader>
<fragment-shader>Shaders/noise.frag</fragment-shader>
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader>Shaders/filters-ALS.frag</fragment-shader>
</program>
<uniform>
<name>mK</name>
@ -169,6 +174,26 @@
<type>float</type>
<value><use>horizon_roughness</use></value>
</uniform>
<uniform>
<name>gamma</name>
<type>float</type>
<value><use>gamma</use></value>
</uniform>
<uniform>
<name>brightness</name>
<type>float</type>
<value><use>brightness</use></value>
</uniform>
<uniform>
<name>use_filtering</name>
<type>bool</type>
<value><use>use_filtering</use></value>
</uniform>
<uniform>
<name>use_night_vision</name>
<type>bool</type>
<value><use>use_night_vision</use></value>
</uniform>
<uniform>
<name>view_pitch_offset</name>
<type>float</type>

View file

@ -130,6 +130,10 @@
<landing_light3_offset><use>/sim/rendering/als-secondary-lights/landing-light3-offset-deg</use></landing_light3_offset>
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
<use_filtering><use>/sim/rendering/als-filters/use-filtering</use></use_filtering>
<gamma><use>/sim/rendering/als-filters/gamma</use></gamma>
<brightness><use>/sim/rendering/als-filters/brightness</use></brightness>
<use_night_vision><use>/sim/rendering/als-filters/use-night-vision</use></use_night_vision>
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
<cloudpos2_x><use>/local-weather/cloud-shadows/cloudpos-x[1]</use></cloudpos2_x>
@ -308,6 +312,7 @@
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader>Shaders/filters-ALS.frag</fragment-shader>
</program>
<uniform>
<name>grain_strength</name>
@ -479,6 +484,26 @@
<type>float</type>
<value><use>landing_light3_offset</use></value>
</uniform>
<uniform>
<name>gamma</name>
<type>float</type>
<value><use>gamma</use></value>
</uniform>
<uniform>
<name>brightness</name>
<type>float</type>
<value><use>brightness</use></value>
</uniform>
<uniform>
<name>use_night_vision</name>
<type>bool</type>
<value><use>use_night_vision</use></value>
</uniform>
<uniform>
<name>use_filtering</name>
<type>bool</type>
<value><use>use_filtering</use></value>
</uniform>
<uniform>
<name>cloudpos1_x</name>
<type>float</type>

View file

@ -146,6 +146,11 @@
<fogtype>
<use>/sim/rendering/shaders/skydome</use>
</fogtype>
<!-- filtering -->
<use_filtering><use>/sim/rendering/als-filters/use-filtering</use></use_filtering>
<gamma><use>/sim/rendering/als-filters/gamma</use></gamma>
<brightness><use>/sim/rendering/als-filters/brightness</use></brightness>
<use_night_vision><use>/sim/rendering/als-filters/use-night-vision</use></use_night_vision>
<!-- cloud shadows -->
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
@ -394,6 +399,7 @@
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader>Shaders/filters-ALS.frag</fragment-shader>
</program>
<!--<uniform>
<name>water_reflection</name>
@ -604,11 +610,31 @@
<type>float</type>
<value><use>landing_light2_offset</use></value>
</uniform>
<uniform>
<name>landing_light3_offset</name>
<type>float</type>
<value><use>landing_light3_offset</use></value>
</uniform>
<uniform>
<name>landing_light3_offset</name>
<type>float</type>
<value><use>landing_light3_offset</use></value>
</uniform>
<uniform>
<name>gamma</name>
<type>float</type>
<value><use>gamma</use></value>
</uniform>
<uniform>
<name>brightness</name>
<type>float</type>
<value><use>brightness</use></value>
</uniform>
<uniform>
<name>use_filtering</name>
<type>bool</type>
<value><use>use_filtering</use></value>
</uniform>
<uniform>
<name>use_night_vision</name>
<type>bool</type>
<value><use>use_night_vision</use></value>
</uniform>
<uniform>
<name>cloudpos1_x</name>
<type>float</type>

View file

@ -138,6 +138,11 @@
<sea_r><use>/environment/sea/color_r</use></sea_r>
<sea_g><use>/environment/sea/color_g</use></sea_g>
<sea_b><use>/environment/sea/color_b</use></sea_b>
<!-- filtering -->
<use_filtering><use>/sim/rendering/als-filters/use-filtering</use></use_filtering>
<gamma><use>/sim/rendering/als-filters/gamma</use></gamma>
<brightness><use>/sim/rendering/als-filters/brightness</use></brightness>
<use_night_vision><use>/sim/rendering/als-filters/use-night-vision</use></use_night_vision>
<!-- cloud shadows -->
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
@ -377,6 +382,7 @@
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader>Shaders/filters-ALS.frag</fragment-shader>
</program>
<!--<uniform>
<name>water_reflection</name>
@ -602,6 +608,26 @@
<type>float</type>
<value><use>landing_light3_offset</use></value>
</uniform>
<uniform>
<name>gamma</name>
<type>float</type>
<value><use>gamma</use></value>
</uniform>
<uniform>
<name>brightness</name>
<type>float</type>
<value><use>brightness</use></value>
</uniform>
<uniform>
<name>use_filtering</name>
<type>bool</type>
<value><use>use_filtering</use></value>
</uniform>
<uniform>
<name>use_night_vision</name>
<type>bool</type>
<value><use>use_night_vision</use></value>
</uniform>
<uniform>
<name>cloudpos1_x</name>
<type>float</type>

View file

@ -3,6 +3,8 @@ varying float fogFactor;
varying vec3 hazeColor;
vec3 filter_combined (in vec3 color) ;
void main(void)
{
vec4 base = texture2D( baseTexture, gl_TexCoord[0].st);
@ -11,7 +13,10 @@ void main(void)
vec4 finalColor = base * gl_Color;
gl_FragColor.rgb = mix(hazeColor, finalColor.rgb, fogFactor );
finalColor.rgb = mix(hazeColor, finalColor.rgb, fogFactor );
finalColor.rgb = filter_combined(finalColor.rgb);
gl_FragColor.rgb = finalColor.rgb;
gl_FragColor.a = mix(0.0, finalColor.a, 1.0 - 0.5 * (1.0 - fogFactor));
}

57
Shaders/filters-ALS.frag Normal file
View file

@ -0,0 +1,57 @@
// -*-C++-*-
// This is a library of filter functions
// Thorsten Renk 2016
#version 120
uniform float gamma;
uniform float brightness;
uniform bool use_filtering;
uniform bool use_night_vision;
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;
return vec3 (0.0, 1.0, 0.0) * value;
}
vec3 filter_combined (in vec3 color) {
if (use_filtering == false)
{
return color;
}
color = brightness_adjust(color);
if (use_night_vision)
{
color = night_vision(color);
}
return gamma_correction (color);
}

View file

@ -49,6 +49,7 @@ float fog_backscatter(in float avisibility);
vec3 searchlight();
vec3 landing_light(in float offset, in float offsetv);
vec3 filter_combined (in vec3 color) ;
float light_func (in float x, in float a, in float b, in float c, in float d, in float e)
{
@ -345,7 +346,7 @@ hColor = clamp(hColor,0.0,1.0);
color = mix(hColor+secondary_light * fog_backscatter(avisibility),color, transmission);
color = filter_combined(color);
gl_FragColor = vec4(color, 1.0);
gl_FragDepth = 0.1;

View file

@ -85,7 +85,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) ;
@ -657,6 +657,7 @@ hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix(hazeColor+secondary_light * fog_backscatter(mvisibility) , fragColor.rgb,transmission);
}
fragColor.rgb = filter_combined(fragColor.rgb);
gl_FragColor = fragColor;

View file

@ -4,7 +4,7 @@
// © Michael Horsch - 2005
// Major update and revisions - 2011-10-07
// © Emilian Huminiuc and Vivian Meazza
// ported to lightfield shading Thorsten Renk 2012
// ported to ALS Thorsten Renk 2012
#version 120
@ -92,6 +92,8 @@ 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) ;
//////////////////////
@ -214,7 +216,7 @@ void main(void)
// get depth map
vec4 topoTexel = texture2D(topo_map, TopoUV);
float floorMixFactor = smoothstep(0.3, 0.985, topoTexel.a);
float floorMixFactor = smoothstep(0.3, 0.985, topoTexel.a);
vec3 floorColour = topoTexel.rgb;
mat4 RotationMatrix;
@ -495,11 +497,12 @@ void main(void)
float waveSlope = N.g;
float surfFact = 0.0;
if ((windEffect >= 8.0) || (steepness < 0.999))
if ((windEffect >= 8.0) || (steepness < 0.999) || (topoTexel.a > 0.98))
{
if ((waveSlope > 0.0) && (ocean_flag ==1))
{
surfFact = surfFact +(1.0 -smoothstep(0.97,1.0,steepness));
surfFact += 0.5 * smoothstep(0.98,1.0,topoTexel.a);
waveSlope = waveSlope + 2.0 * surfFact;
}
if (waveSlope >= foamSlope){
@ -706,6 +709,10 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
finalColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(mvisibility), finalColor.rgb,transmission);
}
finalColor.rgb = filter_combined(finalColor.rgb);
gl_FragColor = finalColor;

View file

@ -292,6 +292,12 @@ Started September 2000 by David Megginson, david@megginson.com
<landing-light3-offset-deg type="float">0.0</landing-light3-offset-deg>
<use-flashlight type="int">0</use-flashlight>
</als-secondary-lights>
<als-filters>
<use-filtering type="bool">false</use-filtering>
<gamma type="float">0.0</gamma>
<brightness type="float">1.0</brightness>
<use-night-vision type="bool">false</use-night-vision>
</als-filters>
</rendering>
<model-hz type="int">120</model-hz>
<navdb>