From e81ed6242f13c3ce1f88432482b6c2d182b436ea Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 25 Aug 2022 14:51:51 -0700 Subject: SL-17967 compiles and runs by avoiding the features --- .../shaders/class1/deferred/deferredUtil.glsl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 777021cd53..c4d1e7d1a7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -158,7 +158,11 @@ float getDepth(vec2 pos_screen) vec4 getTexture2DLodAmbient(vec2 tc, float lod) { - vec4 ret = texture2DLod(projectionMap, tc, lod); +#ifndef FXAA_GLSL_120 + vec4 ret = textureLod(projectionMap, tc, lod); +#else + vec4 ret = texture2D(projectionMap, tc); +#endif ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = tc-vec2(0.5); @@ -170,7 +174,11 @@ vec4 getTexture2DLodAmbient(vec2 tc, float lod) vec4 getTexture2DLodDiffuse(vec2 tc, float lod) { - vec4 ret = texture2DLod(projectionMap, tc, lod); +#ifndef FXAA_GLSL_120 + vec4 ret = textureLod(projectionMap, tc, lod); +#else + vec4 ret = texture2D(projectionMap, tc); +#endif ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -213,7 +221,11 @@ vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv) vec4 texture2DLodSpecular(vec2 tc, float lod) { - vec4 ret = texture2DLod(projectionMap, tc, lod); +#ifndef FXAA_GLSL_120 + vec4 ret = textureLod(projectionMap, tc, lod); +#else + vec4 ret = texture2D(projectionMap, tc); +#endif ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); -- cgit v1.2.3 From 140909c77553db6115e4eeaf14afece498f0a140 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 25 Aug 2022 18:14:22 -0700 Subject: SL-17967 - .glsl typos. No we get pink PBR! --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 13 ++++++++----- .../app_settings/shaders/class3/deferred/spotLightF.glsl | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index d4140a0d92..9286c43ace 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -28,8 +28,8 @@ #define PBR_USE_SUN 1 #define DEBUG_PBR_LIGHT_TYPE 0 // Output no global light to make it easier to see pointLight and spotLight -#define DEBUG_PBR_PACKORM0 0 // Rough=0, Metal=0 -#define DEBUG_PBR_PACKORM1 0 // Rough=1, Metal=1 +#define DEBUG_PBR_PACK_ORM0 0 // Rough=0, Metal=0 +#define DEBUG_PBR_PACK_ORM1 0 // Rough=1, Metal=1 #define DEBUG_PBR_TANGENT1 1 // Tangent = 1,0,0 #define DEBUG_PBR_VERT2CAM1 0 // vertex2camera = 0,0,1 #define DEBUG_PBR_SPECLIGHT051 0 // Force specLigh to be 0,0.5,1 @@ -72,6 +72,7 @@ #define DEBUG_PBR_IRRADIANCE 0 // Output: Diffuse Irradiance, NOTE: SSAO is factored in #define DEBUG_PBR_FSS_ESS_LAMBERT 0 // Output: FssEssLambert #define DEBUG_PBR_EMS 0 // Output: Ems = (1 - BRDF Scale + BRDF Bias) +#define DEBUG_PBR_EMS_AVG 0 // Output: Avg Ems #define DEBUG_PBR_AVG 0 // Output: Avg #define DEBUG_PBR_FMS_EMS 0 // Output: FmsEms #define DEBUG_PBR_DIFFUSE_K 0 // Output: diffuse FssEssLambert + FmsEms @@ -110,6 +111,7 @@ #define DEBUG_PBR_SUN_SPEC_FV 0 // F() * V() #define DEBUG_PBR_SUN_SPEC_DFV 0 // D() * F() * V() #define DEBUG_PBR_SUN_SPEC_NL_DFV 0 // nl * D() * F() * V() +#define DEBUG_PBR_SUN_FINAL 0 // LAMBERT_NL + NL_DFV ? #define DEBUG_PBR_IOR 0 // Output: grayscale IOR #define DEBUG_PBR_REFLECT0_BASE 0 // Output: black reflect0 default from ior @@ -323,9 +325,10 @@ void main() specLight = vec3(0,0.5,1.0); irradiance = specLight; #endif -#if HAS_IBL - kSpec = mix( kSpec, iridescenceFresnel, iridescenceFactor); -#endif +// TODO: +//#if PBR_USE_IBL +// kSpec = mix( kSpec, iridescenceFresnel, iridescenceFactor); +//#endif vec3 FssEssGGX = kSpec*vScaleBias.x + vScaleBias.y; #if DEBUG_PBR_SPEC_IBL vec3 debug_color_spec = specWeight * specLight * FssEssGGX; diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 41e40a07e7..769589eff1 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -278,7 +278,7 @@ void main() } } -#if DEBUG_SPOT_DIFFUSE +#if DEBUG_PBR_SPOT_DIFFUSE final_color = vec3(nl * dist_atten); #endif #if DEBUG_SPOT_NL -- cgit v1.2.3 From a8d122365db280d04552dbc23db9c43dbf1cb400 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Fri, 26 Aug 2022 09:48:18 -0700 Subject: SL-17967 - review comments --- .../newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 9286c43ace..01ed71d45d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -111,7 +111,7 @@ #define DEBUG_PBR_SUN_SPEC_FV 0 // F() * V() #define DEBUG_PBR_SUN_SPEC_DFV 0 // D() * F() * V() #define DEBUG_PBR_SUN_SPEC_NL_DFV 0 // nl * D() * F() * V() -#define DEBUG_PBR_SUN_FINAL 0 // LAMBERT_NL + NL_DFV ? +#define DEBUG_PBR_SUN_FINAL 0 // LAMBERT_NL + BRDF() #define DEBUG_PBR_IOR 0 // Output: grayscale IOR #define DEBUG_PBR_REFLECT0_BASE 0 // Output: black reflect0 default from ior @@ -325,10 +325,6 @@ void main() specLight = vec3(0,0.5,1.0); irradiance = specLight; #endif -// TODO: -//#if PBR_USE_IBL -// kSpec = mix( kSpec, iridescenceFresnel, iridescenceFactor); -//#endif vec3 FssEssGGX = kSpec*vScaleBias.x + vScaleBias.y; #if DEBUG_PBR_SPEC_IBL vec3 debug_color_spec = specWeight * specLight * FssEssGGX; -- cgit v1.2.3 From 88e1740d205bdfaa57d1d5dec4e6e9e755eae075 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 1 Sep 2022 16:18:14 -0700 Subject: SL-17967 - block layout binding acceptable to apple --- .../newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl | 2 +- .../newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl index ab5badf538..3d96fe25be 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl @@ -32,7 +32,7 @@ uniform samplerCubeArray reflectionProbes; -layout (std140, binding = 1) uniform ReflectionProbes +layout (std140) uniform ReflectionProbes { // list of OBBs for user override probes // box is a set of 3 planes outward facing planes and the depth of the box along that plane diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 1f5fdde9ca..3ff039261b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -33,7 +33,7 @@ uniform samplerCubeArray reflectionProbes; uniform samplerCubeArray irradianceProbes; -layout (std140, binding = 1) uniform ReflectionProbes +layout (std140) uniform ReflectionProbes { // list of OBBs for user override probes // box is a set of 3 planes outward facing planes and the depth of the box along that plane -- cgit v1.2.3 From b0a9044240df88df613dcf134bfb080912864e9f Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Sun, 11 Sep 2022 21:07:34 -0700 Subject: SL-17701: PBR: Fix alpha blended objects not receving Sun shadow. --- .../shaders/class1/deferred/pbralphaF.glsl | 21 +++++++++++++-------- .../shaders/class1/deferred/pbralphaV.glsl | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl index c14a30ef39..1533d1dcb0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl @@ -76,10 +76,15 @@ uniform vec3 moon_dir; #endif #endif +#ifdef HAS_SHADOW + VARYING vec3 vary_fragcoord; + uniform vec2 screen_res; +#endif VARYING vec3 vary_position; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; + #ifdef HAS_NORMAL_MAP VARYING vec3 vary_normal; VARYING vec3 vary_mat0; @@ -116,6 +121,7 @@ float calcLegacyDistanceAttenuation(float distance, float falloff); vec2 getGGX( vec2 brdfPoint ); void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight ); +float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyEnv, vec3 pos, vec3 norm, float glossiness, float envIntensity); @@ -164,15 +170,8 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; vec3 pos = vary_position; -#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) - vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); - float scol = max(scol_ambocc.r, diffuse.a); - float ambocc = scol_ambocc.g; -#else float scol = 1.0; float ambocc = 1.0; -#endif vec3 sunlit; vec3 amblit; @@ -211,6 +210,12 @@ void main() tnorm = normalize(tnorm.xyz); norm.xyz = tnorm.xyz; +#if HAS_SHADOW + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; + frag *= screen_res; + scol = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); +#endif + // RGB = Occlusion, Roughness, Metal // default values, see LLViewerFetchedTexture::sWhiteImagep since roughnessFactor and metallicFactor are multiplied in // occlusion 1.0 @@ -308,7 +313,7 @@ irradiance = vec3(amblit); vec3 light = vec3(0); // Punctual lights -#define LIGHT_LOOP(i) light += calcPointLightOrSpotLight( reflect0, c_diff, srgb_to_linear(light_diffuse[i].rgb), albedo.rgb, pos.xyz, n, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w ); +#define LIGHT_LOOP(i) light += scol * calcPointLightOrSpotLight( reflect0, c_diff, srgb_to_linear(light_diffuse[i].rgb), albedo.rgb, pos.xyz, n, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w ); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index 8cc3c11fa1..e0672f09e4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -46,6 +46,11 @@ uniform mat4 modelview_projection_matrix; uniform mat4 texture_matrix0; +#ifdef HAS_SHADOW +VARYING vec3 vary_fragcoord; +uniform float near_clip; +#endif + ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec3 normal; @@ -82,12 +87,17 @@ void main() #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vary_position = pos; #endif - gl_Position = projection_matrix*vec4(pos,1.0); + vec4 vert = projection_matrix * vec4(pos,1.0); #else //transform vertex - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vec4 vert = modelview_projection_matrix * vec4(position.xyz, 1.0); #endif - + gl_Position = vert; + +#if HAS_SHADOW + vary_fragcoord.xyz = vert.xyz + vec3(0,0,near_clip); +#endif + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; #ifdef HAS_NORMAL_MAP -- cgit v1.2.3 From 03df9545092cc3917e1c3f947ce2270d0ba31134 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 12 Sep 2022 01:22:47 -0700 Subject: SL-17701: PBR: Tweak lighting in alpha blending --- indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl index 1533d1dcb0..bde015d109 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl @@ -105,7 +105,7 @@ uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlpha // See: LLRender::syncLightState() uniform vec4 light_position[8]; uniform vec3 light_direction[8]; // spot direction -uniform vec4 light_attenuation[8]; // linear, quadratic, ?, ? +uniform vec4 light_attenuation[8]; // linear, quadratic, is omni, unused, See: LLPipeline::setupHWLights() and syncLightState() uniform vec3 light_diffuse[8]; vec2 encode_normal(vec3 n); @@ -128,8 +128,9 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 l vec3 hue_to_rgb(float hue); // lp = light position -// la = light radius +// la = linear attenuation, light radius // fa = falloff +// See: LLRender::syncLightState() vec3 calcPointLightOrSpotLight(vec3 reflect0, vec3 c_diff, vec3 lightColor, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) @@ -309,11 +310,10 @@ irradiance = vec3(amblit); #endif } vec3 col = colorDiffuse + colorEmissive + colorSpec; - vec3 light = vec3(0); // Punctual lights -#define LIGHT_LOOP(i) light += scol * calcPointLightOrSpotLight( reflect0, c_diff, srgb_to_linear(light_diffuse[i].rgb), albedo.rgb, pos.xyz, n, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w ); +#define LIGHT_LOOP(i) light += srgb_to_linear(vec3(scol)) * calcPointLightOrSpotLight( reflect0, c_diff, srgb_to_linear(2.2*light_diffuse[i].rgb), albedo.rgb, pos.xyz, n, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w ); LIGHT_LOOP(1) LIGHT_LOOP(2) -- cgit v1.2.3