summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2022-08-23 02:22:03 -0700
committerPtolemy <ptolemy@lindenlab.com>2022-08-23 02:22:03 -0700
commit5e41024b9c02176ccfe292f067fb34f0607e59d5 (patch)
treec8f8078824e498b91ac1401b135556456fd78b09 /indra
parentf8974f4d783521846a985dd3d08067bd8e7f66a2 (diff)
SL-17703: PBR: Move IOR calcF0() to deferred utils
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl19
2 files changed, 28 insertions, 8 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index bb1265802a..8a3eb39ae7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -298,6 +298,23 @@ vec3 hue_to_rgb(float hue)
// PBR Utils
+// ior Index of Refraction, normally 1.5
+// returns reflect0
+float calcF0(float ior)
+{
+ float f0 = (1.0 - ior) / (1.0 + ior);
+ return f0 * f0;
+}
+
+vec3 fresnel(float vh, vec3 f0, vec3 f90 )
+{
+ float x = 1.0 - abs(vh);
+ float x2 = x*x;
+ float x5 = x2*x2*x;
+ vec3 fr = f0 + (f90 - f0)*x5;
+ return fr;
+}
+
vec3 fresnelSchlick( vec3 reflect0, vec3 reflect90, float vh)
{
return reflect0 + (reflect90 - reflect0) * pow(clamp(1.0 - vh, 0.0, 1.0), 5.0);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index ed478fad1c..9253b63ca1 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -138,6 +138,9 @@ vec3 getNorm(vec2 pos_screen);
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
+float calcF0(float ior);
+void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist);
+
float getAmbientClamp();
vec2 getGGX( vec2 brdfPoint );
vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
@@ -154,18 +157,18 @@ void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
+// Debug Utils
+vec3 BRDFDiffuse(vec3 color);
+vec3 fresnelSchlick( vec3 reflect0, vec3 reflect90, float vh);
+float D_GGX( float nh, float alphaRough );
+float V_GGX( float nl, float nv, float alphaRough );
+
#ifdef WATER_FOG
vec4 applyWaterFogView(vec3 pos, vec4 color);
#endif
uniform vec3 view_dir; // PBR
-vec3 calcBaseReflect0(float ior)
-{
- vec3 reflect0 = vec3(pow((ior - 1.0) / (ior + 1.0), 2.0));
- return reflect0;
-}
-
void main()
{
vec2 tc = vary_fragcoord.xy;
@@ -241,10 +244,10 @@ void main()
float IOR = 1.5; // default Index Of Refraction 1.5 (dielectrics)
vec3 reflect0 = vec3(0.04); // -> incidence reflectance 0.04
#if HAS_IOR
- reflect0 = calcBaseReflect0(IOR);
+ reflect0 = vec3(calcF0(IOR));
#endif
#if DEBUG_PBR_REFLECT0_BASE
- vec3 debug_reflect0 = reflect0;
+ vec3 debug_reflect0 = vec3(calcF0(IOR));
#endif
float metal = packedORM.b;