1
0
Fork 0

Blend option for ALS urban shader effect

This commit is contained in:
Thorsten Renk 2016-08-05 12:57:21 +03:00
parent 12f4129a0d
commit 6cdc86c9d7
9 changed files with 188 additions and 14 deletions

View file

@ -33,6 +33,8 @@
<fogtype>
<use>/sim/rendering/shaders/skydome</use>
</fogtype>
<urban_blend type="int">0</urban_blend>
<blend_bias type="float">0.4</blend_bias>
<!-- END fog include -->
</parameters>
<generate>
@ -169,7 +171,24 @@
</texture-unit>
<texture-unit>
<unit>3</unit>
<type>noise</type>
<image>
<use>texture[11]/image</use>
</image>
<type>
<use>texture[11]/type</use>
</type>
<filter>
<use>texture[11]/filter</use>
</filter>
<wrap-s>
<use>texture[11]/wrap-s</use>
</wrap-s>
<wrap-t>
<use>texture[11]/wrap-t</use>
</wrap-t>
<internal-format>
<use>texture[11]/internal-format</use>
</internal-format>
</texture-unit>
<program>
<vertex-shader>Shaders/urban-ALS.vert</vertex-shader>
@ -183,10 +202,6 @@
<name>tangent</name>
<index>6</index>
</attribute>
<!--<attribute>
<name>binormal</name>
<index>7</index>
</attribute>-->
<attribute>
<name>normal</name>
<index>15</index>
@ -208,8 +223,8 @@
<value type="int">2</value>
</uniform>
<uniform>
<name>NoiseTex</name>
<type>sampler-3d</type>
<name>BackgroundTex</name>
<type>sampler-2d</type>
<value type="int">3</value>
</uniform>
<uniform>
@ -233,6 +248,13 @@
<use>night-color</use>
</value>
</uniform>
<uniform>
<name>blend_bias</name>
<type>float</type>
<value>
<use>blend_bias</use>
</value>
</uniform>
<uniform>
<name>quality_level</name>
<type>float</type>
@ -250,6 +272,11 @@
<type>int</type>
<value><use>tquality_level</use></value>
</uniform>
<uniform>
<name>urban_blend</name>
<type>int</type>
<value><use>urban_blend</use></value>
</uniform>
<uniform>
<name>snowlevel</name>
<type>float</type>
@ -760,8 +787,26 @@
</texture-unit>
<texture-unit>
<unit>2</unit>
<type>noise</type>
<image>
<use>texture[11]/image</use>
</image>
<type>
<use>texture[11]/type</use>
</type>
<filter>
<use>texture[11]/filter</use>
</filter>
<wrap-s>
<use>texture[11]/wrap-s</use>
</wrap-s>
<wrap-t>
<use>texture[11]/wrap-t</use>
</wrap-t>
<internal-format>
<use>texture[11]/internal-format</use>
</internal-format>
</texture-unit>
<program>
<vertex-shader>Shaders/urban-ALS.vert</vertex-shader>
<fragment-shader>Shaders/urban-ALS.frag</fragment-shader>
@ -1171,8 +1216,8 @@
<value type="int">1</value>
</uniform>
<uniform>
<name>NoiseTex</name>
<type>sampler-3d</type>
<name>BackgroundTex</name>
<type>sampler-2d</type>
<value type="int">2</value>
</uniform>
<uniform>
@ -1196,6 +1241,13 @@
<use>night-color</use>
</value>
</uniform>
<uniform>
<name>blend_bias</name>
<type>float</type>
<value>
<use>blend_bias</use>
</value>
</uniform>
<uniform>
<name>quality_level</name>
<type>float</type>

View file

@ -38,6 +38,45 @@
<load-resistance>1e30</load-resistance>
</material>
<material>
<name>BuiltUpCover</name>
<name>Urban</name>
<effect>Effects/urban</effect>
<texture-set>
<texture>Terrain/city1_overlay.png</texture>
<texture n="2">Terrain/city1-relief-light.png</texture>
<texture n="11">Terrain/dry_pasture4.png</texture>
</texture-set>
<parameters>
<urban_blend>1</urban_blend>
<hires_overlay_bias>-1.0</hires_overlay_bias>
</parameters>
<object-mask>Terrain/city1.mask.png</object-mask>
<object-mask>Terrain/city2.mask.png</object-mask>
<xsize>1000</xsize>
<ysize>1000</ysize>
<light-coverage>100000.0</light-coverage>
<emissive>
<r>0.05</r>
<g>0.05</g>
<b>0.02</b>
<a>1.0</a>
</emissive>
<object-group include="Materials/base/urban-buildings.xml"/>
<building-coverage>2500.0</building-coverage>
<building-small-ratio>0.4</building-small-ratio>
<building-small-min-floors>3</building-small-min-floors>
<building-small-max-width-m>30.0</building-small-max-width-m>
<building-small-min-depth-m>10.0</building-small-min-depth-m>
<building-small-max-depth-m>30.0</building-small-max-depth-m>
<building-medium-ratio>0.6</building-medium-ratio>
<building-large-ratio>0.2</building-large-ratio>
<wood-coverage>250000.0</wood-coverage>
<tree-texture>Trees/mixed-alt.png</tree-texture>
<tree-varieties>8</tree-varieties>
<tree-height-m>25.0</tree-height-m>
<tree-width-m>15.0</tree-width-m>
</material>
<material>

View file

@ -346,9 +346,16 @@
<tree-effect>Effects/tree-european-deciduous</tree-effect>
<effect>Effects/urban</effect>
<texture-set>
<texture>Terrain/18th_century_city.png</texture>
<texture>Terrain/18th_century_city_overlay.png</texture>
<!--<texture n="11">Terrain/dry_pasture4.png</texture>-->
<texture n="2">Terrain/18th_century_city-relief-light.png</texture>
<texture n="11">Terrain/grass_dry3.png</texture>
</texture-set>
<parameters>
<urban_blend>1</urban_blend>
<blend_bias>0.2</blend_bias>
<hires_overlay_bias>-1.0</hires_overlay_bias>
</parameters>
<object-mask>Terrain/18th_century_city.mask.png</object-mask>
<xsize>1000</xsize>
<ysize>1000</ysize>
@ -377,6 +384,33 @@
<tree-width-m>10.0</tree-width-m>
</material>
<material>
<name>Construction</name>
<name>Industrial</name>
<effect>Effects/urban</effect>
<texture-set>
<texture>Terrain/industrial_overlay.png</texture>
<texture n="2">Terrain/industrial-relief-light.png</texture>
<texture n="11">Terrain/grass_dry3.png</texture>
</texture-set>
<parameters>
<urban_blend>1</urban_blend>
<blend_bias>0.2</blend_bias>
<hires_overlay_bias>-1.0</hires_overlay_bias>
</parameters>
<object-mask>Terrain/industrial-mask.png</object-mask>
<xsize>1000</xsize>
<ysize>1000</ysize>
<light-coverage>100000.0</light-coverage>
<emissive>
<r>0.05</r>
<g>0.05</g>
<b>0.02</b>
<a>1.0</a>
</emissive>
<object-group include="Materials/base/industrial-buildings.xml"/>
</material>
<material>
<name>Town</name>
<name>SubUrban</name>

View file

@ -74,7 +74,45 @@
<load-resistance>1e30</load-resistance>
</material>
<material>
<name>BuiltUpCover</name>
<name>Urban</name>
<effect>Effects/urban</effect>
<texture-set>
<texture>Terrain/city1_overlay.png</texture>
<texture n="2">Terrain/city1-relief-light.png</texture>
<texture n="11">Terrain/shrub-hawaii.png</texture>
</texture-set>
<parameters>
<urban_blend>1</urban_blend>
<hires_overlay_bias>-1.0</hires_overlay_bias>
</parameters>
<object-mask>Terrain/city1.mask.png</object-mask>
<object-mask>Terrain/city2.mask.png</object-mask>
<xsize>1000</xsize>
<ysize>1000</ysize>
<light-coverage>100000.0</light-coverage>
<emissive>
<r>0.05</r>
<g>0.05</g>
<b>0.02</b>
<a>1.0</a>
</emissive>
<object-group include="Materials/base/urban-buildings.xml"/>
<building-coverage>2500.0</building-coverage>
<building-small-ratio>0.4</building-small-ratio>
<building-small-min-floors>3</building-small-min-floors>
<building-small-max-width-m>30.0</building-small-max-width-m>
<building-small-min-depth-m>10.0</building-small-min-depth-m>
<building-small-max-depth-m>30.0</building-small-max-depth-m>
<building-medium-ratio>0.6</building-medium-ratio>
<building-large-ratio>0.2</building-large-ratio>
<wood-coverage>250000.0</wood-coverage>
<tree-texture>Trees/mixed-alt.png</tree-texture>
<tree-varieties>8</tree-varieties>
<tree-height-m>25.0</tree-height-m>
<tree-width-m>15.0</tree-width-m>
</material>
<material>
<effect>Effects/landmass-scrub</effect>

View file

@ -61,7 +61,7 @@ mat2 rotMat = mat2 (cos(lightspot_dir1), sin(lightspot_dir1), -sin(lightspot_dir
difference_vec.xy = rotMat * difference_vec.xy;
difference_vec.x/= (1.0 + lightspot_project1);
float lightspot_arg = (1.0 - smoothstep(lightspot_size1/3.0, lightspot_size1, length(difference_vec))) * (1.0 - 0.5* smoothstep(lightspot_size1/3.0, lightspot_size1/(1.0+lightspot_project1), difference_vec.x));
float lightspot_arg = (1.0 - smoothstep(lightspot_size1/3.0, lightspot_size1, length(difference_vec))) * (1.0 - 0.5* smoothstep(lightspot_size1/3.0, lightspot_size1/(1.0+lightspot_project1), -difference_vec.x));
vec3 lightspot_color = vec3 (lightspot_r1,lightspot_g1, lightspot_b1 ) * lightspot_arg;

View file

@ -28,6 +28,8 @@ varying float mie_angle;
uniform sampler2D BaseTex;
uniform sampler2D NormalTex;
uniform sampler2D QDMTex;
uniform sampler2D BackgroundTex;
uniform sampler2D OverlayTex;
uniform float depth_factor;
uniform float tile_size;
uniform float quality_level;
@ -45,6 +47,7 @@ uniform float wetness;
uniform float fogstructure;
uniform float cloud_self_shading;
uniform float air_pollution;
uniform float blend_bias;
uniform float landing_light1_offset;
uniform float landing_light2_offset;
uniform float landing_light3_offset;
@ -59,6 +62,7 @@ uniform int use_landing_light;
uniform int use_alt_landing_light;
uniform int gquality_level;
uniform int tquality_level;
uniform int urban_blend;
const float scale = 1.0;
int linear_search_steps = 10;
@ -272,8 +276,15 @@ void main (void)
vec4 finalColor = texture2D(BaseTex, uv);
vec4 baseTexel = texture2D(BaseTex, uv);
vec4 finalColor = baseTexel;
if (urban_blend == 1)
{
vec4 backgroundTexel = texture2D(BackgroundTex, uv);
finalColor.rgb = mix(backgroundTexel.rgb, baseTexel.rgb, clamp(baseTexel.a - blend_bias, 0.0, 1.0));
}
// texel postprocessing by shader effects

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 KiB