summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl26
1 files changed, 26 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 998ebf8836..56aa8437de 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -27,6 +27,10 @@
#define PBR_USE_IBL 1
#define PBR_USE_SUN 1
+#define PBR_USE_LINEAR_ALBEDO 1
+#define PBR_USE_DEFAULT_IRRADIANCE 0 // PBR: irradiance, skins/default/textures/default_irradiance.png
+#define PBR_USE_IRRADIANCE_HACK 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
@@ -135,6 +139,9 @@ uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+uniform sampler2D altDiffuseMap; // PBR: irradiance, skins/default/textures/default_irradiance.png
+
+const float M_PI = 3.14159265;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
uniform sampler2DRect lightMap;
@@ -295,7 +302,11 @@ void main()
float bv = clamp(dot(b,v),0,1);
// Reference: getMetallicRoughnessInfo
+#if PBR_USE_LINEAR_ALBEDO
+ vec3 base = diffuse.rgb;
+#else
vec3 base = linear_to_srgb(diffuse.rgb);
+#endif
float perceptualRough = max(packedORM.g, 0.1);
vec3 c_diff, reflect0, reflect90;
float alphaRough, specWeight;
@@ -321,7 +332,14 @@ void main()
#if DEBUG_PBR_IRRADIANCE_RAW
vec3 debug_irradiance = irradiance;
#endif
+
+#if PBR_USE_DEFAULT_IRRADIANCE
+ vec2 iruv = vec2(0.5f + 0.5f * atan(reflectVN.z, reflectVN.x) / M_PI, 1.f - acos(reflectVN.y) / M_PI);
+ irradiance = texture2D(altDiffuseMap, iruv).rgb * ambocc;
+#endif
+#if PBR_USE_IRRADIANCE_HACK
irradiance = max(amblit,irradiance) * ambocc;
+#endif
specLight = srgb_to_linear(specLight);
#if DEBUG_PBR_SPECLIGHT051
specLight = vec3(0,0.5,1.0);
@@ -365,8 +383,13 @@ void main()
#endif
// scol = sun shadow
vec3 intensity = ambocc * sunColor * nl * scol;
+#if PBR_USE_LINEAR_ALBEDO
+ vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
+ vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
+#else
vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
+#endif
bloom = dot(sunSpec, sunSpec) / (scale * scale * scale);
#if DEBUG_PBR_SUN_SPEC_FRESNEL
@@ -577,9 +600,11 @@ void main()
#endif
#if DEBUG_PBR_IRRADIANCE_RAW
color.rgb = debug_irradiance;
+ bloom = 0;
#endif
#if DEBUG_PBR_IRRADIANCE
color.rgb = irradiance;
+ bloom = 0;
#endif
#if DEBUG_PBR_KSPEC
color.rgb = kSpec;
@@ -633,6 +658,7 @@ void main()
#if DEBUG_PBR_LIGHT_TYPE
color.rgb = vec3(0);
#endif
+
frag_color.rgb = color.rgb; // PBR is done in linear
}
else