summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2022-08-23 04:15:36 -0700
committerPtolemy <ptolemy@lindenlab.com>2022-08-23 04:15:36 -0700
commit459faa8f7f93b4a0f83b8862eb6b4679ed3635e6 (patch)
tree820ffa3c95632146852651d9dcaccb5409f80257 /indra
parent6bc22eb6f458c73dfeb25cb5c011f5500103ae2d (diff)
SL-17703: PBR: Clamp roughness to minimum to match Blender, etc.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl10
2 files changed, 17 insertions, 11 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 8a3eb39ae7..46463818f8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -405,23 +405,31 @@ float V_GGX( float nl, float nv, float alphaRough )
return 0.0;
}
+// NOTE: Assumes a hard-coded IOR = 1.5
void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight )
{
float metal = packedORM.b;
- c_diff = mix(diffuse.rgb, vec3(0), metal);
+ c_diff = mix(diffuse, vec3(0), metal);
float IOR = 1.5; // default Index Of Refraction 1.5 (dielectrics)
reflect0 = vec3(0.04); // -> incidence reflectance 0.04
- reflect0 = mix( reflect0, diffuse.rgb, metal); // reflect at 0 degrees
+// reflect0 = vec3(calcF0(IOR));
+ reflect0 = mix(reflect0, diffuse, metal); // reflect at 0 degrees
reflect90 = vec3(1); // reflect at 90 degrees
specWeight = 1.0;
- float perceptualRough = packedORM.g;
- alphaRough = perceptualRough * perceptualRough;
+ // When roughness is zero blender shows a tiny specular
+ float perceptualRough = max(packedORM.g, 0.1);
+ alphaRough = perceptualRough * perceptualRough;
+}
+
+vec3 BRDFDiffuse(vec3 color)
+{
+ return color / M_PI;
}
vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh )
{
- return (1.0 - specWeight * fresnelSchlick( reflect0, reflect90, vh)) * (c_diff / M_PI);
+ return (1.0 - specWeight * fresnelSchlick( reflect0, reflect90, vh)) * BRDFDiffuse(c_diff);
}
vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRough, float specWeight, float vh, float nl, float nv, float nh )
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index dcb03642cd..5323159058 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -264,7 +264,6 @@ void main()
packedORM = vec3(1,1,1);
#endif
float IOR = 1.5; // default Index Of Refraction 1.5 (dielectrics)
- vec3 reflect0 = vec3(0.04); // -> incidence reflectance 0.04
#if HAS_IOR
reflect0 = vec3(calcF0(IOR));
#endif
@@ -274,7 +273,6 @@ void main()
float ao = packedORM.r;
float metal = packedORM.b;
vec3 c_diff = mix(diffuse.rgb,vec3(0),metal);
- vec3 reflect90 = vec3(0);
vec3 v = -normalize(pos.xyz);
#if DEBUG_PBR_VERT2CAM1
v = vec3(0,0,1);
@@ -292,11 +290,11 @@ void main()
float dotBV = clamp(dot(b,v),0,1);
// Reference: getMetallicRoughnessInfo
- float perceptualRough = packedORM.g;
+ vec3 base = linear_to_srgb(diffuse.rgb);
+ float perceptualRough = max(packedORM.g, 0.1);
float alphaRough = perceptualRough * perceptualRough;
- 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
+ vec3 reflect0 = mix(vec3(0.04), base, metal); // incidence reflectance 0.04 -> reflect at 0 degrees
+ vec3 reflect90 = vec3(1); // reflect at 90 degrees
#if DEBUG_PBR_REFLECTANCE
float reflectance = max( max( reflect0.r, reflect0.g ), reflect0.b );
#endif