summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl34
1 files changed, 17 insertions, 17 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index d32455d70c..63ab0b9b38 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -80,6 +80,18 @@ vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
vec4 decodeNormal(vec4 norm);
+vec3 clampHDRRange(vec3 color)
+{
+ // Why do this?
+ // There are situations where the color range will go to something insane - potentially producing infs and NaNs even.
+ // This is a safety measure to prevent that.
+ // As to the specific number there - allegedly some HDR displays expect values to be in the 0-11.2 range. Citation needed.
+ // -Geenz 2025-03-05
+ color = mix(color, vec3(1), isinf(color));
+ color = mix(color, vec3(0.0), isnan(color));
+ return clamp(color, vec3(0.0), vec3(11.2));
+}
+
float calcLegacyDistanceAttenuation(float distance, float falloff)
{
float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0);
@@ -426,9 +438,10 @@ float geometricOcclusion(PBRInfo pbrInputs)
float NdotL = pbrInputs.NdotL;
float NdotV = pbrInputs.NdotV;
float r = pbrInputs.alphaRoughness;
+ float r2 = r * r;
- float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
- float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
+ float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r2 + (1.0 - r2) * (NdotL * NdotL)));
+ float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r2 + (1.0 - r2) * (NdotV * NdotV)));
return attenuationL * attenuationV;
}
@@ -613,24 +626,11 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v,
uniform vec4 waterPlane;
uniform float waterSign;
-// discard if given position in eye space is on the wrong side of the waterPlane according to waterSign
void waterClip(vec3 pos)
{
- // TODO: make this less branchy
- if (waterSign > 0.0)
+ if (((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) * waterSign) < 0.0)
{
- if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) < 0.0)
- {
- discard;
- }
+ discard;
}
- else
- {
- if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) > 0.0)
- {
- discard;
- }
- }
-
}