From e4be2917be927b877132c276641b46203f042d90 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Tue, 21 Apr 2015 09:01:31 +0300 Subject: [PATCH] Implicit lightmap support for ALS model interior effect --- Effects/model-interior.eff | 46 +++++++++++++++++++++++++--- Shaders/model-interior-ALS-base.frag | 18 ++++++++++- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/Effects/model-interior.eff b/Effects/model-interior.eff index fcc14c4b8..af473b0f8 100644 --- a/Effects/model-interior.eff +++ b/Effects/model-interior.eff @@ -5,7 +5,7 @@ Effects/model-default - + cubemap Aircraft/Generic/Effects/CubeMaps/real.fair-sky/fair-sky_px.png @@ -15,10 +15,16 @@ Aircraft/Generic/Effects/CubeMaps/real.fair-sky/fair-sky_pz.png Aircraft/Generic/Effects/CubeMaps/real.fair-sky/fair-sky_nz.png - - 0.0 0.0 0.0 - 1.0 1.0 1.0 - 0.0 + + 0.0 0.0 0.0 + 1.0 1.0 1.0 + 0.0 + 0 + 1.0 1.0 1.0 + 0.5 + 1.5 + 1.0 1.0 1.0 + 0.0 @@ -154,6 +160,31 @@ angle float opacity-cube-angle + + + tag_color + float-vec3 + implicit-lightmap-tag-color + + + emit_color + float-vec3 + implicit-lightmap-emit-color + + + threshold_low + float + implicit-lightmap-threshold-low + + + threshold_high + float + implicit-lightmap-threshold-high + + + emit_intensity + float + implicit-lightmap-intensity texture @@ -180,6 +211,11 @@ int tquality_level + + implicit_lightmap_enabled + int + implicit-lightmap-enabled + diff --git a/Shaders/model-interior-ALS-base.frag b/Shaders/model-interior-ALS-base.frag index 3d510ff1b..d4407c738 100644 --- a/Shaders/model-interior-ALS-base.frag +++ b/Shaders/model-interior-ALS-base.frag @@ -24,14 +24,20 @@ uniform float overcast; uniform float eye_alt; uniform float cloud_self_shading; uniform float angle; +uniform float threshold_low; +uniform float threshold_high; +uniform float emit_intensity; uniform vec3 offset_vec; uniform vec3 scale_vec; +uniform vec3 tag_color; +uniform vec3 emit_color; uniform int quality_level; uniform int tquality_level; uniform int use_searchlight; +uniform int implicit_lightmap_enabled; const float EarthRadius = 5800000.0; @@ -145,9 +151,19 @@ void main() texel = texture2D(texture, gl_TexCoord[0].st); fragColor = color * texel + specular; - //fragColor.rgb = vec3(1.0,1.0,1.0) * (1.0 - opacity.a); + // implicit lightmap - the user gets to select + if (implicit_lightmap_enabled == 1) + { + float cdiff = (length(texel.rgb - tag_color)); + float enhance = 1.0 - smoothstep(threshold_low, threshold_high, cdiff); + fragColor.rgb = fragColor.rgb + enhance * emit_color * emit_intensity; + } + + + gl_FragColor = fragColor; + }