diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 01ed71d45d..8a04a8a6a6 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -188,6 +188,7 @@ vec3 srgb_to_linear(vec3 c); // Debug Utils vec3 BRDFDiffuse(vec3 color); +vec3 colorize_dot(float x); vec3 fresnelSchlick( vec3 reflect0, vec3 reflect90, float vh); float D_GGX( float nh, float alphaRough ); float V_GGX( float nl, float nv, float alphaRough ); @@ -288,9 +289,12 @@ void main() vec3 b = cross( n,t); vec3 reflectVN = normalize(reflect(-v,n)); - float dotNV = clamp(dot(n,v),0,1); - float dotTV = clamp(dot(t,v),0,1); - float dotBV = clamp(dot(b,v),0,1); + vec3 h, l; + float nh, nl, nv, vh, lightDist; + calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist); + + float tv = clamp(dot(t,v),0,1); + float bv = clamp(dot(b,v),0,1); // Reference: getMetallicRoughnessInfo vec3 base = linear_to_srgb(diffuse.rgb); @@ -303,10 +307,10 @@ void main() #endif // Common to RadianceGGX and RadianceLambertian - vec2 brdfPoint = clamp(vec2(dotNV, perceptualRough), vec2(0,0), vec2(1,1)); + vec2 brdfPoint = clamp(vec2(nv, perceptualRough), vec2(0,0), vec2(1,1)); vec2 vScaleBias = getGGX( brdfPoint); // Environment BRDF: scale and bias applied to reflect0 vec3 fresnelR = max(vec3(1.0 - perceptualRough), reflect0) - reflect0; // roughness dependent fresnel - vec3 kSpec = reflect0 + fresnelR*pow(1.0 - dotNV, 5.0); + vec3 kSpec = reflect0 + fresnelR*pow(1.0 - nv, 5.0); // Reference: getIBLRadianceGGX // https://forum.substance3d.com/index.php?topic=3243.0 @@ -351,21 +355,18 @@ void main() colorSpec *= ao; // Add in sun/moon reflection - vec3 h, l; - float nh, nl, nv, vh, lightDist; - calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist); - if (nl > 0.0 || nv > 0.0) { - vec3 sunColor = srgb_to_linear(sunlit * 2.0); // NOTE: *2.0 Midday should have strong sunlight + float scale = 4.9; + vec3 sunColor = srgb_to_linear(sunlit * scale); // NOTE: Midday should have strong sunlight #if DEBUG_PBR_SUN_FULL_BRIGHT sunColor = vec3(1); #endif // scol = sun shadow vec3 intensity = ambocc * sunColor * nl * scol; - vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); - vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); - bloom = dot(sunSpec, sunSpec) / 8.0; + vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); + vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); + bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); #if DEBUG_PBR_SUN_SPEC_FRESNEL colorDiffuse = vec3(0); @@ -515,13 +516,13 @@ void main() color.rgb = b; #endif #if DEBUG_PBR_DOT_NV - color.rgb = vec3(dotNV); + color.rgb = vec3(nv); #endif #if DEBUG_PBR_DOT_TV - color.rgb = vec3(dotTV); + color.rgb = vec3(tv); #endif #if DEBUG_PBR_DOT_BV - color.rgb = vec3(dotBV); + color.rgb = vec3(bv); #endif #if DEBUG_PBR_AVG |