diff --git a/Effects/ws30.eff b/Effects/ws30.eff index f386b7639..bff135719 100644 --- a/Effects/ws30.eff +++ b/Effects/ws30.eff @@ -1450,147 +1450,6 @@ </pass> </technique> - - <!-- Photoscenery --> - <technique n="4"> - <predicate> - <and> - <and> - <property>/sim/rendering/photoscenery/enabled</property> - </and> - <or> - <less-equal> - <value type="float">2.0</value> - <glversion/> - </less-equal> - <and> - <extension-supported>GL_ARB_shader_objects</extension-supported> - <extension-supported>GL_ARB_shading_language_100</extension-supported> - <extension-supported>GL_ARB_vertex_shader</extension-supported> - <extension-supported>GL_ARB_fragment_shader</extension-supported> - </and> - </or> - </and> - </predicate> - - <pass> - <lighting>true</lighting> - <material> - <ambient><use>material/ambient</use></ambient> - <diffuse><use>material/diffuse</use></diffuse> - <specular><use>material/specular</use></specular> - <emissive><use>material/emissive</use></emissive> - <shininess><use>material/shininess</use></shininess> - <color-mode>ambient-and-diffuse</color-mode> - </material> - <blend><use>transparent</use></blend> - <alpha-test><use>transparent</use></alpha-test> - <shade-model>smooth</shade-model> - <cull-face>back</cull-face> - <render-bin> - <bin-number><use>render-bin/bin-number</use></bin-number> - <bin-name><use>render-bin/bin-name</use></bin-name> - </render-bin> - <texture-unit> - <unit>0</unit> - <type><use>texture[0]/type</use></type> - <image><use>texture[0]/image</use></image> - <filter><use>texture[0]/filter</use></filter> - <wrap-s><use>texture[0]/wrap-s</use></wrap-s> - <wrap-t><use>texture[0]/wrap-t</use></wrap-t> - <internal-format><use>texture[0]/internal-format</use></internal-format> - </texture-unit> - <program> - <vertex-shader>Shaders/include_fog.vert</vertex-shader> - <vertex-shader>Shaders/default.vert</vertex-shader> - <vertex-shader>Shaders/shadows-include.vert</vertex-shader> - <fragment-shader>Shaders/ws30-photo.frag</fragment-shader> - <fragment-shader>Shaders/include_fog.frag</fragment-shader> - <fragment-shader>Shaders/shadows-include.frag</fragment-shader> - <fragment-shader>Shaders/clustered-include.frag</fragment-shader> - <attribute> - <name>orthophotoTexCoord</name> - <index>14</index> - </attribute> - </program> - <uniform> - <name>visibility</name> - <type>float</type> - <value><use>visibility</use></value> - </uniform> - <uniform> - <name>avisibility</name> - <type>float</type> - <value><use>avisibility</use></value> - </uniform> - <uniform> - <name>hazeLayerAltitude</name> - <type>float</type> - <value><use>lthickness</use></value> - </uniform> - <uniform> - <name>scattering</name> - <type>float</type> - <value><use>scattering</use></value> - </uniform> - <uniform> - <name>terminator</name> - <type>float</type> - <value><use>terminator</use></value> - </uniform> - <uniform> - <name>fogType</name> - <type>int</type> - <value><use>fogtype</use></value> - </uniform> - <uniform> - <name>texture</name> - <type>sampler-2d</type> - <value type="int">0</value> - </uniform> - <uniform> - <name>colorMode</name> - <type>int</type> - <value>2</value> - <!-- AMBIENT_AND_DIFFUSE --> - </uniform> - <uniform> - <name>orthophotoTexture</name> - <type>sampler-2d</type> - <value type="int">15</value> - </uniform> - <!-- BEGIN shadows include --> - <uniform> - <name>shadow_tex</name> - <type>sampler-2d</type> - <value type="int">10</value> - </uniform> - <uniform> - <name>shadows_enabled</name> - <type>bool</type> - <value> - <use>shadows_enabled</use> - </value> - </uniform> - <uniform> - <name>sun_atlas_size</name> - <type>int</type> - <value> - <use>sun_atlas_size</use> - </value> - </uniform> - <!-- END shadows include --> - <depth> - <function>lequal</function> - <!-- <write-mask type="bool">false</write-mask> --> - </depth> - </pass> - </technique> - - - - - <!-- Non-ALS technique with texture rotation --> <technique n="11"> <predicate> diff --git a/Shaders/ws30-ALS-detailed.frag b/Shaders/ws30-ALS-detailed.frag index d33ade054..9723d5d24 100644 --- a/Shaders/ws30-ALS-detailed.frag +++ b/Shaders/ws30-ALS-detailed.frag @@ -86,7 +86,8 @@ uniform float hires_overlay_bias; uniform int quality_level; uniform int tquality_level; -//uniform bool orthophotoAvailable; +// Passed from VPBTechnique, not the Effect +uniform bool photoScenery; const float EarthRadius = 5800000.0; const float terminator_width = 200000.0; @@ -307,33 +308,31 @@ float noise_2000m = Noise3D(worldPos.xyz, 2000.0); // Look up texture coordinates and scale of ground textures // Landclass for this fragment + if (photoScenery) { + texel = texture(landclass, vec2(gl_TexCoord[0].s, 1.0 - gl_TexCoord[0].t)); + } else { + texel = lookup_ground_texture_array(index, tile_coord, lc, dx, dy); - texel = lookup_ground_texture_array(index, tile_coord, lc, dx, dy); + // Mix texels - to work consistently it needs a more preceptual interpolation than mix() + if (num_unique_neighbors != 0) + { + // Closest neighbor landclass + vec4 texel_closest = lookup_ground_texture_array(index_n[0], tile_coord, lc_n[0], dx, dy); - - // Mix texels - to work consistently it needs a more preceptual interpolation than mix() - if (num_unique_neighbors != 0) - { - // Closest neighbor landclass - vec4 texel_closest = lookup_ground_texture_array(index_n[0], tile_coord, lc_n[0], dx, dy); - - - // Neighbor contributions - vec4 texel_nc=texel_closest; + // Neighbor contributions + vec4 texel_nc=texel_closest; if (num_unique_neighbors > 1) { - // 2nd Closest neighbor landclass - vec4 texel_2nd_closest = lookup_ground_texture_array(index_n[1], tile_coord, lc_n[1], + // 2nd Closest neighbor landclass + vec4 texel_2nd_closest = lookup_ground_texture_array(index_n[1], tile_coord, lc_n[1], dx, dy); - - texel_nc = mix(texel_closest, texel_2nd_closest, mfact[1]); + texel_nc = mix(texel_closest, texel_2nd_closest, mfact[1]); } - texel = mix(texel, texel_nc, mfact[0]); - - + texel = mix(texel, texel_nc, mfact[0]); + } } // Testing code: mix with green to show values of variables at each point diff --git a/Shaders/ws30-ALS-ultra.frag b/Shaders/ws30-ALS-ultra.frag index 704ab1e9c..c1a6f2343 100644 --- a/Shaders/ws30-ALS-ultra.frag +++ b/Shaders/ws30-ALS-ultra.frag @@ -107,7 +107,8 @@ uniform int use_alt_landing_light; // Testing code: Currently hardcoded to 2000, to allow noise functions to run while waiting for landclass lookup(s) uniform int swatch_size; //in metres, typically 1000 or 2000 -//uniform bool orthophotoAvailable; +// Passed from VPBTechnique, not the Effect +uniform bool photoScenery; const float EarthRadius = 5800000.0; const float terminator_width = 200000.0; @@ -402,33 +403,31 @@ float snownoise_50m = mix(noise_50m, slopenoise_100m, clamp(3.0*(1.0-steepness), // Look up texture coordinates and scale of ground textures // Landclass for this fragment + if (photoScenery) { + texel = texture(landclass, vec2(gl_TexCoord[0].s, 1.0 - gl_TexCoord[0].t)); + } else { + texel = lookup_ground_texture_array(index, tile_coord, lc, dx, dy); - texel = lookup_ground_texture_array(index, tile_coord, lc, dx, dy); + // Mix texels - to work consistently it needs a more preceptual interpolation than mix() + if (num_unique_neighbors != 0) + { + // Closest neighbor landclass + vec4 texel_closest = lookup_ground_texture_array(index_n[0], tile_coord, lc_n[0], dx, dy); - - // Mix texels - to work consistently it needs a more preceptual interpolation than mix() - if (num_unique_neighbors != 0) - { - // Closest neighbor landclass - vec4 texel_closest = lookup_ground_texture_array(index_n[0], tile_coord, lc_n[0], dx, dy); - - - // Neighbor contributions - vec4 texel_nc=texel_closest; + // Neighbor contributions + vec4 texel_nc=texel_closest; if (num_unique_neighbors > 1) { - // 2nd Closest neighbor landclass - vec4 texel_2nd_closest = lookup_ground_texture_array(index_n[1], tile_coord, lc_n[1], + // 2nd Closest neighbor landclass + vec4 texel_2nd_closest = lookup_ground_texture_array(index_n[1], tile_coord, lc_n[1], dx, dy); - - texel_nc = mix(texel_closest, texel_2nd_closest, mfact[1]); + texel_nc = mix(texel_closest, texel_2nd_closest, mfact[1]); } - texel = mix(texel, texel_nc, mfact[0]); - - + texel = mix(texel, texel_nc, mfact[0]); + } } // Testing code: mix with green to show values of variables at each point diff --git a/Shaders/ws30-ALS.frag b/Shaders/ws30-ALS.frag index 74f330f9f..d9a6fe25d 100644 --- a/Shaders/ws30-ALS.frag +++ b/Shaders/ws30-ALS.frag @@ -69,6 +69,7 @@ uniform float cloud_self_shading; uniform int tile_level; uniform float tile_width; uniform float tile_height; +uniform bool photoScenery; const float EarthRadius = 5800000.0; const float terminator_width = 200000.0; @@ -269,34 +270,32 @@ void main() // Look up texture coordinates and scale of ground textures - // Landclass for this fragment + if (photoScenery) { + texel = texture(landclass, vec2(gl_TexCoord[0].s, 1.0 - gl_TexCoord[0].t)); + } else { + // Landclass for this fragment + texel = lookup_ground_texture_array(index, tile_coord, lc, dx, dy); - texel = lookup_ground_texture_array(index, tile_coord, lc, dx, dy); + // Mix texels - to work consistently it needs a more preceptual interpolation than mix() + if (num_unique_neighbors != 0) + { + // Closest neighbor landclass + vec4 texel_closest = lookup_ground_texture_array(index_n[0], tile_coord, lc_n[0], dx, dy); - - // Mix texels - to work consistently it needs a more preceptual interpolation than mix() - if (num_unique_neighbors != 0) - { - // Closest neighbor landclass - vec4 texel_closest = lookup_ground_texture_array(index_n[0], tile_coord, lc_n[0], dx, dy); - - - // Neighbor contributions - vec4 texel_nc=texel_closest; + // Neighbor contributions + vec4 texel_nc=texel_closest; if (num_unique_neighbors > 1) { - // 2nd Closest neighbor landclass - vec4 texel_2nd_closest = lookup_ground_texture_array(index_n[1], tile_coord, lc_n[1], + // 2nd Closest neighbor landclass + vec4 texel_2nd_closest = lookup_ground_texture_array(index_n[1], tile_coord, lc_n[1], dx, dy); - - texel_nc = mix(texel_closest, texel_2nd_closest, mfact[1]); + texel_nc = mix(texel_closest, texel_2nd_closest, mfact[1]); } - texel = mix(texel, texel_nc, mfact[0]); - - + texel = mix(texel, texel_nc, mfact[0]); + } } // Testing code: mix with green to show values of variables at each point diff --git a/Shaders/ws30-photo.frag b/Shaders/ws30-photo.frag deleted file mode 100644 index a707c362c..000000000 --- a/Shaders/ws30-photo.frag +++ /dev/null @@ -1,68 +0,0 @@ -// -*-C++-*- - -// Ambient term comes in gl_Color.rgb. -#version 120 - -varying vec4 diffuse_term; -varying vec3 normal; -varying vec2 orthoTexCoord; -varying vec4 ecPosition; - -uniform sampler2D texture; - -////fog "include" ///// -uniform int fogType; - -uniform bool orthophotoAvailable; - -vec3 fog_Func(vec3 color, int type); -////////////////////// - -float getShadowing(); -vec3 getClusteredLightsContribution(vec3 p, vec3 n, vec3 texel); - -float luminance(vec3 color) -{ - return dot(vec3(0.212671, 0.715160, 0.072169), color); -} - -void main() -{ - vec3 n; - float NdotL, NdotHV, fogFactor; - vec4 color = gl_Color; - vec3 lightDir = gl_LightSource[0].position.xyz; - vec3 halfVector = gl_LightSource[0].halfVector.xyz; - vec4 texel; - vec4 fragColor; - vec4 specular = vec4(0.0); - - // If gl_Color.a == 0, this is a back-facing polygon and the - // normal should be reversed. - n = (2.0 * gl_Color.a - 1.0) * normal; - n = normalize(n); - - NdotL = dot(n, lightDir); - if (NdotL > 0.0) { - float shadowmap = getShadowing(); - color += diffuse_term * NdotL * shadowmap; - NdotHV = max(dot(n, halfVector), 0.0); - if (gl_FrontMaterial.shininess > 0.0) - specular.rgb = (gl_FrontMaterial.specular.rgb - * gl_LightSource[0].specular.rgb - * pow(NdotHV, gl_FrontMaterial.shininess) - * shadowmap); - } - color.a = diffuse_term.a; - // This shouldn't be necessary, but our lighting becomes very - // saturated. Clamping the color before modulating by the texture - // is closer to what the OpenGL fixed function pipeline does. - color = clamp(color, 0.0, 1.0); - texel = texture2D(texture, vec2(gl_TexCoord[0].s, 1.0 - gl_TexCoord[0].t)); - - fragColor = color * texel + specular; - fragColor.rgb += getClusteredLightsContribution(ecPosition.xyz, n, texel.rgb); - - fragColor.rgb = fog_Func(fragColor.rgb, fogType); - gl_FragColor = fragColor; -} diff --git a/Shaders/ws30-q1.frag b/Shaders/ws30-q1.frag index e30250686..962535180 100644 --- a/Shaders/ws30-q1.frag +++ b/Shaders/ws30-q1.frag @@ -16,6 +16,7 @@ uniform sampler2D perlin; // Passed from VPBTechnique, not the Effect uniform float tile_width; uniform float tile_height; +uniform bool photoScenery; // See include_fog.frag uniform int fogType; @@ -27,10 +28,8 @@ void main() vec3 halfVector = gl_LightSource[0].halfVector.xyz; vec4 texel; vec4 fragColor; - - // The Landclass for this particular fragment. This can be used to - // index into the atlas textures. - int lc = int(texture2D(landclass, gl_TexCoord[0].st).g * 255.0 + 0.5); + vec4 color = vec4(0.9, 0.9, 0.9, 1.0); + vec4 specular = vec4(0.1, 0.1, 0.1, 1.0); // If gl_Color.a == 0, this is a back-facing polygon and the // normal should be reversed. @@ -39,25 +38,33 @@ void main() float NdotL = dot(n, lightDir); float NdotHV = max(dot(n, halfVector), 0.0); - // Different textures have different have different dimensions. - // Dimensions array is scaled to fit in [0...1.0] in the texture1D, so has to be scaled back up here. - vec4 color = texture(diffuseArray, float(lc)/512.0) * (gl_LightSource[0].ambient + NdotL * gl_LightSource[0].diffuse); - vec4 specular = texture(specularArray, float(lc)/512.0); - vec2 atlas_dimensions = 10000.0 * texture(dimensionsArray, float(lc)/512.0).st; - vec2 atlas_scale = vec2(tile_width / atlas_dimensions.s, tile_height / atlas_dimensions.t ); - vec2 st = atlas_scale * gl_TexCoord[0].st; + if (photoScenery) { + texel = texture(landclass, vec2(gl_TexCoord[0].s, 1.0 - gl_TexCoord[0].t)); + } else { + // The Landclass for this particular fragment. This can be used to + // index into the atlas textures. + int lc = int(texture2D(landclass, gl_TexCoord[0].st).g * 255.0 + 0.5); - // Rotate texture using the perlin texture as a mask to reduce tiling - if (step(0.5, texture(perlin, atlas_scale * gl_TexCoord[0].st / 8.0).r) == 1.0) { - st = vec2(atlas_scale.s * gl_TexCoord[0].t, atlas_scale.t * gl_TexCoord[0].s); + // Different textures have different have different dimensions. + // Dimensions array is scaled to fit in [0...1.0] in the texture1D, so has to be scaled back up here. + //color = texture(diffuseArray, float(lc)/512.0) * (gl_LightSource[0].ambient + NdotL * gl_LightSource[0].diffuse); + //specular = texture(specularArray, float(lc)/512.0); + vec2 atlas_dimensions = 10000.0 * texture(dimensionsArray, float(lc)/512.0).st; + vec2 atlas_scale = vec2(tile_width / atlas_dimensions.s, tile_height / atlas_dimensions.t ); + vec2 st = atlas_scale * gl_TexCoord[0].st; + + // Rotate texture using the perlin texture as a mask to reduce tiling + if (step(0.5, texture(perlin, atlas_scale * gl_TexCoord[0].st / 8.0).r) == 1.0) { + st = vec2(atlas_scale.s * gl_TexCoord[0].t, atlas_scale.t * gl_TexCoord[0].s); + } + + if (step(0.5, texture(perlin, - atlas_scale * gl_TexCoord[0].st / 16.0).r) == 1.0) { + st = -st; + } + + texel = texture(atlas, vec3(st, lc)); } - if (step(0.5, texture(perlin, - atlas_scale * gl_TexCoord[0].st / 16.0).r) == 1.0) { - st = -st; - } - - texel = texture(atlas, vec3(st, lc)); - fragColor = color * texel + pow(NdotHV, gl_FrontMaterial.shininess) * gl_LightSource[0].specular * specular; fragColor.rgb = fog_Func(fragColor.rgb, fogType); diff --git a/Shaders/ws30.frag b/Shaders/ws30.frag index 90c02e362..5bb8248b0 100644 --- a/Shaders/ws30.frag +++ b/Shaders/ws30.frag @@ -15,6 +15,7 @@ uniform sampler1D specularArray; // Passed from VPBTechnique, not the Effect uniform float tile_width; uniform float tile_height; +uniform bool photoScenery; // See include_fog.frag uniform int fogType; @@ -26,10 +27,8 @@ void main() vec3 halfVector = gl_LightSource[0].halfVector.xyz; vec4 texel; vec4 fragColor; - - // The Landclass for this particular fragment. This can be used to - // index into the atlas textures. - int lc = int(texture2D(landclass, gl_TexCoord[0].st).g * 255.0 + 0.5); + vec4 color = vec4(0.9, 0.9, 0.9, 1.0); + vec4 specular = vec4(0.1, 0.1, 0.1, 1.0); // If gl_Color.a == 0, this is a back-facing polygon and the // normal should be reversed. @@ -38,14 +37,22 @@ void main() float NdotL = dot(n, lightDir); float NdotHV = max(dot(n, halfVector), 0.0); - // Different textures have different have different dimensions. - // Dimensions array is scaled to fit in [0...1.0] in the texture1D, so has to be scaled back up here. - vec4 color = texture(diffuseArray, float(lc)/512.0) * (gl_LightSource[0].ambient + NdotL * gl_LightSource[0].diffuse); - vec4 specular = texture(specularArray, float(lc)/512.0); - vec2 atlas_dimensions = 10000.0 * texture(dimensionsArray, float(lc)/512.0).st; - vec2 atlas_scale = vec2(tile_width / atlas_dimensions.s, tile_height / atlas_dimensions.t ); + if (photoScenery) { + texel = texture(landclass, vec2(gl_TexCoord[0].s, 1.0 - gl_TexCoord[0].t)); + } else { + // The Landclass for this particular fragment. This can be used to + // index into the atlas textures. + int lc = int(texture2D(landclass, gl_TexCoord[0].st).g * 255.0 + 0.5); - texel = texture(atlas, vec3(atlas_scale * gl_TexCoord[0].st, lc)); + // Different textures have different have different dimensions. + // Dimensions array is scaled to fit in [0...1.0] in the texture1D, so has to be scaled back up here. + //color = texture(diffuseArray, float(lc)/512.0) * (gl_LightSource[0].ambient + NdotL * gl_LightSource[0].diffuse); + //specular = texture(specularArray, float(lc)/512.0); + vec2 atlas_dimensions = 10000.0 * texture(dimensionsArray, float(lc)/512.0).st; + vec2 atlas_scale = vec2(tile_width / atlas_dimensions.s, tile_height / atlas_dimensions.t ); + + texel = texture(atlas, vec3(atlas_scale * gl_TexCoord[0].st, lc)); + } fragColor = color * texel + pow(NdotHV, gl_FrontMaterial.shininess) * gl_LightSource[0].specular * specular;