diff options
Diffstat (limited to 'indra/newview/app_settings')
14 files changed, 122 insertions, 134 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl index 3f3c11517e..2ccd3fd962 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl @@ -30,4 +30,4 @@ out vec4 frag_color; void main() { frag_color = vec4(1.0, 0, 0.5, 0.5); -}
\ No newline at end of file +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index 24faf1763f..e9515a9187 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -44,10 +44,10 @@ uniform mat4 modelview_matrix; out vec3 vary_position; -uniform mat3 texture_basecolor_matrix; -uniform mat3 texture_normal_matrix; -uniform mat3 texture_metallic_roughness_matrix; -uniform mat3 texture_emissive_matrix; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_normal_transform; +uniform vec4[2] texture_metallic_roughness_transform; +uniform vec4[2] texture_emissive_transform; out vec3 vary_fragcoord; @@ -59,7 +59,7 @@ in vec3 normal; in vec4 tangent; in vec2 texcoord0; -out vec2 basecolor_texcoord; +out vec2 base_color_texcoord; out vec2 normal_texcoord; out vec2 metallic_roughness_texcoord; out vec2 emissive_texcoord; @@ -70,7 +70,7 @@ out vec3 vary_tangent; flat out float vary_sign; out vec3 vary_normal; -vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() @@ -89,10 +89,10 @@ void main() vary_fragcoord.xyz = vert.xyz + vec3(0,0,near_clip); - basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0); - normal_texcoord = texture_transform(texcoord0, texture_normal_matrix, texture_matrix0); - metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_matrix, texture_matrix0); - emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0); + base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); + normal_texcoord = texture_transform(texcoord0, texture_normal_transform, texture_matrix0); + metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_transform, texture_matrix0); + emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0); #ifdef HAS_SKIN vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz; @@ -125,19 +125,19 @@ uniform mat4 modelview_matrix; out vec3 vary_position; -uniform mat3 texture_basecolor_matrix; -uniform mat3 texture_emissive_matrix; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_emissive_transform; in vec3 position; in vec4 diffuse_color; in vec2 texcoord0; -out vec2 basecolor_texcoord; +out vec2 base_color_texcoord; out vec2 emissive_texcoord; out vec4 vertex_color; -vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() @@ -147,8 +147,8 @@ void main() gl_Position = vert; vary_position = vert.xyz; - basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0); - emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0); + base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); + emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0); vertex_color = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl index 8dc9e02f7a..1c36aa6b50 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrglowF.glsl @@ -37,7 +37,7 @@ out vec4 frag_color; in vec3 vary_position; in vec4 vertex_emissive; -in vec2 basecolor_texcoord; +in vec2 base_color_texcoord; in vec2 emissive_texcoord; uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() @@ -47,7 +47,7 @@ vec3 srgb_to_linear(vec3 c); void main() { - vec4 basecolor = texture2D(diffuseMap, basecolor_texcoord.xy).rgba; + vec4 basecolor = texture2D(diffuseMap, base_color_texcoord.xy).rgba; if (basecolor.a < minimum_alpha) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl index bcad1c1ceb..82a50a115c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl @@ -34,20 +34,20 @@ uniform mat4 modelview_projection_matrix; uniform mat4 texture_matrix0; -uniform mat3 texture_basecolor_matrix; -uniform mat3 texture_emissive_matrix; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_emissive_transform; in vec3 position; in vec4 emissive; in vec2 texcoord0; -out vec2 basecolor_texcoord; +out vec2 base_color_texcoord; out vec2 emissive_texcoord; out vec4 vertex_emissive; -vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() { @@ -64,8 +64,8 @@ void main() gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); #endif - basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0); - emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0); + base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); + emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0); vertex_emissive = emissive; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index c4c5a7872b..6659e67a7a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -47,7 +47,7 @@ in vec3 vary_normal; in vec3 vary_tangent; flat in float vary_sign; -in vec2 basecolor_texcoord; +in vec2 base_color_texcoord; in vec2 normal_texcoord; in vec2 metallic_roughness_texcoord; in vec2 emissive_texcoord; @@ -62,7 +62,7 @@ uniform mat3 normal_matrix; void main() { - vec4 basecolor = texture2D(diffuseMap, basecolor_texcoord.xy).rgba; + vec4 basecolor = texture2D(diffuseMap, base_color_texcoord.xy).rgba; if (basecolor.a < minimum_alpha) { discard; @@ -121,7 +121,7 @@ out vec4 frag_color; in vec3 vary_position; in vec4 vertex_color; -in vec2 basecolor_texcoord; +in vec2 base_color_texcoord; in vec2 emissive_texcoord; uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() @@ -131,7 +131,7 @@ vec3 srgb_to_linear(vec3 c); void main() { - vec4 basecolor = texture2D(diffuseMap, basecolor_texcoord.xy).rgba; + vec4 basecolor = texture2D(diffuseMap, base_color_texcoord.xy).rgba; if (basecolor.a < minimum_alpha) { discard; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index f0e3d4f034..e2c23ac8f0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -38,10 +38,10 @@ uniform mat4 modelview_projection_matrix; #endif uniform mat4 texture_matrix0; -uniform mat3 texture_basecolor_matrix; -uniform mat3 texture_normal_matrix; -uniform mat3 texture_metallic_roughness_matrix; -uniform mat3 texture_emissive_matrix; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_normal_transform; +uniform vec4[2] texture_metallic_roughness_transform; +uniform vec4[2] texture_emissive_transform; in vec3 position; in vec4 diffuse_color; @@ -49,7 +49,7 @@ in vec3 normal; in vec4 tangent; in vec2 texcoord0; -out vec2 basecolor_texcoord; +out vec2 base_color_texcoord; out vec2 normal_texcoord; out vec2 metallic_roughness_texcoord; out vec2 emissive_texcoord; @@ -60,7 +60,7 @@ out vec3 vary_tangent; flat out float vary_sign; out vec3 vary_normal; -vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() { @@ -78,10 +78,10 @@ void main() gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); #endif - basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0); - normal_texcoord = texture_transform(texcoord0, texture_normal_matrix, texture_matrix0); - metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_matrix, texture_matrix0); - emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0); + base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); + normal_texcoord = texture_transform(texcoord0, texture_normal_transform, texture_matrix0); + metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_transform, texture_matrix0); + emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0); #ifdef HAS_SKIN vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz; @@ -106,29 +106,29 @@ uniform mat4 modelview_projection_matrix; uniform mat4 texture_matrix0; -uniform mat3 texture_basecolor_matrix; -uniform mat3 texture_normal_matrix; -uniform mat3 texture_metallic_roughness_matrix; -uniform mat3 texture_emissive_matrix; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_normal_transform; +uniform vec4[2] texture_metallic_roughness_transform; +uniform vec4[2] texture_emissive_transform; in vec3 position; in vec4 diffuse_color; in vec2 texcoord0; -out vec2 basecolor_texcoord; +out vec2 base_color_texcoord; out vec2 emissive_texcoord; out vec4 vertex_color; -vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() { //transform vertex gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - basecolor_texcoord = texture_transform(texcoord0, texture_basecolor_matrix, texture_matrix0); - emissive_texcoord = texture_transform(texcoord0, texture_emissive_matrix, texture_matrix0); + base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); + emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0); vertex_color = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index f0e940eb5f..cc77712347 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -134,6 +134,7 @@ vec3 toneMap(vec3 color) color *= exposure; #ifdef TONEMAP_ACES_NARKOWICZ + color *= 0.8; color = toneMapACES_Narkowicz(color); #endif @@ -145,7 +146,7 @@ vec3 toneMap(vec3 color) // boost exposure as discussed in https://github.com/mrdoob/three.js/pull/19621 // this factor is based on the exposure correction of Krzysztof Narkowicz in his // implemetation of ACES tone mapping - color /= 0.6; + color *= 0.85/0.6; color = toneMapACES_Hill(color); #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl index b146c665f9..71f7ec52c4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl @@ -23,6 +23,31 @@ * $/LicenseInfo$ */ +// This shader code is taken from the sample code on the KHR_texture_transform +// spec page page, plus or minus some sign error corrections (I think because the GLSL +// matrix constructor is backwards?): +// https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform +// Previously (6494eed242b1), we passed in a single, precalculated matrix +// uniform per transform into the shaders. However, that was found to produce +// small-but-noticeable discrepancies with the GLTF sample model +// "TextureTransformTest", likely due to numerical precision differences. In +// the interest of parity with other renderers, calculate the transform +// directly in the shader. -Cosmic,2023-02-24 +vec2 khr_texture_transform(vec2 texcoord, vec2 scale, float rotation, vec2 offset) +{ + mat3 scale_mat = mat3(scale.x,0,0, 0,scale.y,0, 0,0,1); + mat3 offset_mat = mat3(1,0,0, 0,1,0, offset.x, offset.y, 1); + mat3 rotation_mat = mat3( + cos(rotation),-sin(rotation), 0, + sin(rotation), cos(rotation), 0, + 0, 0, 1 + ); + + mat3 transform = offset_mat * rotation_mat * scale_mat; + + return (transform * vec3(texcoord, 1)).xy; +} + // vertex_texcoord - The UV texture coordinates sampled from the vertex at // runtime. Per SL convention, this is in a right-handed UV coordinate // system. Collada models also have right-handed UVs. @@ -33,20 +58,18 @@ // animations, available through LSL script functions such as // LlSetTextureAnim. It assumes a right-handed UV coordinate system. // texcoord - The final texcoord to use for image sampling -vec2 texture_transform(vec2 vertex_texcoord, mat3 khr_gltf_transform, mat4 sl_animation_transform) +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform) { vec2 texcoord = vertex_texcoord; + // Apply texture animation first to avoid shearing and other artifacts + texcoord = (sl_animation_transform * vec4(texcoord, 0, 1)).xy; // Convert to left-handed coordinate system. The offset of 1 is necessary // for rotations to be applied correctly. - // In the future, we could bake this coordinate conversion into the uniform - // that khr_gltf_transform comes from, since it's applied immediately - // before. texcoord.y = 1.0 - texcoord.y; - texcoord = (khr_gltf_transform * vec3(texcoord, 1.0)).xy; + texcoord = khr_texture_transform(texcoord, khr_gltf_transform[0].xy, khr_gltf_transform[0].z, khr_gltf_transform[1].xy); // Convert back to right-handed coordinate system texcoord.y = 1.0 - texcoord.y; - texcoord = (sl_animation_transform * vec4(texcoord, 0, 1)).xy; // To make things more confusing, all SL image assets are upside-down // We may need an additional sign flip here when we implement a Vulkan backend diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl index 9f7706fe36..45267e4403 100644 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -26,29 +26,11 @@ out vec4 frag_color; uniform sampler2D diffuseRect; -uniform sampler2D depthMap; - -uniform float resScale; -uniform float znear; -uniform float zfar; in vec2 vary_texcoord0; -// get linear depth value given a depth buffer sample d and znear and zfar values -float linearDepth(float d, float znear, float zfar); - void main() { - float depth = texture(depthMap, vary_texcoord0.xy).r; - float dist = linearDepth(depth, znear, zfar); - - // convert linear depth to distance - vec3 v; - v.xy = vary_texcoord0.xy / 512.0 * 2.0 - 1.0; - v.z = 1.0; - v = normalize(v); - dist /= v.z; - vec3 col = texture(diffuseRect, vary_texcoord0.xy).rgb; - frag_color = vec4(col, dist/256.0); + frag_color = vec4(col, 0.0); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index 987b0ca1d5..2a093827cb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -54,7 +54,7 @@ in vec3 vary_fragcoord; in vec3 vary_position; -in vec2 basecolor_texcoord; +in vec2 base_color_texcoord; in vec2 normal_texcoord; in vec2 metallic_roughness_texcoord; in vec2 emissive_texcoord; @@ -168,7 +168,7 @@ void main() waterClip(pos); - vec4 basecolor = texture(diffuseMap, basecolor_texcoord.xy).rgba; + vec4 basecolor = texture(diffuseMap, base_color_texcoord.xy).rgba; basecolor.rgb = srgb_to_linear(basecolor.rgb); #ifdef HAS_ALPHA_MASK if (basecolor.a < minimum_alpha) @@ -267,7 +267,7 @@ out vec4 frag_color; in vec3 vary_position; -in vec2 basecolor_texcoord; +in vec2 base_color_texcoord; in vec2 emissive_texcoord; in vec4 vertex_color; @@ -286,7 +286,7 @@ void main() vec3 pos = vary_position; - vec4 basecolor = texture(diffuseMap, basecolor_texcoord.xy).rgba; + vec4 basecolor = texture(diffuseMap, base_color_texcoord.xy).rgba; basecolor.rgb = srgb_to_linear(basecolor.rgb); #ifdef HAS_ALPHA_MASK if (basecolor.a < minimum_alpha) diff --git a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl index f1ee4b4681..5fa53c374b 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl @@ -34,7 +34,7 @@ uniform mat3 env_mat; vec3 srgb_to_linear(vec3 c); void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool errorCorrect) + vec2 tc, vec3 pos, vec3 norm, float glossiness) { ambenv = vec3(reflection_probe_ambiance * 0.25); @@ -43,11 +43,11 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, glossenv = srgb_to_linear(textureCube(environmentMap, env_vec).rgb); } -void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness) +void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, + vec2 tc, vec3 pos, vec3 norm, float glossiness) { - sampleReflectionProbes(ambenv, glossenv, - tc, pos, norm, glossiness, false); + sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness); + glossenv *= 8.0; } vec4 sampleReflectionProbesDebug(vec3 pos) diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index b00a6ed757..49529860be 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -382,11 +382,6 @@ void main() color.rgb = mix(atmosFragLightingLinear(color.rgb, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), emissive); color.rgb = scaleSoftClipFragLinear(color.rgb); -#ifdef WATER_FOG - vec4 temp = applyWaterFogView(pos, vec4(color, 0.0)); - color = temp.rgb; -#endif - vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0, 0, 0); @@ -400,11 +395,18 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) + light *= 1.0-emissive; color += light; + glare *= 1.0-emissive; glare = min(glare, 1.0); float al = max(diffcol.a, glare) * vertex_color.a; +#ifdef WATER_FOG + vec4 temp = applyWaterFogView(pos, vec4(color, 0.0)); + color = temp.rgb; +#endif + frag_color = vec4(color, al); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 24539c3c3a..23c6f4d5ae 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -542,7 +542,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int } } -vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) +vec3 sampleProbes(vec3 pos, vec3 dir, float lod) { float wsum[2]; wsum[0] = 0; @@ -573,29 +573,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) { - if (errorCorrect && refIndex[i].w >= 0) - { // error correction is on and this probe is a sphere - //take a sample to get depth value, then error correct - refcol = tapRefMap(pos, dir, w, dw, vi, wi, abs(lod + 2), refSphere[i].xyz, i); - - //adjust lookup by distance result - float d = length(vi - wi); - vi += dir * d; - - vi -= refSphere[i].xyz; - - vi = env_mat * vi; - - refcol = textureLod(reflectionProbes, vec4(vi, refIndex[i].x), lod).rgb; - - // weight by vector correctness - vec3 pi = normalize(wi - pos); - w *= max(dot(pi, dir), 0.1); - } - else - { - refcol = tapRefMap(pos, dir, w, dw, vi, wi, lod, refSphere[i].xyz, i); - } + refcol = tapRefMap(pos, dir, w, dw, vi, wi, lod, refSphere[i].xyz, i); col[p] += refcol.rgb*w; wsum[p] += w; @@ -684,7 +662,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir) } void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool errorCorrect) + vec2 tc, vec3 pos, vec3 norm, float glossiness) { // TODO - don't hard code lods float reflection_lods = max_probe_lod; @@ -695,13 +673,12 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, ambenv = sampleProbeAmbient(pos, norm); float lod = (1.0-glossiness)*reflection_lods; - glossenv = sampleProbes(pos, normalize(refnormpersp), lod, errorCorrect); + glossenv = sampleProbes(pos, normalize(refnormpersp), lod); #if defined(SSR) if (cube_snapshot != 1 && glossiness >= 0.9) { vec4 ssr = vec4(0); - //float w = tapScreenSpaceReflection(errorCorrect ? 1 : 4, tc, pos, norm, ssr, sceneMap); float w = tapScreenSpaceReflection(1, tc, pos, norm, ssr, sceneMap); glossenv = mix(glossenv, ssr.rgb, w); @@ -709,6 +686,12 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, #endif } +void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, + vec2 tc, vec3 pos, vec3 norm, float glossiness) +{ + sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness); +} + void debugTapRefMap(vec3 pos, vec3 dir, float depth, int i, inout vec4 col) { vec3 origin = vec3(0,0,0); @@ -749,14 +732,6 @@ vec4 sampleReflectionProbesDebug(vec3 pos) return col; } -void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness) -{ - sampleReflectionProbes(ambenv, glossenv, - tc, pos, norm, glossiness, false); -} - - void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity) { @@ -770,12 +745,12 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; - glossenv = sampleProbes(pos, normalize(refnormpersp), lod, false); + glossenv = sampleProbes(pos, normalize(refnormpersp), lod); } if (envIntensity > 0.0) { - legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, false); + legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0); } #if defined(SSR) diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 631d2c04d0..a87682affb 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -122,11 +122,8 @@ vec3 transform_normal(vec3 vNt) return normalize(vNt.x * vT + vNt.y * vB + vNt.z * vN); } -void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness); - -void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, - vec2 tc, vec3 pos, vec3 norm, float glossiness, bool errorCorrect); +void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, + vec2 tc, vec3 pos, vec3 norm, float glossiness); vec3 getPositionWithNDC(vec3 ndc); @@ -219,16 +216,16 @@ void main() fb = applyWaterFogViewLinear(refPos, fb, sunlit); #else - vec4 fb = applyWaterFogViewLinear(viewVec*2048.0, vec4(0.5), sunlit); + vec4 fb = applyWaterFogViewLinear(viewVec*2048.0, vec4(1.0), sunlit); #endif float metallic = 0.0; - float perceptualRoughness = 0.1; + float perceptualRoughness = 0.05; float gloss = 1.0 - perceptualRoughness; vec3 irradiance = vec3(0); vec3 radiance = vec3(0); - sampleReflectionProbes(irradiance, radiance, distort2, pos.xyz, wave_ibl.xyz, gloss); + sampleReflectionProbesWater(irradiance, radiance, distort2, pos.xyz, wave_ibl.xyz, gloss); irradiance = vec3(0); @@ -265,10 +262,18 @@ void main() f *= 0.9; f *= f; + // incoming scale is [0, 1] with 0.5 being default + // shift to 0.5 to 1.5 + f *= (fresnelScale - 0.5)+1.0; + + // incoming offset is [0, 1] with 0.5 being default + // shift from -1 to 1 + f += (fresnelOffset - 0.5) * 2.0; + f = clamp(f, 0, 1); - //fb.rgb *= 1.; - + color = mix(color, fb.rgb, f); + float spec = min(max(max(punctual.r, punctual.g), punctual.b), 0.05); frag_color = vec4(color, spec); //*sunAngle2); |