1
0
Fork 0

Improved Random building texturesa - Gabo Huerta

Improved textures, lightmaps from Gabo Huerta.
Improved interaction with the urban shader from Thorsten Renk.
This commit is contained in:
Stuart Buchanan 2013-12-28 20:36:49 +00:00
parent 2b6964911f
commit b2f261ea0a
6 changed files with 110 additions and 81 deletions

View file

@ -7,11 +7,13 @@
<use>/environment/snow-level-m</use>
</snow-level>
<depth-factor type="float">0.008</depth-factor>
<night-color type="vec3d">0.75 0.59 0.05</night-color>
<night-color type="vec3d">1 1 0.50</night-color>
<random-buildings type="bool">
<use>/sim/rendering/random-buildings</use>
</random-buildings>
<quality-level>
<use>/sim/rendering/shaders/urban</use>
</quality-level>
<!--fog include-->
<visibility>
<use>/environment/ground-visibility-m</use>
@ -32,7 +34,6 @@
<use>/sim/rendering/shaders/skydome</use>
</fogtype>
<!-- END fog include -->
</parameters>
<generate>
<normal type="int">15</normal>
@ -41,8 +42,6 @@
</generate>
<technique n="1">
<predicate>
<and>
@ -52,10 +51,6 @@
<value type="float">4.0</value>
<float-property>/sim/rendering/shaders/urban</float-property>
</less-equal>
<equal>
<property>/sim/rendering/random-buildings</property>
<value type="bool">false</value>
</equal>
<or>
<less-equal>
<value type="float">2.0</value>
@ -111,7 +106,7 @@
<use>texture[0]/image</use>
</image>
<type>
<use>texture[0]/type</use>
<use>texture[0]/type</use>
</type>
<filter>
<use>texture[0]/filter</use>
@ -132,7 +127,7 @@
<use>texture[2]/image</use>
</image>
<type>
<use>texture[2]/type</use>
<use>texture[2]/type</use>
</type>
<filter>
<use>texture[2]/filter</use>
@ -153,7 +148,7 @@
<use>texture[2]/image</use>
</image>
<type>
<use>texture[2]/type</use>
<use>texture[2]/type</use>
</type>
<filter>nearest-mipmap-nearest</filter>
<wrap-s>
@ -178,7 +173,7 @@
</texture-unit>
<program>
<vertex-shader>Shaders/urban-lightfield.vert</vertex-shader>
<fragment-shader>Shaders/urban-lightfield.frag</fragment-shader>
<attribute>
<name>tangent</name>
@ -255,6 +250,13 @@
<use>max-lod-level</use>
</value>
</uniform>
<uniform>
<name>random_buildings</name>
<type>bool</type>
<value type="bool">
<use>random-buildings</use>
</value>
</uniform>
<!-- BEGIN fog include -->
<uniform>
<name>visibility</name>
@ -341,7 +343,7 @@
<type>float</type>
<value><use>moonlight</use></value>
</uniform>
<!-- END fog include -->
</pass>
</technique>
@ -356,10 +358,6 @@
<value type="float">1.0</value>
<float-property>/sim/rendering/shaders/urban</float-property>
</less-equal>
<equal>
<property>/sim/rendering/random-buildings</property>
<value type="bool">false</value>
</equal>
<or>
<less-equal>
<value type="float">2.0</value>
@ -411,7 +409,7 @@
<use>texture[0]/image</use>
</image>
<type>
<use>texture[0]/type</use>
<use>texture[0]/type</use>
</type>
<filter>
<use>texture[0]/filter</use>
@ -432,7 +430,7 @@
<use>texture[2]/image</use>
</image>
<type>
<use>texture[2]/type</use>
<use>texture[2]/type</use>
</type>
<filter>
<use>texture[2]/filter</use>
@ -544,8 +542,7 @@
<name>fogstructure</name>
<type>float</type>
<value><use>fogstructure</use></value>
</uniform>
</uniform>
<!-- END fog include -->
<uniform>
@ -609,7 +606,13 @@
<value><use>moonlight</use></value>
</uniform>
<uniform>
<name>random_buildings</name>
<type>bool</type>
<value type="bool">
<use>random-buildings</use>
</value>
</uniform>
</pass>
</technique>
@ -624,10 +627,6 @@
<value type="float">4.0</value>
<float-property>/sim/rendering/shaders/urban</float-property>
</less-equal>
<equal>
<property>/sim/rendering/random-buildings</property>
<value type="bool">false</value>
</equal>
<or>
<less-equal>
<value type="float">2.0</value>
@ -675,7 +674,7 @@
<use>texture[0]/image</use>
</image>
<type>
<use>texture[0]/type</use>
<use>texture[0]/type</use>
</type>
<filter>
<use>texture[0]/filter</use>
@ -696,7 +695,7 @@
<use>texture[2]/image</use>
</image>
<type>
<use>texture[2]/type</use>
<use>texture[2]/type</use>
</type>
<filter>
<use>texture[2]/filter</use>
@ -813,6 +812,13 @@
<use>max-lod-level</use>
</value>
</uniform>
<uniform>
<name>random_buildings</name>
<type>bool</type>
<value type="bool">
<use>random-buildings</use>
</value>
</uniform>
</pass>
</technique>
<technique n="7">
@ -824,10 +830,6 @@
<value type="float">1.0</value>
<float-property>/sim/rendering/shaders/urban</float-property>
</less-equal>
<equal>
<property>/sim/rendering/random-buildings</property>
<value type="bool">false</value>
</equal>
<or>
<less-equal>
<value type="float">2.0</value>
@ -871,7 +873,7 @@
<use>texture[0]/image</use>
</image>
<type>
<use>texture[0]/type</use>
<use>texture[0]/type</use>
</type>
<filter>
<use>texture[0]/filter</use>
@ -892,7 +894,7 @@
<use>texture[2]/image</use>
</image>
<type>
<use>texture[2]/type</use>
<use>texture[2]/type</use>
</type>
<filter>
<use>texture[2]/filter</use>
@ -979,6 +981,13 @@
<use>snow-level</use>
</value>
</uniform>
<uniform>
<name>random_buildings</name>
<type>bool</type>
<value type="bool">
<use>random-buildings</use>
</value>
</uniform>
</pass>
</technique>
<technique n="8">
@ -990,10 +999,6 @@
<value type="float">4.0</value>
<float-property>/sim/rendering/shaders/urban</float-property>
</less-equal>
<equal>
<property>/sim/rendering/random-buildings</property>
<value type="bool">false</value>
</equal>
<or>
<less-equal>
<value type="float">2.0</value>
@ -1049,7 +1054,7 @@
<use>texture[0]/image</use>
</image>
<type>
<use>texture[0]/type</use>
<use>texture[0]/type</use>
</type>
<filter>
<use>texture[0]/filter</use>
@ -1070,7 +1075,7 @@
<use>texture[2]/image</use>
</image>
<type>
<use>texture[2]/type</use>
<use>texture[2]/type</use>
</type>
<filter>
<use>texture[2]/filter</use>
@ -1194,6 +1199,13 @@
<use>max-lod-level</use>
</value>
</uniform>
<uniform>
<name>random_buildings</name>
<type>bool</type>
<value type="bool">
<use>random-buildings</use>
</value>
</uniform>
<!-- BEGIN fog include -->
<uniform>
<name>visibility</name>
@ -1249,10 +1261,6 @@
<value type="float">1.0</value>
<float-property>/sim/rendering/shaders/urban</float-property>
</less-equal>
<equal>
<property>/sim/rendering/random-buildings</property>
<value type="bool">false</value>
</equal>
<or>
<less-equal>
<value type="float">2.0</value>
@ -1304,7 +1312,7 @@
<use>texture[0]/image</use>
</image>
<type>
<use>texture[0]/type</use>
<use>texture[0]/type</use>
</type>
<filter>
<use>texture[0]/filter</use>
@ -1325,7 +1333,7 @@
<use>texture[2]/image</use>
</image>
<type>
<use>texture[2]/type</use>
<use>texture[2]/type</use>
</type>
<filter>
<use>texture[2]/filter</use>
@ -1456,8 +1464,6 @@
<use>snow-level</use>
</value>
</uniform>
</pass>
</technique>
</PropertyList>

View file

@ -31,6 +31,7 @@ uniform float depth_factor;
uniform float tile_size;
uniform float quality_level;
uniform float snowlevel;
uniform bool random_buildings;
const float scale = 1.0;
int linear_search_steps = 10;
@ -153,7 +154,9 @@ float ray_intersect_relief(vec2 dp, vec2 ds)
float ray_intersect(vec2 dp, vec2 ds)
{
if ( quality_level >= 4.0 )
if ( random_buildings )
return 0.0;
else if ( quality_level >= 4.0 )
return ray_intersect_QDM( dp, ds );
else
return ray_intersect_relief( dp, ds );
@ -164,13 +167,18 @@ void main (void)
if ( quality_level >= 3.0 ) {
linear_search_steps = 20;
}
float depthfactor = depth_factor;
if ( random_buildings )
depthfactor = 0.0;
vec3 normal = normalize(VNormal);
vec3 tangent = normalize(VTangent);
vec3 binormal = normalize(VBinormal);
vec3 ecPos3 = ecPosition.xyz / ecPosition.w;
vec3 V = normalize(ecPos3);
vec3 s = vec3(dot(V, tangent), dot(V, binormal), dot(normal, -V));
vec2 ds = s.xy * depth_factor / s.z;
vec2 ds = s.xy * depthfactor / s.z;
vec2 dp = gl_TexCoord[0].st - ds;
float d = ray_intersect(dp, ds);
@ -206,7 +214,7 @@ void main (void)
// step(0.8,Nz)*(1.0-emis)*smoothstep(snowlevel+300.0, snowlevel+360.0, (rawpos.z)+nvL[1]*3000.0));
// finalColor *= ambient_light;
vec4 p = vec4( ecPos3 + tile_size * V * (d-1.0) * depth_factor / s.z, 1.0 );
vec4 p = vec4( ecPos3 + tile_size * V * (d-1.0) * depthfactor / s.z, 1.0 );
if (dot(normal,-V) > 0.1) {
vec4 iproj = gl_ProjectionMatrix * p;

View file

@ -39,7 +39,7 @@ uniform float visibility;
uniform float avisibility;
uniform float scattering;
uniform float terminator;
uniform float terrain_alt;
uniform float terrain_alt;
uniform float hazeLayerAltitude;
uniform float overcast;
uniform float eye_alt;
@ -49,6 +49,7 @@ uniform float wetness;
uniform float fogstructure;
uniform float cloud_self_shading;
uniform vec3 night_color;
uniform bool random_buildings;
const float scale = 1.0;
int linear_search_steps = 10;
@ -125,7 +126,7 @@ float interpolatedNoise3D(in float x, in float y, in float z)
float ii1 = simple_interpolate(i1,i2,fractional_x);
float ii2 = simple_interpolate(i3,i4,fractional_x);
return simple_interpolate(ii1 , ii2 , fractional_y);
}
@ -174,9 +175,9 @@ if (alt < 30000.0)
else if (alt < 50000.0)
{
fade_mix = (alt - 30000.0)/20000.0;
return fade_mix * exp(-targ*targ - pow(targ,4.0)) + (1.0 - fade_mix) * exp(-targ - pow(targ,4.0));
return fade_mix * exp(-targ*targ - pow(targ,4.0)) + (1.0 - fade_mix) * exp(-targ - pow(targ,4.0));
}
else
else
{
return exp(- targ * targ - pow(targ,4.0));
}
@ -299,7 +300,9 @@ float ray_intersect_relief(vec2 dp, vec2 ds)
float ray_intersect(vec2 dp, vec2 ds)
{
if ( quality_level >= 4.0 )
if ( random_buildings )
return 0.0;
else if ( quality_level >= 4.0 )
return ray_intersect_QDM( dp, ds );
else
return ray_intersect_relief( dp, ds );
@ -310,6 +313,11 @@ void main (void)
if ( quality_level >= 3.0 ) {
linear_search_steps = 20;
}
float depthfactor = depth_factor;
if ( random_buildings )
depthfactor = 0.0;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
float effective_scattering = min(scattering, cloud_self_shading);
vec3 normal = normalize(VNormal);
@ -319,7 +327,7 @@ void main (void)
vec3 ecPos3 = ecPosition.xyz / ecPosition.w;
vec3 V = normalize(ecPos3);
vec3 s = vec3(dot(V, tangent), dot(V, binormal), dot(normal, -V));
vec2 ds = s.xy * depth_factor / s.z;
vec2 ds = s.xy * depthfactor / s.z;
vec2 dp = gl_TexCoord[0].st - ds;
float d = ray_intersect(dp, ds);
@ -340,7 +348,7 @@ void main (void)
if ( quality_level >= 2.0 ) {
dp += ds * d;
vec3 sl = normalize( vec3( dot( l, tangent ), dot( l, binormal ), dot( -l, normal ) ) );
ds = sl.xy * depth_factor / sl.z;
ds = sl.xy * depthfactor / sl.z;
dp -= ds * d;
float dl = ray_intersect(dp, ds);
if ( dl < d - 0.05 )
@ -357,10 +365,10 @@ void main (void)
emission_factor *= 0.5*pow(tc.r+0.8*tc.g+0.2*tc.b, 2.0) -0.2;
ambient_light += (emission_factor * vec4(night_color, 0.0));
vec4 finalColor = texture2D(BaseTex, uv);
// texel postprocessing by shader effects
@ -388,7 +396,7 @@ if (quality_level > 2)
finalColor *= ambient_light;
vec4 p = vec4( ecPos3 + tile_size * V * (d-1.0) * depth_factor / s.z, 1.0 );
vec4 p = vec4( ecPos3 + tile_size * V * (d-1.0) * depthfactor / s.z, 1.0 );
//finalColor.rgb = fog_Func(finalColor.rgb, fogType);
@ -399,7 +407,7 @@ float dist = length(relPos);
float delta_z = hazeLayerAltitude - eye_alt;
if (dist > max(40.0, 0.04 * min(visibility,avisibility)))
if (dist > max(40.0, 0.04 * min(visibility,avisibility)))
{
alt = eye_alt;
@ -422,7 +430,7 @@ float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
if (delta_z > 0.0) // we're inside the layer
{
if (ct < 0.0) // we look down
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
@ -434,26 +442,26 @@ if (delta_z > 0.0) // we're inside the layer
if (H > delta_z) {distance_in_layer = dist/H * delta_z;}
else {distance_in_layer = dist;}
vAltitude = min(distance_in_layer,visibility) * ct;
delta_zv = delta_z - vAltitude;
delta_zv = delta_z - vAltitude;
}
}
else // we see the layer from above, delta_z < 0.0
{
{
H = dist * -ct;
if (H < (-delta_z)) // we don't see into the layer at all, aloft visibility is the only fading
{
distance_in_layer = 0.0;
delta_zv = 0.0;
}
}
else
{
vAltitude = H + delta_z;
distance_in_layer = vAltitude/H * dist;
distance_in_layer = vAltitude/H * dist;
vAltitude = min(distance_in_layer,visibility) * (-ct);
delta_zv = vAltitude;
}
}
}
// ground haze cannot be thinner than aloft visibility in the model,
// so we need to use aloft visibility otherwise
@ -481,7 +489,7 @@ if (visibility < avisibility)
eqColorFactor = 1.0 - 0.1 * delta_zv/visibility - (1.0 - effective_scattering);
}
else
else
{
if (quality_level > 3)
{
@ -521,7 +529,7 @@ eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + term
{
intensity = length(hazeColor);
float mie_magnitude = 0.5 * smoothstep(350000.0, 150000.0, terminator-sqrt(2.0 * EarthRadius * terrain_alt));
hazeColor = intensity * ((1.0 - mie_magnitude) + mie_magnitude * mie_angle) * normalize(mix(hazeColor, vec3 (0.5, 0.58, 0.65), mie_magnitude * (0.5 - 0.5 * mie_angle)) );
hazeColor = intensity * ((1.0 - mie_magnitude) + mie_magnitude * mie_angle) * normalize(mix(hazeColor, vec3 (0.5, 0.58, 0.65), mie_magnitude * (0.5 - 0.5 * mie_angle)) );
}
@ -534,7 +542,7 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
if (lightArg < 10.0)
{
float mie_magnitude = 0.5 * smoothstep(350000.0, 150000.0, terminator-sqrt(2.0 * EarthRadius * terrain_alt));
hazeColor = intensity * ((1.0 - mie_magnitude) + mie_magnitude * mie_angle) * normalize(mix(hazeColor, vec3 (0.5, 0.58, 0.65), mie_magnitude * (0.5 - 0.5 * mie_angle)) );
hazeColor = intensity * ((1.0 - mie_magnitude) + mie_magnitude * mie_angle) * normalize(mix(hazeColor, vec3 (0.5, 0.58, 0.65), mie_magnitude * (0.5 - 0.5 * mie_angle)) );
}
// high altitude desaturation of the haze color
@ -543,16 +551,16 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
// blue hue of haze
hazeColor.x = hazeColor.x * 0.83;
hazeColor.y = hazeColor.y * 0.9;
hazeColor.y = hazeColor.y * 0.9;
// additional blue in indirect light
float fade_out = max(0.65 - 0.3 *overcast, 0.45);
intensity = length(hazeColor);
hazeColor = intensity * normalize(mix(hazeColor, 1.5* shadedFogColor, 1.0 -smoothstep(0.25, fade_out,eShade) ));
hazeColor = intensity * normalize(mix(hazeColor, 1.5* shadedFogColor, 1.0 -smoothstep(0.25, fade_out,eShade) ));
// change haze color to blue hue for strong fogging
hazeColor = intensity * normalize(mix(hazeColor, shadedFogColor, (1.0-smoothstep(0.5,0.9,eqColorFactor))));
hazeColor = intensity * normalize(mix(hazeColor, shadedFogColor, (1.0-smoothstep(0.5,0.9,eqColorFactor))));
// reduce haze intensity when looking at shaded surfaces, only in terminator region
@ -567,7 +575,7 @@ finalColor.xyz = mix(eqColorFactor * hazeColor * eShade, finalColor.xyz,transmis
gl_FragColor = finalColor;
}
else // if dist < threshold no fogging at all
else // if dist < threshold no fogging at all
{
gl_FragColor = finalColor;
}

View file

@ -31,6 +31,7 @@ uniform float tile_size;
uniform float quality_level;
uniform float snowlevel;
uniform vec3 night_color;
uniform bool random_buildings;
const float scale = 1.0;
int linear_search_steps = 10;
@ -156,7 +157,9 @@ float ray_intersect_relief(vec2 dp, vec2 ds)
float ray_intersect(vec2 dp, vec2 ds)
{
if ( quality_level >= 4.0 )
if ( random_buildings )
return 0.0;
else if ( quality_level >= 4.0 )
return ray_intersect_QDM( dp, ds );
else
return ray_intersect_relief( dp, ds );
@ -167,6 +170,10 @@ void main (void)
if ( quality_level >= 3.0 ) {
linear_search_steps = 20;
}
float depthfactor = depth_factor;
if ( random_buildings ) depthfactor = 0.0;
vec3 normal = normalize(VNormal);
vec3 tangent = normalize(VTangent);
//vec3 binormal = normalize(VBinormal);
@ -174,7 +181,7 @@ void main (void)
vec3 ecPos3 = ecPosition.xyz / ecPosition.w;
vec3 V = normalize(ecPos3);
vec3 s = vec3(dot(V, tangent), dot(V, binormal), dot(normal, -V));
vec2 ds = s.xy * depth_factor / s.z;
vec2 ds = s.xy * depthfactor / s.z;
vec2 dp = gl_TexCoord[0].st - ds;
float d = ray_intersect(dp, ds);
@ -195,7 +202,7 @@ void main (void)
if ( quality_level >= 2.0 ) {
dp += ds * d;
vec3 sl = normalize( vec3( dot( l, tangent ), dot( l, binormal ), dot( -l, normal ) ) );
ds = sl.xy * depth_factor / sl.z;
ds = sl.xy * depthfactor / sl.z;
dp -= ds * d;
float dl = ray_intersect(dp, ds);
if ( dl < d - 0.05 )
@ -232,7 +239,7 @@ void main (void)
step(0.8,Nz)*(1.0-emis)*smoothstep(snowlevel+300.0, snowlevel+360.0, (rawpos.z)+nvL[1]*3000.0));
finalColor *= ambient_light;
vec4 p = vec4( ecPos3 + tile_size * V * (d-1.0) * depth_factor / s.z, 1.0 );
vec4 p = vec4( ecPos3 + tile_size * V * (d-1.0) * depthfactor / s.z, 1.0 );
finalColor.rgb = fog_Func(finalColor.rgb, fogType);
gl_FragColor = finalColor;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 KiB

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 784 KiB

After

Width:  |  Height:  |  Size: 2.7 MiB