1
0
Fork 0

Generic secondary lights (landing light and searchlight) for ALS

This commit is contained in:
Thorsten Renk 2014-10-05 14:08:29 +03:00
parent 379d3c1437
commit 33d1d8c70d
8 changed files with 187 additions and 22 deletions

View file

@ -23,7 +23,6 @@
<grit_alpha>1.0</grit_alpha>
<overlay_bias>0.0</overlay_bias>
<overlay_alpha>1.0</overlay_alpha>
<use_headlight>0</use_headlight>
</parameters>
<technique n="2">
@ -115,7 +114,7 @@
</texture-unit>
<program>
<vertex-shader>Shaders/terrain-haze-ultra.vert</vertex-shader>
<fragment-shader>Shaders/airfield.frag</fragment-shader>
<fragment-shader>Shaders/airfield-ALS.frag</fragment-shader>
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader>Shaders/noise.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
@ -221,6 +220,21 @@
<type>float</type>
<value><use>air_pollution</use></value>
</uniform>
<uniform>
<name>view_pitch_offset</name>
<type>float</type>
<value><use>view_pitch_offset</use></value>
</uniform>
<uniform>
<name>view_heading_offset</name>
<type>float</type>
<value><use>view_heading_offset</use></value>
</uniform>
<uniform>
<name>field_of_view</name>
<type>float</type>
<value><use>view_fov</use></value>
</uniform>
<uniform>
<name>cloudpos1_x</name>
<type>float</type>
@ -442,9 +456,24 @@
<value> <use>use_overlay</use></value>
</uniform>
<uniform>
<name>use_headlight</name>
<name>use_searchlight</name>
<type>int</type>
<value> <use>use_headlight</use></value>
<value> <use>use_searchlight</use></value>
</uniform>
<uniform>
<name>use_landing_light</name>
<type>int</type>
<value> <use>use_landing_light</use></value>
</uniform>
<uniform>
<name>display_xsize</name>
<type>int</type>
<value><use>display_xsize</use></value>
</uniform>
<uniform>
<name>display_ysize</name>
<type>int</type>
<value><use>display_ysize</use></value>
</uniform>
<uniform>
<name>texture</name>

View file

@ -84,7 +84,6 @@
<moonlight><use>/environment/moonlight</use></moonlight>
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
<use_headlight>0</use_headlight>
<!-- END fog include -->
</parameters>
<generate>
@ -161,7 +160,7 @@
</texture-unit>
<program>
<vertex-shader>Shaders/terrain-haze-ultra.vert</vertex-shader>
<fragment-shader>Shaders/runway-lightfield.frag</fragment-shader>
<fragment-shader>Shaders/runway-ALS.frag</fragment-shader>
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader>Shaders/noise.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
@ -262,6 +261,21 @@
<type>float</type>
<value><use>air_pollution</use></value>
</uniform>
<uniform>
<name>view_pitch_offset</name>
<type>float</type>
<value><use>view_pitch_offset</use></value>
</uniform>
<uniform>
<name>view_heading_offset</name>
<type>float</type>
<value><use>view_heading_offset</use></value>
</uniform>
<uniform>
<name>field_of_view</name>
<type>float</type>
<value><use>view_fov</use></value>
</uniform>
<uniform>
<name>cloudpos1_x</name>
<type>float</type>
@ -478,9 +492,24 @@
<value><use>tquality_level</use></value>
</uniform>
<uniform>
<name>use_headlight</name>
<name>use_searchlight</name>
<type>int</type>
<value> <use>use_headlight</use></value>
<value> <use>use_searchlight</use></value>
</uniform>
<uniform>
<name>use_landing_light</name>
<type>int</type>
<value> <use>use_landing_light</use></value>
</uniform>
<uniform>
<name>display_xsize</name>
<type>int</type>
<value><use>display_xsize</use></value>
</uniform>
<uniform>
<name>display_ysize</name>
<type>int</type>
<value><use>display_ysize</use></value>
</uniform>
<uniform>
<name>texture</name>

View file

@ -116,6 +116,13 @@
<wind_effects><use>/sim/rendering/shaders/wind-effects</use></wind_effects>
<windE><use>/environment/sea/surface/wind-from-east-fps</use></windE>
<windN><use>/environment/sea/surface/wind-from-north-fps</use></windN>
<display_xsize><use>/sim/startup/xsize</use></display_xsize>
<display_ysize><use>/sim/startup/ysize</use></display_ysize>
<view_pitch_offset><use>/sim/current-view/pitch-offset-deg</use></view_pitch_offset>
<view_heading_offset><use>/sim/current-view/heading-offset-deg</use></view_heading_offset>
<view_fov><use>/sim/current-view/field-of-view</use></view_fov>
<use_searchlight><use>/sim/rendering/als-secondary-lights/use-searchlight</use></use_searchlight>
<use_landing_light><use>/sim/rendering/als-secondary-lights/use-landing-light</use></use_landing_light>
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
@ -295,6 +302,7 @@
<fragment-shader>Shaders/noise.frag</fragment-shader>
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
</program>
<uniform>
<name>grain_strength</name>
@ -436,6 +444,21 @@
<type>float</type>
<value><use>air_pollution</use></value>
</uniform>
<uniform>
<name>view_pitch_offset</name>
<type>float</type>
<value><use>view_pitch_offset</use></value>
</uniform>
<uniform>
<name>view_heading_offset</name>
<type>float</type>
<value><use>view_heading_offset</use></value>
</uniform>
<uniform>
<name>field_of_view</name>
<type>float</type>
<value><use>view_fov</use></value>
</uniform>
<uniform>
<name>cloudpos1_x</name>
<type>float</type>
@ -646,6 +669,26 @@
<type>float</type>
<value><use>windN</use></value>
</uniform>
<uniform>
<name>use_searchlight</name>
<type>int</type>
<value> <use>use_searchlight</use></value>
</uniform>
<uniform>
<name>use_landing_light</name>
<type>int</type>
<value> <use>use_landing_light</use></value>
</uniform>
<uniform>
<name>display_xsize</name>
<type>int</type>
<value><use>display_xsize</use></value>
</uniform>
<uniform>
<name>display_ysize</name>
<type>int</type>
<value><use>display_ysize</use></value>
</uniform>
<uniform>
<name>quality_level</name>
<type>int</type>

View file

@ -38,7 +38,8 @@ uniform int quality_level;
uniform int tquality_level;
uniform int cloud_shadow_flag;
uniform int use_overlay;
uniform int use_headlight;
uniform int use_searchlight;
uniform int use_landing_light;
const float EarthRadius = 5800000.0;
const float terminator_width = 200000.0;
@ -54,7 +55,8 @@ float fog_func (in float targ, in float alt);
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
float alt_factor(in float eye_alt, in float vertex_alt);
vec3 rayleigh_out_shift(in vec3 color, in float outscatter);
vec3 headlight(in float dist);
vec3 searchlight(in float dist);
vec3 landing_light(in float dist);
float light_func (in float x, in float a, in float b, in float c, in float d, in float e)
{
@ -266,9 +268,13 @@ if (quality_level > 3)
if (use_headlight == 1)
if (use_searchlight == 1)
{
color.rgb += headlight(dist);
color.rgb += searchlight(dist);
}
if (use_landing_light == 1)
{
color.rgb += landing_light(dist);
}
fragColor = color * texel + specular;

View file

@ -35,7 +35,8 @@ uniform float uvstretch;
uniform int quality_level;
uniform int tquality_level;
uniform int cloud_shadow_flag;
uniform int use_headlight;
uniform int use_searchlight;
uniform int use_landing_light;
const float EarthRadius = 5800000.0;
const float terminator_width = 200000.0;
@ -48,8 +49,8 @@ float mie_angle;
float shadow_func (in float x, in float y, in float noise, in float dist);
float Noise2D(in vec2 coord, in float wavelength);
float fog_func (in float targ, in float alt);
vec3 headlight(in float dist);
vec3 searchlight(in float dist);
vec3 landing_light(in float dist);
@ -245,9 +246,13 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
// is closer to what the OpenGL fixed function pipeline does.
color = clamp(color, 0.0, 1.0);
if (use_headlight == 1)
if (use_searchlight == 1)
{
color.rgb += headlight(dist);
color.rgb += searchlight(dist);
}
if (use_landing_light == 1)
{
color.rgb += landing_light(dist);
}
fragColor = color * texel + specular;

View file

@ -1,9 +1,15 @@
// -*-C++-*-
vec3 headlight(in float dist)
uniform int display_xsize;
uniform int display_ysize;
uniform float field_of_view;
uniform float view_pitch_offset;
uniform float view_heading_offset;
vec3 searchlight(in float dist)
{
vec2 center = vec2 (600.0, 400.0);
vec2 center = vec2 (float(display_xsize) * 0.5, float(display_ysize) * 0.4);
float angularDist;
float headlightIntensity;
@ -11,7 +17,39 @@ angularDist = length(gl_FragCoord.xy -center);
if (angularDist <200.0)
{
headlightIntensity = pow(cos(angularDist/200.0 * 3.1415/2.0),2.0);
headlightIntensity = headlightIntensity * min(1.0, 1000.0/(dist*dist));
headlightIntensity = headlightIntensity * min(1.0, 10000.0/(dist*dist));
return headlightIntensity * vec3 (0.5,0.5, 0.5);
}
else return vec3 (0.0,0.0,0.0);
}
vec3 landing_light(in float dist)
{
float fov_h = field_of_view;
float fov_v = float(display_ysize)/float(display_xsize) * field_of_view;
float yaw_offset;
if (view_heading_offset > 180.0)
{yaw_offset = -360.0+view_heading_offset;}
else
{yaw_offset = view_heading_offset;}
float x_offset = (float(display_xsize) / fov_h * yaw_offset);
float y_offset = -(float(display_ysize) / fov_v * view_pitch_offset);
vec2 center = vec2 (float(display_xsize) * 0.5 + x_offset, float(display_ysize) * 0.4 + y_offset);
float angularDist;
float headlightIntensity;
angularDist = length(gl_FragCoord.xy -center);
if (angularDist <200.0)
{
headlightIntensity = pow(cos(angularDist/200.0 * 3.1415/2.0),2.0);
headlightIntensity = headlightIntensity * min(1.0, 10000.0/(dist*dist));
return headlightIntensity * vec3 (0.5,0.5, 0.5);
}
else return vec3 (0.0,0.0,0.0);

View file

@ -59,6 +59,8 @@ uniform int tquality_level;
uniform int wind_effects;
uniform int cloud_shadow_flag;
uniform int rock_strata;
uniform int use_searchlight;
uniform int use_landing_light;
const float EarthRadius = 5800000.0;
const float terminator_width = 200000.0;
@ -78,6 +80,8 @@ float fog_func (in float targ, in float alt);
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
float alt_factor(in float eye_alt, in float vertex_alt);
vec3 rayleigh_out_shift(in vec3 color, in float outscatter);
vec3 searchlight(in float dist);
vec3 landing_light(in float dist);
float light_func (in float x, in float a, in float b, in float c, in float d, in float e)
{
@ -456,7 +460,14 @@ if ((dist < 5000.0)&& (quality_level > 3) && (combined_wetness>0.0))
// is closer to what the OpenGL fixed function pipeline does.
color = clamp(color, 0.0, 1.0);
if (use_searchlight == 1)
{
color.rgb += searchlight(dist);
}
if (use_landing_light == 1)
{
color.rgb += landing_light(dist);
}
fragColor = color * texel + specular;

View file

@ -287,6 +287,10 @@ Started September 2000 by David Megginson, david@megginson.com
<!-- OSG default is 300, but this means we burn lots of memory on no-longer
visible trees / random buildings -->
<max-paged-lod type="int">16</max-paged-lod>
<als-secondary-lights>
<use-searchlight type="bool">false</use-searchlight>
<use-landing-light type="bool">false</use-landing-light>
</als-secondary-lights>
</rendering>
<model-hz type="int">120</model-hz>
<navdb>