summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-02-24 14:54:25 -0600
committerDave Parks <davep@lindenlab.com>2023-02-24 14:54:25 -0600
commit86427ec145c7b956ec9ff5d9aa7ddde630cf45e1 (patch)
tree10cb985632f3bc903efea8c47cde0f22f0e29433 /indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
parent63ae47d8fd479a3cb05ff1d2364d683975e1b052 (diff)
SL-19212 Resurrect glare and apply to PBR materials as well (and fix color mismatch in legacy alpha vs opaque).
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl32
1 files changed, 17 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index a95feb8e2f..987b0ca1d5 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -107,16 +107,16 @@ vec3 pbrBaseLight(vec3 diffuseColor,
vec3 colorEmissive,
float ao,
vec3 additive,
- vec3 atten);
+ vec3 atten,
+ out vec3 specContrib);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l); //surface point to light
-
-vec2 BRDF(float NoV, float roughness);
+ vec3 l, //surface point to light
+ out vec3 specContrib);
vec3 calcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
@@ -127,7 +127,7 @@ vec3 calcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
vec3 lp, // light position
vec3 ld, // light direction (for spotlights)
vec3 lightColor,
- float lightSize, float falloff, float is_pointlight, float ambiance)
+ float lightSize, float falloff, float is_pointlight, inout float glare, float ambiance)
{
vec3 color = vec3(0,0,0);
@@ -149,7 +149,10 @@ vec3 calcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
vec3 intensity = spot_atten * dist_atten * lightColor * 3.0;
- color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
+ vec3 speccol;
+ color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, speccol);
+ speccol *= intensity;
+ glare += max(max(speccol.r, speccol.g), speccol.b);
}
return color;
@@ -158,6 +161,7 @@ vec3 calcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
void main()
{
vec3 color = vec3(0,0,0);
+ float glare = 0.0;
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
vec3 pos = vary_position;
@@ -224,15 +228,14 @@ void main()
vec3 v = -normalize(pos.xyz);
- color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
-
- float nv = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0);
- vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0-perceptualRoughness);
+ vec3 spec;
+ color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit, scol, radiance, irradiance, colorEmissive, ao, additive, atten, spec);
+ glare += max(max(spec.r, spec.g), spec.b);
vec3 light = vec3(0);
// Punctual lights
-#define LIGHT_LOOP(i) light += calcPointLightOrSpotLight(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, pos.xyz, v, light_position[i].xyz, light_direction[i].xyz, light_diffuse[i].rgb, light_deferred_attenuation[i].x, light_deferred_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w);
+#define LIGHT_LOOP(i) light += calcPointLightOrSpotLight(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, pos.xyz, v, light_position[i].xyz, light_direction[i].xyz, light_diffuse[i].rgb, light_deferred_attenuation[i].x, light_deferred_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w);
LIGHT_LOOP(1)
LIGHT_LOOP(2)
@@ -246,11 +249,10 @@ void main()
float a = basecolor.a*vertex_color.a;
- vec3 spec = radiance; // *specularColor;
- float lum = max(max(spec.r, spec.g), spec.b);
- float f = brdf.y;
- a += f;
+ glare = min(glare, 1.0);
+ a = max(a, glare);
+
frag_color = vec4(color.rgb,a);
}