From d8dd4d9c0cd4554704cbe15b5502f4d87a4674ad Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 27 Jun 2023 20:01:52 -0700 Subject: Just about got hero reflection maps working. DRTVWR-583 --- .../shaders/class3/deferred/reflectionProbeF.glsl | 8 ++++++++ .../app_settings/shaders/class3/deferred/softenLightF.glsl | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 1b2a34ef01..298ddf92a7 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -31,6 +31,7 @@ float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, uniform samplerCubeArray reflectionProbes; uniform samplerCubeArray irradianceProbes; + uniform sampler2D sceneMap; uniform int cube_snapshot; uniform float max_probe_lod; @@ -70,6 +71,9 @@ layout (std140) uniform ReflectionProbes // number of reflection probes present in refSphere int refmapCount; + + vec4 heroPosition[1]; + int heroProbeCount; }; // Inputs @@ -513,6 +517,10 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, v = env_mat * v; +#if defined(HERO_PROBES) + vec3 mirror = textureLod(heroProbes, vec4(v.xyz, 0), lod).rgb; +#endif + vec4 ret = textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), lod) * refParams[i].y; return ret.rgb; diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 4ef003e0cb..a63d445115 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -32,6 +32,14 @@ uniform sampler2D specularRect; uniform sampler2D normalMap; uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform samplerCubeArray heroProbes; + +layout (std140) uniform HeroProbeData +{ + vec4 heroPosition[1]; + int heroProbeCount; +}; + const float M_PI = 3.14159265; #if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) @@ -290,7 +298,7 @@ void main() vec4 fogged = applyWaterFogViewLinear(pos.xyz, vec4(color, bloom)); color = fogged.rgb; #endif - - frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results + frag_color.rgb = textureLod(heroProbes, vec4(norm.xyz, 0), 0).rgb; + //frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results frag_color.a = 0.0; } -- cgit v1.2.3 From f7f9601567ce089f3335407f1d3c7d32dbb18c60 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 17 Jul 2023 15:05:47 -0700 Subject: Got hero probes rendering from the camera. DRTVWR-583 --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index a63d445115..d8118fab82 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -117,8 +117,8 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 additive, vec3 atten); -vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, - float perceptualRoughness, +vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, + float perceptualRoughness, float metallic, vec3 n, // normal vec3 v, // surface point to camera @@ -193,7 +193,7 @@ void main() if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 orm = texture(specularRect, tc).rgb; + vec3 orm = texture(specularRect, tc).rgb; float perceptualRoughness = orm.g; float metallic = orm.b; float ao = orm.r; @@ -298,7 +298,6 @@ void main() vec4 fogged = applyWaterFogViewLinear(pos.xyz, vec4(color, bloom)); color = fogged.rgb; #endif - frag_color.rgb = textureLod(heroProbes, vec4(norm.xyz, 0), 0).rgb; - //frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results + frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results frag_color.a = 0.0; } -- cgit v1.2.3 From 3d73326516c73f880f46e28f14b6c515307ede91 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 18 Jul 2023 00:14:34 -0700 Subject: Fix for irradiance breaking. Still need to fix the problem with individual faces getting tossed around though. Will work on that tomorrow. DRTVWR-583 --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index d8118fab82..0152c0612a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -217,6 +217,7 @@ void main() { color = atmosFragLightingLinear(color, additive, atten); } + color = texture(heroProbes, vec4(norm.xyz * env_mat, 0), 0).xyz; } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { @@ -291,9 +292,7 @@ void main() color = atmosFragLightingLinear(color, additive, atten); } } - - #ifdef WATER_FOG vec4 fogged = applyWaterFogViewLinear(pos.xyz, vec4(color, bloom)); color = fogged.rgb; -- cgit v1.2.3 From b861832102abf469963bd3c56f7b009ba4432d6a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sun, 6 Aug 2023 23:33:29 -0700 Subject: Making more progress, need to add the heroprobe manager. DRTVWR-583 --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 0152c0612a..e485c26e9b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -217,7 +217,9 @@ void main() { color = atmosFragLightingLinear(color, additive, atten); } - color = texture(heroProbes, vec4(norm.xyz * env_mat, 0), 0).xyz; + + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + color = texture(heroProbes, vec4(env_mat * refnormpersp, 0), 0).xyz; } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { -- cgit v1.2.3 From 0eba1396dcc7ec5c32124dbfd48abb75c1a5b524 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 21 Aug 2023 07:59:06 -0700 Subject: Experiment with placement a bit when there's no drawable. DRTVWR-583 --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index e485c26e9b..742b52b074 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -213,13 +213,14 @@ void main() vec3 v = -normalize(pos.xyz); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; + if (do_atmospherics) { color = atmosFragLightingLinear(color, additive, atten); } - vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - color = texture(heroProbes, vec4(env_mat * refnormpersp, 0), 0).xyz; } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { -- cgit v1.2.3 From 25aee5e983a8de712565d8241cbdb18da832a4d1 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 8 Sep 2023 15:54:52 -0700 Subject: Some more modes for mirrors to place the probe. DRTVWR-583 --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 742b52b074..2483355205 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -280,6 +280,9 @@ void main() // add radiance map applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz); + + color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - spec.a) * 11).xyz * spec.rgb; + } color.rgb = mix(color.rgb, baseColor.rgb, baseColor.a); -- cgit v1.2.3 From 1433434bf134b76220fa2c31c16f36459b463e32 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 8 Sep 2023 23:01:16 -0700 Subject: Update reflectionProbeF.glsl DRTVWR-583 --- .../app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index adbf7abdd1..549ac50280 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -71,9 +71,6 @@ layout (std140) uniform ReflectionProbes // number of reflection probes present in refSphere int refmapCount; - - vec4 heroPosition[1]; - int heroProbeCount; }; // Inputs @@ -523,10 +520,6 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, v = env_mat * v; -#if defined(HERO_PROBES) - vec3 mirror = textureLod(heroProbes, vec4(v.xyz, 0), lod).rgb; -#endif - vec4 ret = textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), lod) * refParams[i].y; return ret.rgb; -- cgit v1.2.3 From e841c73a9972fc184487c061e8a80add3a18aff1 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 16 Oct 2023 08:45:48 -0700 Subject: Tons of masking changes and tweaks. We now support masking mirrors in the GBuffer. We also now support the concept of one arbitrary clip plane. DRTVWR-583 --- .../shaders/class3/deferred/materialF.glsl | 30 +++++++++++++++++++--- .../shaders/class3/deferred/softenLightF.glsl | 6 +++-- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 319f2f25b7..af49e76984 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -51,6 +51,23 @@ vec3 linear_to_srgb(vec3 cs); vec3 legacy_adjust(vec3 c); vec3 legacy_adjust_fullbright(vec3 c); +uniform vec4 clipPlane; +uniform float clipSign; +uniform float mirror_flag; +void applyClip(vec3 pos) +{ + float funnyClip = 0; + if (mirror_flag > 0) + { + if ((dot(pos.xyz, clipPlane.xyz) + clipPlane.w) > 0.0) + { + discard; + } + } +} + +in vec3 vary_position; + #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) out vec4 frag_color; @@ -72,12 +89,12 @@ uniform vec4 morphFactor; uniform vec3 camPosLocal; uniform mat3 env_mat; +uniform float is_mirror; + uniform vec3 sun_dir; uniform vec3 moon_dir; in vec2 vary_fragcoord; -in vec3 vary_position; - uniform mat4 proj_mat; uniform mat4 inv_proj; uniform vec2 screen_res; @@ -291,6 +308,7 @@ float getShadow(vec3 pos, vec3 norm) void main() { + applyClip(vary_position); waterClip(); // diffcol == diffuse map combined with vertex color @@ -419,9 +437,15 @@ void main() #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer // deferred path // See: C++: addDeferredAttachment(), shader: softenLightF.glsl + + float flag = GBUFFER_FLAG_HAS_ATMOS; + + if (mirror_flag > 0) + flag = 1; + frag_data[0] = vec4(diffcol.rgb, emissive); // gbuffer is sRGB for legacy materials frag_data[1] = vec4(spec.rgb, glossiness); // XYZ = Specular color. W = Specular exponent. - frag_data[2] = vec4(encode_normal(norm), env, GBUFFER_FLAG_HAS_ATMOS);; // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) + frag_data[2] = vec4(encode_normal(norm), env, flag);; // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) frag_data[3] = vec4(0); #endif } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 20a5ad66b6..d42388ae78 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -191,7 +191,7 @@ void main() vec3 irradiance = vec3(0); vec3 radiance = vec3(0); - if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) + if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR) || GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR)) { vec3 orm = texture(specularRect, tc).rgb; float perceptualRoughness = orm.g; @@ -214,7 +214,9 @@ void main() color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; + + if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR)) + color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; if (do_atmospherics) { -- cgit v1.2.3 From 4d39d889976dcc3b7aa7098bc70ab7ebb881c0a8 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 24 Jan 2024 15:50:13 -0800 Subject: https://github.com/secondlife/viewer/issues/671 Wire up the RenderMirrors debug setting. --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index f5541df227..79d9000482 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -34,11 +34,13 @@ uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal uniform samplerCubeArray heroProbes; +#if defined(HERO_PROBES) layout (std140) uniform HeroProbeData { vec4 heroPosition[1]; int heroProbeCount; }; +#endif const float M_PI = 3.14159265; @@ -196,15 +198,12 @@ void main() vec3 v = -normalize(pos.xyz); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); + #ifdef HERO_PROBES vec3 refnormpersp = reflect(pos.xyz, norm.xyz); if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR)) color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; - - if (do_atmospherics) - { - color = atmosFragLightingLinear(color, additive, atten); - } + #endif } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { @@ -263,7 +262,9 @@ void main() // add radiance map applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz); + #ifdef HERO_PROBES color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - spec.a) * 11).xyz * spec.rgb; + #endif } -- cgit v1.2.3 From 42b51bfd2cccba1dfdc820a4a033481fd42c1907 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 24 Jan 2024 16:02:31 -0800 Subject: https://github.com/secondlife/viewer-issues/issues/23 Fix for merge up to the featurettes branch, and reflection probes being "hazy" --- .../shaders/class3/deferred/softenLightF.glsl | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 79d9000482..f1de0b88d6 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -114,8 +114,8 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 additive, vec3 atten); -vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, - float perceptualRoughness, +vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, + float perceptualRoughness, float metallic, vec3 n, // normal vec3 v, // surface point to camera @@ -176,9 +176,9 @@ void main() vec3 irradiance = vec3(0); vec3 radiance = vec3(0); - if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR) || GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR)) + if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 orm = texture(specularRect, tc).rgb; + vec3 orm = texture(specularRect, tc).rgb; float perceptualRoughness = orm.g; float metallic = orm.b; float ao = orm.r; @@ -275,12 +275,7 @@ void main() applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity); } } - - #ifdef WATER_FOG - vec4 fogged = applyWaterFogViewLinear(pos.xyz, vec4(color, bloom)); - color = fogged.rgb; - #endif - + frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results frag_color.a = 0.0; } -- cgit v1.2.3 From 476cbaed6a876c308baa057b50af2631668f7293 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 31 Jan 2024 15:54:14 -0800 Subject: #677 Some clipping WIP --- .../app_settings/shaders/class3/deferred/materialF.glsl | 12 +++++++----- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index b3b1aaed56..8fe0e1cec8 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -48,15 +48,18 @@ vec3 linear_to_srgb(vec3 cs); uniform vec4 clipPlane; uniform float clipSign; uniform float mirror_flag; +uniform mat4 modelview_matrix; +uniform mat3 normal_matrix; void applyClip(vec3 pos) { - float funnyClip = 0; + if (mirror_flag > 0) { - if ((dot(pos.xyz, clipPlane.xyz) + clipPlane.w) > 0.0) - { + if ((dot(pos.xyz, clipPlane.xyz) + clipPlane.w) < 0.0) + { discard; - } + } + } } @@ -308,7 +311,6 @@ void main() // diffcol == diffuse map combined with vertex color vec4 diffcol = texture(diffuseMap, vary_texcoord0.xy); diffcol.rgb *= vertex_color.rgb; - alphaMask(diffcol.a); // spec == specular map combined with specular color diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index f1de0b88d6..b49c3386db 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -201,7 +201,6 @@ void main() #ifdef HERO_PROBES vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_MIRROR)) color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; #endif } -- cgit v1.2.3 From b2462355a39a8473065c279c66daba307f1fa9bf Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 1 Feb 2024 13:19:20 -0600 Subject: #677 WIP -- add mirror clipping to more shaders --- .../shaders/class3/deferred/fullbrightShinyF.glsl | 3 +++ .../shaders/class3/deferred/materialF.glsl | 22 +++------------------- 2 files changed, 6 insertions(+), 19 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index 8430cca325..c382a9fbc0 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -53,8 +53,11 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); +void mirrorClip(vec3 pos); + void main() { + mirrorClip(vary_position); #ifdef HAS_DIFFUSE_LOOKUP vec4 color = diffuseLookup(vary_texcoord0.xy); #else diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 8fe0e1cec8..0476b98e10 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -45,26 +45,13 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); -uniform vec4 clipPlane; -uniform float clipSign; -uniform float mirror_flag; uniform mat4 modelview_matrix; uniform mat3 normal_matrix; -void applyClip(vec3 pos) -{ - - if (mirror_flag > 0) - { - if ((dot(pos.xyz, clipPlane.xyz) + clipPlane.w) < 0.0) - { - discard; - } - - } -} in vec3 vary_position; +void mirrorClip(vec3 pos); + #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) out vec4 frag_color; @@ -305,7 +292,7 @@ float getShadow(vec3 pos, vec3 norm) void main() { - applyClip(vary_position); + mirrorClip(vary_position); waterClip(); // diffcol == diffuse map combined with vertex color @@ -430,9 +417,6 @@ void main() float flag = GBUFFER_FLAG_HAS_ATMOS; - if (mirror_flag > 0) - flag = 1; - frag_data[0] = vec4(diffcol.rgb, emissive); // gbuffer is sRGB for legacy materials frag_data[1] = vec4(spec.rgb, glossiness); // XYZ = Specular color. W = Specular exponent. frag_data[2] = vec4(encode_normal(norm), env, flag);; // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) -- cgit v1.2.3 From aab98046b9971717ecdc739b2230377278c83da3 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 1 Feb 2024 13:03:28 -0800 Subject: #677 More clipping fixes. --- indra/newview/app_settings/shaders/class3/environment/waterF.glsl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index b364e454e8..b2a81aa025 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -35,6 +35,8 @@ vec3 scaleSoftClipFragLinear(vec3 l); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec4 applyWaterFogViewLinear(vec3 pos, vec4 color); +void mirrorClip(vec3 pos); + // PBR interface vec2 BRDF(float NoV, float roughness); @@ -129,6 +131,7 @@ vec3 getPositionWithNDC(vec3 ndc); void main() { + mirrorClip(vary_position); vN = vary_normal; vT = vary_tangent; vB = cross(vN, vT); -- cgit v1.2.3 From 2d4a63833c2515ae36c614fce8101f41be0e1d61 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 1 Feb 2024 15:34:34 -0800 Subject: #677 Clip underwater. --- indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl index 223e55eb69..ef086fc3be 100644 --- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl @@ -55,9 +55,11 @@ in vec4 view; in vec3 vary_position; vec4 applyWaterFogViewLinearNoClip(vec3 pos, vec4 color); +void mirrorClip(vec3 position); void main() { + mirrorClip(vary_position); vec4 color; //get detail normals -- cgit v1.2.3 From 6846600e3ef1eec7fade19f61d2d45614ae1a8b0 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 2 Feb 2024 13:49:06 -0600 Subject: #677 Fix terrain clipping and tweak hero probe mixing with radiance --- .../shaders/class3/deferred/softenLightF.glsl | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index b49c3386db..be180b877f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -60,6 +60,7 @@ uniform float ssao_irradiance_max; #endif // Inputs +uniform vec4 clipPlane; uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; @@ -189,6 +190,19 @@ void main() sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear); + #ifdef HERO_PROBES + float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; + if (clipDist > 0.0 && clipDist < 0.1 && perceptualRoughness < 0.2) + { + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) + { + radiance = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), perceptualRoughness*11).xyz; + } + } + #endif + + adjustIrradiance(irradiance, ambocc); vec3 diffuseColor; @@ -198,11 +212,11 @@ void main() vec3 v = -normalize(pos.xyz); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); - #ifdef HERO_PROBES + /*#ifdef HERO_PROBES vec3 refnormpersp = reflect(pos.xyz, norm.xyz); color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; - #endif + #endif*/ } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { @@ -226,6 +240,18 @@ void main() sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear); + #ifdef HERO_PROBES + float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; + if (clipDist > 0.0 && clipDist < 0.1 && spec.a > 0.8) + { + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) + { + radiance = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-spec.a)*11).xyz; + } + } + #endif + adjustIrradiance(irradiance, ambocc); // apply lambertian IBL only (see pbrIbl) @@ -261,9 +287,9 @@ void main() // add radiance map applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz); - #ifdef HERO_PROBES + /*#ifdef HERO_PROBES color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - spec.a) * 11).xyz * spec.rgb; - #endif + #endif*/ } -- cgit v1.2.3 From 5abc68ad438c1feb79f008aa8148dda77aae2af9 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 2 Feb 2024 15:43:56 -0600 Subject: #677 Move PBR mirror radiance mixing to reflectionProbeF so transparent PBR surfaces can be mirrors --- .../shaders/class3/deferred/reflectionProbeF.glsl | 18 ++++++++++++++++++ .../shaders/class3/deferred/softenLightF.glsl | 13 ------------- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index d9dc83bb10..fe2647452f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -682,6 +682,12 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit) return col[1]+col[0]; } + +#if defined(HERO_PROBES) +uniform vec4 clipPlane; +uniform samplerCubeArray heroProbes; +#endif + void doProbeSample(inout vec3 ambenv, inout vec3 glossenv, vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit) { @@ -713,6 +719,18 @@ void doProbeSample(inout vec3 ambenv, inout vec3 glossenv, glossenv = mix(glossenv, ssr.rgb, ssr.a); } #endif + +#if defined(HERO_PROBES) + float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; + if (clipDist > 0.0 && clipDist < 0.1 && glossiness > 0.8) + { + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) + { + glossenv = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*10).xyz; + } + } +#endif } void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index be180b877f..a8cfc3537e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -189,19 +189,6 @@ void main() float gloss = 1.0 - perceptualRoughness; sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear); - - #ifdef HERO_PROBES - float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; - if (clipDist > 0.0 && clipDist < 0.1 && perceptualRoughness < 0.2) - { - vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) - { - radiance = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), perceptualRoughness*11).xyz; - } - } - #endif - adjustIrradiance(irradiance, ambocc); -- cgit v1.2.3 From 75b67c3750083e5ea150432d999866a0e383f927 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 5 Feb 2024 16:01:47 -0600 Subject: #677 Add hero probes to blinn-phong surfaces --- .../shaders/class3/deferred/reflectionProbeF.glsl | 39 ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index fe2647452f..4f6e01764a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -684,10 +684,33 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit) #if defined(HERO_PROBES) + uniform vec4 clipPlane; uniform samplerCubeArray heroProbes; + +void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) +{ + float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; + if (clipDist > 0.0 && clipDist < 0.1 && glossiness > 0.8) + { + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) + { + glossenv = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*10).xyz; + } + } +} + +#else + +void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) +{ +} + #endif + + void doProbeSample(inout vec3 ambenv, inout vec3 glossenv, vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit) { @@ -720,17 +743,7 @@ void doProbeSample(inout vec3 ambenv, inout vec3 glossenv, } #endif -#if defined(HERO_PROBES) - float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; - if (clipDist > 0.0 && clipDist < 0.1 && glossiness > 0.8) - { - vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) - { - glossenv = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*10).xyz; - } - } -#endif + tapHeroProbe(glossenv, pos, norm, glossiness); } void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, @@ -818,6 +831,7 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout { float lod = (1.0-glossiness)*reflection_lods; glossenv = sampleProbes(pos, normalize(refnormpersp), lod); + } if (envIntensity > 0.0) @@ -845,6 +859,9 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout } #endif + tapHeroProbe(glossenv, pos, norm, glossiness); + tapHeroProbe(legacyenv, pos, norm, 1.0); + glossenv = clamp(glossenv, vec3(0), vec3(10)); } -- cgit v1.2.3 From c3d4f571aa5522e3028842c6d7caa977819a7393 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 8 Feb 2024 13:22:10 -0800 Subject: Update softenLightF.glsl --- .../shaders/class3/deferred/softenLightF.glsl | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index a8cfc3537e..cc6e16c64f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -198,12 +198,6 @@ void main() vec3 v = -normalize(pos.xyz); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); - - /*#ifdef HERO_PROBES - vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - - color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; - #endif*/ } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { @@ -226,18 +220,6 @@ void main() vec3 legacyenv = vec3(0); sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear); - - #ifdef HERO_PROBES - float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; - if (clipDist > 0.0 && clipDist < 0.1 && spec.a > 0.8) - { - vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) - { - radiance = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-spec.a)*11).xyz; - } - } - #endif adjustIrradiance(irradiance, ambocc); @@ -274,10 +256,6 @@ void main() // add radiance map applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz); - /*#ifdef HERO_PROBES - color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - spec.a) * 11).xyz * spec.rgb; - #endif*/ - } color.rgb = mix(color.rgb, baseColor.rgb, baseColor.a); -- cgit v1.2.3 From b3283036af886de56f45c731ab21e2b16383a770 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 26 Feb 2024 04:02:09 -0800 Subject: #681 Start adding blending boilerplate. --- .../shaders/class3/deferred/reflectionProbeF.glsl | 71 +++++++++++++++++++++- .../shaders/class3/deferred/softenLightF.glsl | 10 --- 2 files changed, 68 insertions(+), 13 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 4f6e01764a..14d9cf798f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -686,17 +686,82 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit) #if defined(HERO_PROBES) uniform vec4 clipPlane; -uniform samplerCubeArray heroProbes; + +uniform samplerCubeArray heroProbes; + +layout (std140) uniform HeroProbeData +{ + mat4 heroBox[1]; + vec4 heroSphere[1]; + uint heroShape[1]; + int heroMipCount; + int heroProbeCount; +}; + +vec3 boxIntersectHero(vec3 origin, vec3 dir, int i, out float d, float scale) +{ + // Intersection with OBB convert to unit box space + // Transform in local unit parallax cube space (scaled and rotated) + mat4 clipToLocal = heroBox[i]; + + vec3 RayLS = mat3(clipToLocal) * dir; + vec3 PositionLS = (clipToLocal * vec4(origin, 1.0)).xyz; + + d = 1.0-max(max(abs(PositionLS.x), abs(PositionLS.y)), abs(PositionLS.z)); + + vec3 Unitary = vec3(scale); + vec3 FirstPlaneIntersect = (Unitary - PositionLS) / RayLS; + vec3 SecondPlaneIntersect = (-Unitary - PositionLS) / RayLS; + vec3 FurthestPlane = max(FirstPlaneIntersect, SecondPlaneIntersect); + float Distance = min(FurthestPlane.x, min(FurthestPlane.y, FurthestPlane.z)); + + // Use Distance in CS directly to recover intersection + vec3 IntersectPositionCS = origin + dir * Distance; + + return IntersectPositionCS; +} + +float sphereWeightHero(vec3 pos, vec3 dir, vec3 origin, float r, out float dw) +{ + float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down) + vec3 delta = pos.xyz - origin; + float d2 = max(length(delta), 0.001); + + float atten = 1.0 - max(d2 - r1, 0.0) / max((r - r1), 0.001); + float w = 1.0 / d2; + + dw = w * atten * max(r, 1.0)*4; + + w *= atten; + + return w; +} void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) { float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; - if (clipDist > 0.0 && clipDist < 0.1 && glossiness > 0.8) + float w = 0; + float dw = 0; + if (heroShape[0] < 1) + { + float d = 0; + boxIntersectHero(pos, norm, 0, d, 1.0); + + w = max(d, 0.001); + } + else + { + float r = heroSphere[0].w; + //v = sphereIntersect(pos, norm, heroSphere[0].xyz, 4096.0*4096.0); + + w = sphereWeightHero(pos, norm, heroSphere[0].xyz, r, dw); + } + { vec3 refnormpersp = reflect(pos.xyz, norm.xyz); if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) { - glossenv = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*10).xyz; + glossenv = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz * w; } } } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index cc6e16c64f..2f90249169 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -32,16 +32,6 @@ uniform sampler2D specularRect; uniform sampler2D normalMap; uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl -uniform samplerCubeArray heroProbes; - -#if defined(HERO_PROBES) -layout (std140) uniform HeroProbeData -{ - vec4 heroPosition[1]; - int heroProbeCount; -}; -#endif - const float M_PI = 3.14159265; #if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) -- cgit v1.2.3 From 8b374f733360650c95d3ec021f1ec351e8b5dc21 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 27 Feb 2024 13:18:03 -0800 Subject: #681 Make our sampling code for probes a good deal more generic to make sure all probes can benefit from the same blending functions. --- .../shaders/class3/deferred/reflectionProbeF.glsl | 49 ++++++---------------- 1 file changed, 13 insertions(+), 36 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 14d9cf798f..7df9bdba5d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -366,11 +366,11 @@ return texCUBE(envMap, ReflDirectionWS); // i - probe index in refBox/refSphere // d - distance to nearest wall in clip space // scale - scale of box, default 1.0 -vec3 boxIntersect(vec3 origin, vec3 dir, int i, out float d, float scale) +vec3 boxIntersect(vec3 origin, vec3 dir, mat4 i, out float d, float scale) { // Intersection with OBB convert to unit box space // Transform in local unit parallax cube space (scaled and rotated) - mat4 clipToLocal = refBox[i]; + mat4 clipToLocal = i; vec3 RayLS = mat3(clipToLocal) * dir; vec3 PositionLS = (clipToLocal * vec4(origin, 1.0)).xyz; @@ -389,7 +389,7 @@ vec3 boxIntersect(vec3 origin, vec3 dir, int i, out float d, float scale) return IntersectPositionCS; } -vec3 boxIntersect(vec3 origin, vec3 dir, int i, out float d) +vec3 boxIntersect(vec3 origin, vec3 dir, mat4 i, out float d) { return boxIntersect(origin, dir, i, d, 1.0); } @@ -444,9 +444,9 @@ void boxIntersectionDebug( in vec3 ro, in vec3 p, vec3 boxSize, inout vec4 col) } -void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col) +void boxIntersectDebug(vec3 origin, vec3 pos, mat4 i, inout vec4 col) { - mat4 clipToLocal = refBox[i]; + mat4 clipToLocal = i; // transform into unit cube space origin = (clipToLocal * vec4(origin, 1.0)).xyz; @@ -463,7 +463,7 @@ void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col) // r - radius of probe influence volume // i - index of probe in refSphere // dw - distance weight -float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, int i, out float dw) +float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, vec4 i, out float dw) { float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz - origin; @@ -472,7 +472,7 @@ float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, int i, out float dw float atten = 1.0 - max(d2 - r1, 0.0) / max((r - r1), 0.001); float w = 1.0 / d2; - w *= refParams[i].z; + w *= i.z; dw = w * atten * max(r, 1.0)*4; @@ -498,7 +498,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, if (refIndex[i].w < 0) { // box probe float d = 0; - v = boxIntersect(pos, dir, i, d); + v = boxIntersect(pos, dir, refBox[i], d); w = max(d, 0.001); } @@ -512,7 +512,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres rr); - w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, refParams[i], dw); } v -= c; @@ -538,7 +538,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int if (refIndex[i].w < 0) { float d = 0.0; - v = boxIntersect(pos, dir, i, d, 3.0); + v = boxIntersect(pos, dir, refBox[i], d, 3.0); w = max(d, 0.001); } else @@ -552,7 +552,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres rr); - w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, refParams[i], dw); } v -= c; @@ -698,29 +698,6 @@ layout (std140) uniform HeroProbeData int heroProbeCount; }; -vec3 boxIntersectHero(vec3 origin, vec3 dir, int i, out float d, float scale) -{ - // Intersection with OBB convert to unit box space - // Transform in local unit parallax cube space (scaled and rotated) - mat4 clipToLocal = heroBox[i]; - - vec3 RayLS = mat3(clipToLocal) * dir; - vec3 PositionLS = (clipToLocal * vec4(origin, 1.0)).xyz; - - d = 1.0-max(max(abs(PositionLS.x), abs(PositionLS.y)), abs(PositionLS.z)); - - vec3 Unitary = vec3(scale); - vec3 FirstPlaneIntersect = (Unitary - PositionLS) / RayLS; - vec3 SecondPlaneIntersect = (-Unitary - PositionLS) / RayLS; - vec3 FurthestPlane = max(FirstPlaneIntersect, SecondPlaneIntersect); - float Distance = min(FurthestPlane.x, min(FurthestPlane.y, FurthestPlane.z)); - - // Use Distance in CS directly to recover intersection - vec3 IntersectPositionCS = origin + dir * Distance; - - return IntersectPositionCS; -} - float sphereWeightHero(vec3 pos, vec3 dir, vec3 origin, float r, out float dw) { float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down) @@ -745,7 +722,7 @@ void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) if (heroShape[0] < 1) { float d = 0; - boxIntersectHero(pos, norm, 0, d, 1.0); + boxIntersect(pos, norm, heroBox[0], d, 1.0); w = max(d, 0.001); } @@ -844,7 +821,7 @@ void debugTapRefMap(vec3 pos, vec3 dir, float depth, int i, inout vec4 col) { if (refIndex[i].w < 0) { - boxIntersectDebug(origin, pos, i, col); + boxIntersectDebug(origin, pos, refBox[i], col); } else { -- cgit v1.2.3 From 47cd3cb0ad03c91f118fd20fea8d8924759fd2b7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 27 Feb 2024 13:46:49 -0800 Subject: #681 More generalization of falloff. --- .../shaders/class3/deferred/reflectionProbeF.glsl | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 7df9bdba5d..257299258e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -698,22 +698,6 @@ layout (std140) uniform HeroProbeData int heroProbeCount; }; -float sphereWeightHero(vec3 pos, vec3 dir, vec3 origin, float r, out float dw) -{ - float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down) - vec3 delta = pos.xyz - origin; - float d2 = max(length(delta), 0.001); - - float atten = 1.0 - max(d2 - r1, 0.0) / max((r - r1), 0.001); - float w = 1.0 / d2; - - dw = w * atten * max(r, 1.0)*4; - - w *= atten; - - return w; -} - void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) { float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; @@ -729,16 +713,15 @@ void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) else { float r = heroSphere[0].w; - //v = sphereIntersect(pos, norm, heroSphere[0].xyz, 4096.0*4096.0); - w = sphereWeightHero(pos, norm, heroSphere[0].xyz, r, dw); + w = sphereWeight(pos, norm, heroSphere[0].xyz, r, vec4(1), dw); } { vec3 refnormpersp = reflect(pos.xyz, norm.xyz); if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) { - glossenv = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz * w; + glossenv = mix(glossenv, textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz, w); } } } -- cgit v1.2.3 From 1fc45a50ff15e6f31a4554da83256b7f59b1af15 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 6 Mar 2024 17:56:16 -0800 Subject: #681 Add probe blending for mirrors. --- .../shaders/class3/deferred/reflectionProbeF.glsl | 43 ++++++++++------------ 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 257299258e..4f2475b101 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -48,6 +48,7 @@ layout (std140) uniform ReflectionProbes /// box[0..2] - plane 0 .. 2 in [A,B,C,D] notation // box[3][0..2] - plane thickness mat4 refBox[MAX_REFMAP_COUNT]; + mat4 heroBox; // list of bounding spheres for reflection probes sorted by distance to camera (closest first) vec4 refSphere[MAX_REFMAP_COUNT]; // extra parameters @@ -56,6 +57,7 @@ layout (std140) uniform ReflectionProbes // z - fade in // w - znear vec4 refParams[MAX_REFMAP_COUNT]; + vec4 heroSphere; // index of cube map in reflectionProbes for a corresponding reflection probe // e.g. cube map channel of refSphere[2] is stored in refIndex[2] // refIndex.x - cubemap channel in reflectionProbes @@ -71,6 +73,10 @@ layout (std140) uniform ReflectionProbes // number of reflection probes present in refSphere int refmapCount; + + int heroShape; + int heroMipCount; + int heroProbeCount; }; // Inputs @@ -682,48 +688,37 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit) return col[1]+col[0]; } - #if defined(HERO_PROBES) uniform vec4 clipPlane; - uniform samplerCubeArray heroProbes; -layout (std140) uniform HeroProbeData -{ - mat4 heroBox[1]; - vec4 heroSphere[1]; - uint heroShape[1]; - int heroMipCount; - int heroProbeCount; -}; - void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) { float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; float w = 0; float dw = 0; - if (heroShape[0] < 1) + float falloffMult = 10; + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + if (heroShape < 1) { float d = 0; - boxIntersect(pos, norm, heroBox[0], d, 1.0); + boxIntersect(pos, norm, heroBox, d, 1.0); - w = max(d, 0.001); + w = max(d, 0); } else { - float r = heroSphere[0].w; + float r = heroSphere.w; - w = sphereWeight(pos, norm, heroSphere[0].xyz, r, vec4(1), dw); - } - - { - vec3 refnormpersp = reflect(pos.xyz, norm.xyz); - if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) - { - glossenv = mix(glossenv, textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz, w); - } + w = sphereWeight(pos, refnormpersp, heroSphere.xyz, r, vec4(1), dw); } + + clipDist = clipDist * 0.95 + 0.05; + clipDist = clamp(clipDist * falloffMult, 0, 1); + w = clamp(w * falloffMult * clipDist, 0, 1); + + glossenv = mix(glossenv, textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz, w); } #else -- cgit v1.2.3 From c1bde75768e1374d4f094936d52ed29f6f5d3cba Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 8 Mar 2024 12:01:20 -0600 Subject: HDRI Local Preview (#953) * #926 WIP - HDRI import prototype v0 * #926 WIP -- add OpenEXR to autobuild.xml * #926 WIP -- Add OpenEXR cmake * #926 WIP -- Attempt at using OpenEXR autobuild package and don't hard code .exr file to load * #926 Unmangle autobuild.xml and get dll's in the right place (thanks, Caladbolg!) * implement mac shared libs plumbing for OpenEXR for secondlife/viewer#926 * Fix Xcode/clang compile error regarding new[]/delete[] mismatch * #926 HDRI Preview finishing touches. - Full ACES when HDRI is enabled - Fix for probes getting stuck paused - Add exposure and rotation controls --------- Co-authored-by: Brad Linden --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 2f90249169..5cc7ea698a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -189,6 +189,10 @@ void main() vec3 v = -normalize(pos.xyz); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); } + else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI)) + { + color = texture(emissiveRect, tc).rgb; + } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { //should only be true of WL sky, just port over base color value -- cgit v1.2.3 From 457b720fd9b2ced6f288d4bbc71045cefaed4a49 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 12 Mar 2024 14:26:21 -0500 Subject: #965 Fix for EEP skies being too bright --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 5cc7ea698a..9b9739ba22 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -191,11 +191,12 @@ void main() } else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI)) { + // actual HDRI sky, just copy color value color = texture(emissiveRect, tc).rgb; } - else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) + else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS)) { - //should only be true of WL sky, just port over base color value + //should only be true of WL sky, port over base color value and scale for fake HDR color = texture(emissiveRect, tc).rgb; color = srgb_to_linear(color); color *= sky_hdr_scale; -- cgit v1.2.3 From 7ef2b43802da07b8f30b455448cb84bd1c26320d Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 10 Apr 2024 15:21:59 -0700 Subject: Multiple fixes for mirrors. (#1192) * #1064 Fix for mirror surfaces going black when the roughness is set too high. * #1130 Fix for the user's avatar not appearing in mouselook in a mirror. * #1059 Disable mirrors on low settings per the feature table. * #860 Modify the settings UI to better reflect that we only have two AA modes: off and FXAA. * #1191 Add some settings for mirrors in preferences. * #1185 Add support for runtime mirror resolution changing. Useful for quality settings, and auto-FPS. --- .../newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 4f2475b101..90c84cc428 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -717,7 +717,7 @@ void tapHeroProbe(inout vec3 glossenv, vec3 pos, vec3 norm, float glossiness) clipDist = clipDist * 0.95 + 0.05; clipDist = clamp(clipDist * falloffMult, 0, 1); w = clamp(w * falloffMult * clipDist, 0, 1); - + w = mix(0, w, clamp(glossiness - 0.75, 0, 1) * 4); // We only generate a quarter of the mips for the hero probes. Linearly interpolate between normal probes and hero probes based upon glossiness. glossenv = mix(glossenv, textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-glossiness)*heroMipCount).xyz, w); } -- cgit v1.2.3 From 2880e5ceeeacbf4024167b2a4e0f1d2ce129eb6f Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 19 Apr 2024 11:59:28 -0500 Subject: #1139 Fix for world going black/white in some scenes (NaNs) (#1273) * #1139 Fix for world going black/white in some scenes (NaNs) NaNs were coming from normal encode/decode. Take advantage of available gbuffer space to send full normal instead of encoding. * #1139 Cleanup remove now unused encodeNormF.glsl * #1139 Remove final reference to encodeNormF * #1139 Fix for getNormalEnvIntensityFlags referencing wrong sampler for env intensity * Mac build fix --- .../app_settings/shaders/class3/deferred/materialF.glsl | 14 ++++++-------- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 5 +++-- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 0476b98e10..d49db4b74d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -216,8 +216,6 @@ in vec3 vary_normal; in vec4 vertex_color; in vec2 vary_texcoord0; -vec2 encode_normal(vec3 n); - // get the transformed normal and apply glossiness component from normal map vec3 getNormal(inout float glossiness) { @@ -306,8 +304,6 @@ void main() float glossiness = specular_color.a; vec3 norm = getNormal(glossiness); - vec2 abnormal = encode_normal(norm.xyz); - float emissive = getEmissive(diffcol); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -417,10 +413,12 @@ void main() float flag = GBUFFER_FLAG_HAS_ATMOS; - frag_data[0] = vec4(diffcol.rgb, emissive); // gbuffer is sRGB for legacy materials - frag_data[1] = vec4(spec.rgb, glossiness); // XYZ = Specular color. W = Specular exponent. - frag_data[2] = vec4(encode_normal(norm), env, flag);; // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) - frag_data[3] = vec4(0); + frag_data[0] = max(vec4(diffcol.rgb, emissive), vec4(0)); // gbuffer is sRGB for legacy materials + frag_data[1] = max(vec4(spec.rgb, glossiness), vec4(0)); // XYZ = Specular color. W = Specular exponent. + frag_data[2] = max(vec4(norm, flag), vec4(0)); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) + frag_data[3] = vec4(env, 0, 0, 0); + #endif } + diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 9b9739ba22..f71f8a028f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -129,7 +129,8 @@ void main() float depth = getDepth(tc.xy); vec4 pos = getPositionWithDepth(tc, depth); vec4 norm = texture(normalMap, tc); - float envIntensity = norm.z; + vec3 colorEmissive = texture(emissiveRect, tc).rgb; + float envIntensity = colorEmissive.r; norm.xyz = getNorm(tc); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; @@ -174,7 +175,7 @@ void main() float metallic = orm.b; float ao = orm.r; - vec3 colorEmissive = texture(emissiveRect, tc).rgb; + // PBR IBL float gloss = 1.0 - perceptualRoughness; -- cgit v1.2.3 From f1b7e806eb30a343876036eff5caef7c03309aa6 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 21 Apr 2024 20:40:13 -0400 Subject: Fix sampling normals from gbuffer and cleanup redundant gbuffer samples (#1294) * Fix sampling normals from gbuffer and cleanup redundant gbuffer samples * Allow negative normals in gbuffer to fix broken material rendering --- .../newview/app_settings/shaders/class3/deferred/hazeF.glsl | 5 ++--- .../app_settings/shaders/class3/deferred/materialF.glsl | 2 +- .../shaders/class3/deferred/multiPointLightF.glsl | 7 +++---- .../app_settings/shaders/class3/deferred/pointLightF.glsl | 7 +++---- .../shaders/class3/deferred/screenSpaceReflPostF.glsl | 9 +++------ .../app_settings/shaders/class3/deferred/softenLightF.glsl | 13 ++++++------- .../app_settings/shaders/class3/deferred/spotLightF.glsl | 10 +++++----- .../app_settings/shaders/class3/deferred/waterHazeF.glsl | 1 - 8 files changed, 23 insertions(+), 31 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl index 0b154e82ad..4af57e3b80 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl @@ -33,7 +33,7 @@ uniform vec3 moon_dir; uniform int sun_up_factor; in vec2 vary_fragcoord; -vec3 getNorm(vec2 pos_screen); +vec4 getNorm(vec2 pos_screen); vec4 getPositionWithDepth(vec2 pos_screen, float depth); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); @@ -53,8 +53,7 @@ void main() vec2 tc = vary_fragcoord.xy; float depth = getDepth(tc.xy); vec4 pos = getPositionWithDepth(tc, depth); - vec4 norm = texture(normalMap, tc); - norm.xyz = getNorm(tc); + vec4 norm = getNorm(tc); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; vec3 color = vec3(0); diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index d49db4b74d..2a20eb79d2 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -415,7 +415,7 @@ void main() frag_data[0] = max(vec4(diffcol.rgb, emissive), vec4(0)); // gbuffer is sRGB for legacy materials frag_data[1] = max(vec4(spec.rgb, glossiness), vec4(0)); // XYZ = Specular color. W = Specular exponent. - frag_data[2] = max(vec4(norm, flag), vec4(0)); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) + frag_data[2] = vec4(norm, flag); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) frag_data[3] = vec4(env, 0, 0, 0); #endif diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index ec8168465e..edfd6cbced 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -48,7 +48,7 @@ in vec4 vary_fragcoord; void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); float calcLegacyDistanceAttenuation(float distance, float falloff); vec4 getPosition(vec2 pos_screen); -vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); +vec4 getNorm(vec2 screenpos); vec2 getScreenXY(vec4 clip); vec2 getScreenCoord(vec4 clip); vec3 srgb_to_linear(vec3 c); @@ -74,9 +74,8 @@ void main() discard; } - float envIntensity; // not used for this shader - vec3 n; - vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() + vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG() + vec3 n = norm.xyz; vec4 spec = texture(specularRect, tc); vec3 diffuse = texture(diffuseRect, tc).rgb; diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index 31af1208bd..60be9f4407 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -52,7 +52,7 @@ uniform vec4 viewport; void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); float calcLegacyDistanceAttenuation(float distance, float falloff); -vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); +vec4 getNorm(vec2 screenpos); vec4 getPosition(vec2 pos_screen); vec2 getScreenXY(vec4 clip); vec2 getScreenCoord(vec4 clip); @@ -72,9 +72,8 @@ void main() vec2 tc = getScreenCoord(vary_fragcoord); vec3 pos = getPosition(tc).xyz; - float envIntensity; - vec3 n; - vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() + vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG() + vec3 n = norm.xyz; vec3 diffuse = texture(diffuseRect, tc).rgb; vec4 spec = texture(specularRect, tc); diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl index dbf20fe2d8..deb276ef9d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl @@ -40,14 +40,13 @@ uniform sampler2D specularRect; uniform sampler2D diffuseRect; uniform sampler2D diffuseMap; -vec3 getNorm(vec2 screenpos); +vec4 getNorm(vec2 screenpos); float getDepth(vec2 pos_screen); float linearDepth(float d, float znear, float zfar); float linearDepth01(float d, float znear, float zfar); vec4 getPositionWithDepth(vec2 pos_screen, float depth); vec4 getPosition(vec2 pos_screen); -vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); float random (vec2 uv); @@ -57,9 +56,7 @@ void main() { vec2 tc = vary_fragcoord.xy; float depth = linearDepth01(getDepth(tc), zNear, zFar); - float envIntensity; - vec3 n; - vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() + vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG() vec3 pos = getPositionWithDepth(tc, getDepth(tc)).xyz; vec4 spec = texture(specularRect, tc); vec2 hitpixel; @@ -84,7 +81,7 @@ void main() vec4 collectedColor = vec4(0); - float w = tapScreenSpaceReflection(4, tc, pos, n, collectedColor, diffuseMap, 0); + float w = tapScreenSpaceReflection(4, tc, pos, norm.xyz, collectedColor, diffuseMap, 0); collectedColor.rgb *= specCol.rgb; diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index f71f8a028f..96c32734e4 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -61,7 +61,7 @@ in vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 getNorm(vec2 pos_screen); +vec4 getNorm(vec2 pos_screen); vec4 getPositionWithDepth(vec2 pos_screen, float depth); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); @@ -128,14 +128,13 @@ void main() vec2 tc = vary_fragcoord.xy; float depth = getDepth(tc.xy); vec4 pos = getPositionWithDepth(tc, depth); - vec4 norm = texture(normalMap, tc); + vec4 norm = getNorm(tc); vec3 colorEmissive = texture(emissiveRect, tc).rgb; float envIntensity = colorEmissive.r; - norm.xyz = getNorm(tc); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; vec4 baseColor = texture(diffuseRect, tc); - vec4 spec = texture(specularRect, vary_fragcoord.xy); // NOTE: PBR linear Emissive + vec4 spec = texture(specularRect, tc); // NOTE: PBR linear Emissive #if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) vec2 scol_ambocc = texture(lightMap, vary_fragcoord.xy).rg; @@ -170,7 +169,7 @@ void main() if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 orm = texture(specularRect, tc).rgb; + vec3 orm = spec.rgb; float perceptualRoughness = orm.g; float metallic = orm.b; float ao = orm.r; @@ -193,12 +192,12 @@ void main() else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI)) { // actual HDRI sky, just copy color value - color = texture(emissiveRect, tc).rgb; + color = colorEmissive.rgb; } else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS)) { //should only be true of WL sky, port over base color value and scale for fake HDR - color = texture(emissiveRect, tc).rgb; + color = colorEmissive.rgb; color = srgb_to_linear(color); color *= sky_hdr_scale; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index d31b37fb60..319fa86148 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -72,7 +72,7 @@ uniform mat4 inv_proj; void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); float calcLegacyDistanceAttenuation(float distance, float falloff); bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc ); -vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); +vec4 getNorm(vec2 screenpos); vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float nl, float noise, vec2 projected_uv); vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv ); vec2 getScreenCoord(vec4 clip); @@ -121,9 +121,8 @@ void main() shadow = clamp(shadow, 0.0, 1.0); } - float envIntensity; - vec3 n; - vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); + vec4 norm = getNorm(tc); + vec3 n = norm.xyz; float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); if (dist_atten <= 0.0) @@ -145,7 +144,6 @@ void main() if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { - vec3 colorEmissive = texture(emissiveRect, tc).rgb; vec3 orm = spec.rgb; float perceptualRoughness = orm.g; float metallic = orm.b; @@ -182,6 +180,8 @@ void main() } else { + float envIntensity = texture(emissiveRect, tc).r; + diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl index f6b8299f91..f6bef1e498 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl @@ -56,7 +56,6 @@ void main() } vec4 pos = getPositionWithDepth(tc, depth); - vec4 norm = texture(normalMap, tc); vec4 fogged = getWaterFogView(pos.xyz); -- cgit v1.2.3 From b06a99f7c76950484972e25d9dbbee8660a6a6c3 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Wed, 15 May 2024 12:47:27 +0300 Subject: Post-merge spaces fix --- .../shaders/class3/deferred/fullbrightShinyF.glsl | 28 ++++++++-------- .../shaders/class3/deferred/materialF.glsl | 24 +++++++------- .../shaders/class3/environment/underWaterF.glsl | 36 ++++++++++---------- .../shaders/class3/environment/waterF.glsl | 38 +++++++++++----------- 4 files changed, 63 insertions(+), 63 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index c382a9fbc0..03dc3d7113 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -1,28 +1,28 @@ -/** +/** * @file fullbrightShinyF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2007, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + /*[EXTRA_CODE_HERE]*/ out vec4 frag_color; @@ -59,16 +59,16 @@ void main() { mirrorClip(vary_position); #ifdef HAS_DIFFUSE_LOOKUP - vec4 color = diffuseLookup(vary_texcoord0.xy); + vec4 color = diffuseLookup(vary_texcoord0.xy); #else - vec4 color = texture(diffuseMap, vary_texcoord0.xy); + vec4 color = texture(diffuseMap, vary_texcoord0.xy); #endif - - color.rgb *= vertex_color.rgb; - // SL-9632 HUDs are affected by Atmosphere + color.rgb *= vertex_color.rgb; + + // SL-9632 HUDs are affected by Atmosphere #ifndef IS_HUD - + vec3 sunlit; vec3 amblit; vec3 additive; @@ -90,8 +90,8 @@ void main() applyLegacyEnv(color.rgb, legacyenv, spec, pos, norm, env_intensity); #endif - color.a = 1.0; + color.a = 1.0; - frag_color = max(color, vec4(0)); + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 2a20eb79d2..d3e19cf4a8 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -100,7 +100,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe float falloff_factor = (12.0 * fa) - 9.0; float inverted_la = falloff_factor / la; // Yes, it makes me want to cry as well. DJH - + vec3 col = vec3(0); //get light vector @@ -220,19 +220,19 @@ in vec2 vary_texcoord0; vec3 getNormal(inout float glossiness) { #ifdef HAS_NORMAL_MAP - vec4 vNt = texture(bumpMap, vary_texcoord1.xy); + vec4 vNt = texture(bumpMap, vary_texcoord1.xy); glossiness *= vNt.a; - vNt.xyz = vNt.xyz * 2 - 1; + vNt.xyz = vNt.xyz * 2 - 1; float sign = vary_sign; vec3 vN = vary_normal; vec3 vT = vary_tangent.xyz; - + vec3 vB = sign * cross(vN, vT); vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); - return tnorm; + return tnorm; #else - return normalize(vary_normal); + return normalize(vary_normal); #endif } @@ -269,9 +269,9 @@ void waterClip() float getEmissive(vec4 diffcol) { #if (DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE) - return emissive_brightness; + return emissive_brightness; #else - return max(diffcol.a, emissive_brightness); + return max(diffcol.a, emissive_brightness); #endif } @@ -295,7 +295,7 @@ void main() // diffcol == diffuse map combined with vertex color vec4 diffcol = texture(diffuseMap, vary_texcoord0.xy); - diffcol.rgb *= vertex_color.rgb; + diffcol.rgb *= vertex_color.rgb; alphaMask(diffcol.a); // spec == specular map combined with specular color @@ -328,7 +328,7 @@ void main() vec3 additive; vec3 atten; calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten); - + vec3 sunlit_linear = srgb_to_linear(sunlit); vec3 amblit_linear = amblit; @@ -336,7 +336,7 @@ void main() vec3 glossenv; vec3 legacyenv; sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xy*0.5+0.5, pos.xyz, norm.xyz, glossiness, env, true, amblit_linear); - + color = ambenv; float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); @@ -408,7 +408,7 @@ void main() frag_color = max(vec4(color, al), vec4(0)); -#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer +#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer // deferred path // See: C++: addDeferredAttachment(), shader: softenLightF.glsl float flag = GBUFFER_FLAG_HAS_ATMOS; diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl index ef086fc3be..728d70ebb2 100644 --- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl @@ -4,25 +4,25 @@ * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2007, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + out vec4 frag_color; uniform sampler2D diffuseMap; @@ -57,27 +57,27 @@ in vec3 vary_position; vec4 applyWaterFogViewLinearNoClip(vec3 pos, vec4 color); void mirrorClip(vec3 position); -void main() +void main() { - mirrorClip(vary_position); - vec4 color; + mirrorClip(vary_position); + vec4 color; //get detail normals - vec3 wave1 = texture(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; - vec3 wave2 = texture(bumpMap, littleWave.xy).xyz*2.0-1.0; - vec3 wave3 = texture(bumpMap, littleWave.zw).xyz*2.0-1.0; - vec3 wavef = normalize(wave1+wave2+wave3); - - //figure out distortion vector (ripply) - vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; - distort = distort+wavef.xy*refScale; + vec3 wave1 = texture(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2 = texture(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3 = texture(bumpMap, littleWave.zw).xyz*2.0-1.0; + vec3 wavef = normalize(wave1+wave2+wave3); + + //figure out distortion vector (ripply) + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + distort = distort+wavef.xy*refScale; #ifdef TRANSPARENT_WATER - vec4 fb = texture(screenTex, distort); + vec4 fb = texture(screenTex, distort); #else vec4 fb = vec4(waterFogColorLinear, 0.0); #endif - + fb = applyWaterFogViewLinearNoClip(vary_position, fb); frag_color = max(fb, vec4(0)); diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index b2a81aa025..a5592188a9 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -1,28 +1,28 @@ -/** +/** * @file waterF.glsl * * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2022, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + // class3/environment/waterF.glsl out vec4 frag_color; @@ -129,7 +129,7 @@ void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, vec3 getPositionWithNDC(vec3 ndc); -void main() +void main() { mirrorClip(vary_position); vN = vary_normal; @@ -160,7 +160,7 @@ void main() vec3 wave3 = BlendNormal(wave3_a, wave3_b); vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; - + //wave1 = transform_normal(wave1); //wave2 = transform_normal(wave2); //wave3 = transform_normal(wave3); @@ -171,7 +171,7 @@ void main() vec3 up = transform_normal(vec3(0,0,1)); float vdu = -dot(viewVec, up)*2; - + vec3 wave_ibl = wavef; wave_ibl.z *= 2.0; wave_ibl = transform_normal(normalize(wave_ibl)); @@ -185,13 +185,13 @@ void main() //wavef = vec3(0, 0, 1); wavef = transform_normal(wavef); - - float dist2 = dist; - dist = max(dist, 5.0); - - float dmod = sqrt(dist); - - //figure out distortion vector (ripply) + + float dist2 = dist; + dist = max(dist, 5.0); + + float dmod = sqrt(dist); + + //figure out distortion vector (ripply) vec2 distort2 = distort + waver.xy * refScale / max(dmod, 1.0); distort2 = clamp(distort2, vec2(0), vec2(0.999)); @@ -235,7 +235,7 @@ void main() float metallic = 0.0; float perceptualRoughness = 0.05; float gloss = 1.0 - perceptualRoughness; - + vec3 irradiance = vec3(0); vec3 radiance = vec3(0); sampleReflectionProbesWater(irradiance, radiance, distort2, pos.xyz, wave_ibl.xyz, gloss, amblit); @@ -251,7 +251,7 @@ void main() vec3 colorEmissive = vec3(0); float ao = 1.0; vec3 light_dir = transform_normal(lightDir); - + perceptualRoughness = 0.0; metallic = 1.0; @@ -284,7 +284,7 @@ void main() color = ((1.0 - f) * color) + fb.rgb; float spec = min(max(max(punctual.r, punctual.g), punctual.b), 0.05); - + frag_color = max(vec4(color, spec), vec4(0)); } -- cgit v1.2.3