From 7ac0923e3375c490daa1ff1ae34a68b99e41afad Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 27 Jun 2022 14:09:44 -0700 Subject: SL-17274: Document which shader encodesNormal includes --- indra/llrender/llglslshader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 6b4778c270..68e1a8954d 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -52,7 +52,7 @@ public: bool hasShadows; bool hasAmbientOcclusion; bool hasSrgb; - bool encodesNormal; + bool encodesNormal; // include: shaders\class1\environment\encodeNormF.glsl bool isDeferred; bool hasIndirect; S32 mIndexedTextureChannels; -- cgit v1.2.3 From 402cbefc8f93b1cbfe78486951ad3836acd2195c Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 27 Jun 2022 15:01:13 -0700 Subject: SL-17274: Cleanup incorrect emissive comment --- indra/newview/lldrawpoolpbropaque.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index b0f1867e9a..86d73de14e 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -130,7 +130,7 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) if (params.mEmissiveMap) { - gDeferredPBROpaqueProgram.bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap); // Packed Occlusion Roughness Metal + gDeferredPBROpaqueProgram.bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap); } else { -- cgit v1.2.3 From 46c817d8511428662f4e325976887e1b4f669f75 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 27 Jun 2022 15:07:40 -0700 Subject: SL-17274: PBR: Fix v, dotTV, dotBV --- .../shaders/class3/deferred/softenLightF.glsl | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 243f1c4498..0ca7391e32 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -26,6 +26,7 @@ #define DEBUG_PBR_PACKORM0 0 // Rough=0, Metal=0 #define DEBUG_PBR_PACKORM1 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_RAW_DIFF 0 // Output: use diffuse in G-Buffer #define DEBUG_PBR_RAW_SPEC 0 // Output: use spec in G-Buffer @@ -41,7 +42,10 @@ #define DEBUG_PBR_SPEC 0 // Output: Final spec #define DEBUG_PBR_SPEC_REFLECTION 0 // Output: reflection #define DEBUG_PBR_NORMAL 0 // Output: passed in normal. To see raw normal map: set DEBUG_PBR_RAW_DIFF 1, and in pbropaqueF set DEBUG_NORMAL_RAW -#define DEBUG_PBR_VIEW 0 // Output: view_dir +#define DEBUG_PBR_TANGENT 0 // Output: Tangent +#define DEBUG_PBR_BITANGET 0 // Output: Bitangnet +#define DEBUG_PBR_V2C_RAW 0 // Output: vertex2camera +#define DEBUG_PBR_V2C_REMAP 0 // Output: vertex2camera (remap [-1,1] -> [0,1]) #define DEBUG_PBR_BRDF 0 // Output: Environment BRDF #define DEBUG_PBR_DOT_NV 0 // Output: grayscale dot(Normal,ViewDir) #define DEBUG_PBR_DOT_TV 0 // Output: @@ -209,7 +213,10 @@ void main() float metal = packedORM.b; vec3 reflect90 = vec3(0); - vec3 v = view_dir; + vec3 v = -normalize(pos.xyz); +#if DEBUG_PBR_VERT2CAM1 + v = vec3(0,0,1); +#endif vec3 n = norm.xyz; // vec3 t = texture2DRect(tangentMap, tc).rgb; #if DEBUG_PBR_TANGENT1 @@ -219,8 +226,8 @@ void main() vec3 reflectVN = normalize(reflect(-v,n)); float dotNV = clamp(dot(n,v),0,1); - float dotTV = clamp(dot(n,t),0,1); - float dotBV = clamp(dot(n,b),0,1); + float dotTV = clamp(dot(t,v),0,1); + float dotBV = clamp(dot(b,v),0,1); // Reference: getMetallicRoughnessInfo float perceptualRough = packedORM.g; @@ -305,8 +312,17 @@ void main() #if DEBUG_PBR_NORMAL color.rgb = norm.xyz; #endif - #if DEBUG_PBR_VIEW - color.rgb = view_dir; + #if DEBUG_PBR_TANGENT + color.rgb = t; + #endif + #if DEBUG_PBR_BITANGENT + color.rgb = b; + #endif + #if DEBUG_PBR_V2C_RAW + color.rgb = v; + #endif + #if DEBUG_PBR_V2C_REMAP + color.rgb = v*0.5 + vec3(0.5); #endif #if DEBUG_PBR_DOT_NV color.rgb = vec3(dotNV); -- cgit v1.2.3 From 780bed6c2b012473791e01d72527d1324749bf32 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 27 Jun 2022 16:39:14 -0700 Subject: SL-17274: Cleanup position --- indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index a2606ed771..82338069a8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -78,23 +78,24 @@ VARYING vec2 vary_texcoord0; void main() { + vec4 pos4 = vec4(position,1.0); #ifdef HAS_SKIN mat4 mat = getObjectSkinnedTransform(); mat = modelview_matrix * mat; - vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; + vec3 pos = (mat*pos4).xyz; #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vary_position = pos; #endif - gl_Position = projection_matrix*vec4(pos,1.0); + gl_Position = projection_matrix*pos4; #else //transform vertex - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = modelview_projection_matrix * pos4; #endif vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -- cgit v1.2.3 From 5462ac5d3b20aeefbe750ab10780346c9238bdff Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 27 Jun 2022 16:45:06 -0700 Subject: SL-17274: PBR: Fix IOR --- .../shaders/class3/deferred/softenLightF.glsl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 0ca7391e32..9b21c7a3cb 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -51,6 +51,7 @@ #define DEBUG_PBR_DOT_TV 0 // Output: #define DEBUG_PBR_DOT_BV 0 // Output: #define DEBUG_PBR_FRESNEL 0 // Output: roughness dependent fresnel +#define DEBUG_PBR_IOR 0 // Output: grayscale IOR #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable @@ -205,11 +206,14 @@ void main() #if DEBUG_PBR_PACK_ORM1 packedORM = vec3(1,1,1); #endif - float IOR = 1.5; // default Index Of Reflection 1.5 + float IOR = 1.5; // default Index Of Refraction 1.5 (dielectrics) vec3 reflect0 = vec3(0.04); // -> incidence reflectance 0.04 - - IOR = 0.0; // TODO: Set from glb - reflect0 = calcBaseReflect0(IOR); +#if HAS_IOR + reflect0 = calcBaseReflect0(IOR); +#endif +#if DEBUG_PBR_REFLECT0_BASE + vec3 debug_reflect0 = reflect0; +#endif float metal = packedORM.b; vec3 reflect90 = vec3(0); @@ -273,6 +277,12 @@ void main() #if DEBUG_PBR_FRESNEL color.rgb = fresnelR; #endif + #if DEBUG_PBR_IOR + color.rgb = vec3(IOR); + #endif + #if DEBUG_PBR_KSPEC + color.rgb = kSpec; + #endif #if DEBUG_PBR_RAW_DIFF color.rgb = diffuse.rgb; #endif -- cgit v1.2.3 From 00e5a546702c6234d5c8df8b7056bf009b46bf5e Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:33:39 -0700 Subject: SL-17274: PBR: Cleanup: Only calc reflectance if debugging --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 9b21c7a3cb..b628a0265f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -239,7 +239,9 @@ void main() vec3 colorDiff = mix( diffuse.rgb, vec3(0) , metal); reflect0 = mix( reflect0 , diffuse.rgb, metal); // reflect at 0 degrees reflect90 = vec3(1); // reflect at 90 degrees +#if DEBUG_PBR_REFLECTANCE float reflectance = max( max( reflect0.r, reflect0.g ), reflect0.b ); +#endif // Common to RadianceGGX and RadianceLambertian float specWeight = 1.0; -- cgit v1.2.3 From c69d7bab9955172393ff0cc3223077154f23b4b2 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:34:32 -0700 Subject: SL-17274: PBR: Move amblit to before PBR shading --- .../shaders/class3/deferred/softenLightF.glsl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index b628a0265f..bb14ca471d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -189,6 +189,8 @@ void main() vec3 legacyenv; sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity); + amblit = max(ambenv, amblit); + bool hasPBR = GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR); if (hasPBR) { @@ -345,10 +347,24 @@ void main() #if DEBUG_PBR_DOT_BV color.rgb = vec3(dotBV); #endif + #if DEBUG_PBR_FE_GGX + color.rgb = FssEssGGX; // spec + #endif + #if DEBUG_PBR_FE_LAMBERT + color.rgb = FssEssLambert; // diffuse + #endif +color.rgb = vec3(dotNV); +color.rgb = vec3(brdfPoint,0.0); +color.rgb = vec3(vScaleBias,0.0); +color.rgb = fresnelR; +color.rgb = kSpec; +color.rgb = reflection; +color.rgb = specLight; +//color.rgb = FssEssGGX; + } else { - amblit = max(ambenv, amblit); color.rgb = amblit*ambocc; //float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); -- cgit v1.2.3 From 4de6e8808586fe1b806f955d3ddd785c6d827a16 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:37:33 -0700 Subject: SL-17274: PBR: Add reflection vec --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index bb14ca471d..758b267b40 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -253,6 +253,7 @@ void main() vec3 kSpec = reflect0 + fresnelR*pow(1.0 - dotNV, 5.0); // Reference: getIBLRadianceGGX + vec3 reflection = normalize(reflect(-v,n)); vec3 specLight = getSpecularPBR(reflection); #if HAS_IBL kSpec = mix( kSpec, iridescenceFresnel, iridescenceFactor); -- cgit v1.2.3 From 39092990b712342a5327f3dbdd63f634d4f0d847 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:39:48 -0700 Subject: SL-17274: PBR: Add reflect0 debugging --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 758b267b40..c83fa3615e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -52,6 +52,8 @@ #define DEBUG_PBR_DOT_BV 0 // Output: #define DEBUG_PBR_FRESNEL 0 // Output: roughness dependent fresnel #define DEBUG_PBR_IOR 0 // Output: grayscale IOR +#define DEBUG_PBR_REFLECT0_BASE 0 // Output: black reflect0 default from ior +#define DEBUG_PBR_REFLECT0_MIX 0 // Output: diffuse reflect0 calculated from ior #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable @@ -294,6 +296,12 @@ void main() #if DEBUG_PBR_RAW_SPEC color.rgb = spec.rgb; #endif + #if DEBUG_PBR_REFLECT0_BASE + color.rgb = vec3(debug_reflect0); + #endif + #if DEBUG_PBR_REFLECT0_MIX + color.rgb = vec3(reflect0); + #endif #if DEBUG_PBR_REFLECTANCE color.rgb = vec3(reflectance); #endif -- cgit v1.2.3 From ea48b194237ce8a8f38bc2f3fd54808c0c32df2a Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:42:14 -0700 Subject: SL-17274: PBR: Remove manual debug --- .../shaders/class3/deferred/softenLightF.glsl | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index c83fa3615e..15a3775569 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -54,6 +54,8 @@ #define DEBUG_PBR_IOR 0 // Output: grayscale IOR #define DEBUG_PBR_REFLECT0_BASE 0 // Output: black reflect0 default from ior #define DEBUG_PBR_REFLECT0_MIX 0 // Output: diffuse reflect0 calculated from ior +#define DEBUG_PBR_FE_GGX 0 // Output: FssEssGGX +#define DEBUG_PBR_FE_LAMBERT 0 // Output: FssEssLambert #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable @@ -260,8 +262,8 @@ void main() #if HAS_IBL kSpec = mix( kSpec, iridescenceFresnel, iridescenceFactor); #endif - vec3 FssEssRadiance = kSpec*vScaleBias.x + vScaleBias.y; - colorSpec += specWeight * specLight * FssEssRadiance; + vec3 FssEssGGX = kSpec*vScaleBias.x + vScaleBias.y; + colorSpec += specWeight * specLight * FssEssGGX; // Reference: getIBLRadianceLambertian vec3 irradiance = getDiffuseLightPBR(n); @@ -362,15 +364,6 @@ void main() #if DEBUG_PBR_FE_LAMBERT color.rgb = FssEssLambert; // diffuse #endif -color.rgb = vec3(dotNV); -color.rgb = vec3(brdfPoint,0.0); -color.rgb = vec3(vScaleBias,0.0); -color.rgb = fresnelR; -color.rgb = kSpec; -color.rgb = reflection; -color.rgb = specLight; -//color.rgb = FssEssGGX; - } else { -- cgit v1.2.3 From 626ef903b272fe8636d5e18d9b9b573d9bd22321 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:43:50 -0700 Subject: SL-17274: PBR: Add kDiffuse debugging --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 15a3775569..a0a2f95651 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -56,6 +56,7 @@ #define DEBUG_PBR_REFLECT0_MIX 0 // Output: diffuse reflect0 calculated from ior #define DEBUG_PBR_FE_GGX 0 // Output: FssEssGGX #define DEBUG_PBR_FE_LAMBERT 0 // Output: FssEssLambert +#define DEBUG_PBR_DIFFUSE_K 0 // Output: diffuse FssEssLambert + FmsEms #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable @@ -313,6 +314,9 @@ void main() #if DEBUG_PBR_DIFFUSE color.rgb = colorDiffuse; #endif + #if DEBUG_PBR_DIFFUSE_K + color.rgb = kDiffuse; + #endif #if DEBUG_PBR_EMISSIVE color.rgb = colorEmissive; #endif -- cgit v1.2.3 From c55634a046b3ac2999b8dbef1a08ec5974951410 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:45:08 -0700 Subject: SL-17274: PBR: Cleanup dot() vertex2camera --- .../newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index a0a2f95651..4688d946de 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -47,9 +47,9 @@ #define DEBUG_PBR_V2C_RAW 0 // Output: vertex2camera #define DEBUG_PBR_V2C_REMAP 0 // Output: vertex2camera (remap [-1,1] -> [0,1]) #define DEBUG_PBR_BRDF 0 // Output: Environment BRDF -#define DEBUG_PBR_DOT_NV 0 // Output: grayscale dot(Normal,ViewDir) -#define DEBUG_PBR_DOT_TV 0 // Output: -#define DEBUG_PBR_DOT_BV 0 // Output: +#define DEBUG_PBR_DOT_NV 0 // Output: grayscale dot(Normal ,Vertex2Camera) +#define DEBUG_PBR_DOT_TV 0 // Output: grayscale dot(Tangent ,Vertex2Camera) +#define DEBUG_PBR_DOT_BV 0 // Output: graysacle dot(Bitangent,Vertex2Camera) #define DEBUG_PBR_FRESNEL 0 // Output: roughness dependent fresnel #define DEBUG_PBR_IOR 0 // Output: grayscale IOR #define DEBUG_PBR_REFLECT0_BASE 0 // Output: black reflect0 default from ior -- cgit v1.2.3 From c90fb9b14c61a81c2cebfaa7d92c09d98bfd06da Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 10:45:55 -0700 Subject: SL-17274: PBR: Add kSpec debugging --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 4688d946de..c97a09ab1d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -51,6 +51,7 @@ #define DEBUG_PBR_DOT_TV 0 // Output: grayscale dot(Tangent ,Vertex2Camera) #define DEBUG_PBR_DOT_BV 0 // Output: graysacle dot(Bitangent,Vertex2Camera) #define DEBUG_PBR_FRESNEL 0 // Output: roughness dependent fresnel +#define DEBUG_PBR_KSPEC 0 // Output: K spec #define DEBUG_PBR_IOR 0 // Output: grayscale IOR #define DEBUG_PBR_REFLECT0_BASE 0 // Output: black reflect0 default from ior #define DEBUG_PBR_REFLECT0_MIX 0 // Output: diffuse reflect0 calculated from ior -- cgit v1.2.3 From 7fdb05d7ef449d2cc9b96c77c7bfa41bf7c15ede Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 28 Jun 2022 11:11:40 -0700 Subject: SL-17274: PBR: Add occlusion --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index c97a09ab1d..ff2b87b9df 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -33,6 +33,7 @@ #define DEBUG_PBR_IRRADIANCE 0 // Output: Diffuse Irradiance #define DEBUG_PBR_DIFFUSE 0 // Output: Radiance Lambertian #define DEBUG_PBR_ORM 0 // Output: Packed Occlusion Roughness Metal +#define DEBUG_PBR_OCCLUSION 0 // Output: Occlusion map #define DEBUG_PBR_ROUGH_PERCEPTUAL 0 // Output: grayscale Perceptual Roughenss #define DEBUG_PBR_ROUGH_ALPHA 0 // Output: grayscale Alpha Roughness #define DEBUG_PBR_METAL 0 // Output: grayscale metal @@ -277,7 +278,11 @@ void main() vec3 kDiffuse = colorDiffuse * (1.0 - FssEssLambert + FmsEms); colorDiffuse += (FmsEms + kDiffuse) * irradiance; - color.rgb = colorDiffuse + colorEmissive + colorSpec; + float occlusion_strength = 1.0; // TODO: From glb + float ao = packedORM.r; + colorDiffuse = mix(colorDiffuse, colorDiffuse * ao, occlusion_strength); + + color.rgb = colorDiffuse + colorEmissive + colorSpec; #if DEBUG_PBR_BRDF_UV color.rgb = vec3(brdfPoint,0.0); @@ -336,6 +341,9 @@ void main() #if DEBUG_PBR_SPEC_REFLECTION color.rgb = specLight; #endif + #if DEBUG_PBR_OCCLUSION + color.rgb = vec3(packedORM.r); + #endif #if DEBUG_PBR_ORM color.rgb = packedORM; #endif -- cgit v1.2.3