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.glsl146
1 files changed, 0 insertions, 146 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 0b97ee43e3..2989332e98 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -24,9 +24,6 @@
*/
-
-
-
/* Parts of this file are taken from Sascha Willem's Vulkan GLTF refernce implementation
MIT License
@@ -351,149 +348,6 @@ vec3 hue_to_rgb(float hue)
// PBR Utils
-vec3 fresnelSchlick( vec3 reflect0, vec3 reflect90, float vh)
-{
- return reflect0 + (reflect90 - reflect0) * pow(clamp(1.0 - vh, 0.0, 1.0), 5.0);
-}
-
-// Approximate Environment BRDF
-vec2 getGGXApprox( vec2 uv )
-{
- // Reference: Physically Based Shading on Mobile
- // https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile
- // EnvBRDFApprox( vec3 SpecularColor, float Roughness, float NoV )
- float nv = uv.x;
- float roughness = uv.y;
-
- const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04 , -0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( -9.28 * nv ) ) * r.x + r.y;
- vec2 ScaleBias = vec2( -1.04, 1.04 ) * a004 + r.zw;
- return ScaleBias;
-}
-
-#define PBR_USE_GGX_APPROX 1
-vec2 getGGX( vec2 brdfPoint )
-{
-#if PBR_USE_GGX_APPROX
- return getGGXApprox( brdfPoint);
-#else
- return texture2D(GGXLUT, brdfPoint).rg; // TODO: use GGXLUT
-#endif
-}
-
-
-// Reference: float getRangeAttenuation(float range, float distance)
-float getLightAttenuationPointSpot(float range, float distance)
-{
-#if 1
- return distance;
-#else
- float range2 = pow(range, 2.0);
-
- // support negative range as unlimited
- if (range <= 0.0)
- {
- return 1.0 / range2;
- }
-
- return max(min(1.0 - pow(distance / range, 4.0), 1.0), 0.0) / range2;
-#endif
-}
-
-vec3 getLightIntensityPoint(vec3 lightColor, float lightRange, float lightDistance)
-{
- float rangeAttenuation = getLightAttenuationPointSpot(lightRange, lightDistance);
- return rangeAttenuation * lightColor;
-}
-
-float getLightAttenuationSpot(vec3 spotDirection)
-{
- return 1.0;
-}
-
-vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v)
-{
- float spotAttenuation = getLightAttenuationSpot(-v);
- return spotAttenuation * getLightIntensityPoint( lightColor, lightRange, lightDistance );
-}
-
-// NOTE: This is different from the GGX texture
-float D_GGX( float nh, float alphaRough )
-{
- float rough2 = alphaRough * alphaRough;
- float f = (nh * nh) * (rough2 - 1.0) + 1.0;
- return rough2 / (M_PI * f * f);
-}
-
-// NOTE: This is different from the GGX texture
-// See:
-// Real Time Rendering, 4th Edition
-// Page 341
-// Equation 9.43
-// Also see:
-// https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
-// 4.4.2 Geometric Shadowing (specular G)
-float V_GGX( float nl, float nv, float alphaRough )
-{
-#if 1
- // Note: When roughness is zero, has discontuinity in the bottom hemisphere
- float rough2 = alphaRough * alphaRough;
- float ggxv = nl * sqrt(nv * nv * (1.0 - rough2) + rough2);
- float ggxl = nv * sqrt(nl * nl * (1.0 - rough2) + rough2);
-
- float ggx = ggxv + ggxl;
- if (ggx > 0.0)
- {
- return 0.5 / ggx;
- }
- return 0.0;
-#else
- // See: smithVisibility_GGXCorrelated, V_SmithCorrelated, etc.
- float rough2 = alphaRough * alphaRough;
- float ggxv = nl * sqrt(nv * (nv - rough2 * nv) + rough2);
- float ggxl = nv * sqrt(nl * (nl - rough2 * nl) + rough2);
- return 0.5 / (ggxv + ggxl);
-#endif
-
-}
-
-// NOTE: Assumes a hard-coded IOR = 1.5
-void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight )
-{
- float metal = packedORM.b;
- c_diff = mix(diffuse, vec3(0), metal);
- float IOR = 1.5; // default Index Of Refraction 1.5 (dielectrics)
- reflect0 = vec3(0.04); // -> incidence reflectance 0.04
-// reflect0 = vec3(calcF0(IOR));
- reflect0 = mix(reflect0, diffuse, metal); // reflect at 0 degrees
- reflect90 = vec3(1); // reflect at 90 degrees
- specWeight = 1.0;
-
- // When roughness is zero blender shows a tiny specular
- float perceptualRough = max(packedORM.g, 0.1);
- alphaRough = perceptualRough * perceptualRough;
-}
-
-vec3 BRDFDiffuse(vec3 color)
-{
- return color * ONE_OVER_PI;
-}
-
-vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh )
-{
- return (1.0 - fresnelSchlick( reflect0, reflect90, vh)) * BRDFDiffuse(c_diff);
-}
-
-vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRough, float specWeight, float vh, float nl, float nv, float nh )
-{
- vec3 fresnel = fresnelSchlick( reflect0, reflect90, vh ); // Fresnel
- float vis = V_GGX( nl, nv, alphaRough ); // Visibility
- float d = D_GGX( nh, alphaRough ); // Distribution
- return fresnel * vis * d;
-}
-
vec2 BRDF(float NoV, float roughness)
{
return texture(brdfLut, vec2(NoV, roughness)).rg;