summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl146
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl11
6 files changed, 8 insertions, 163 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;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
index 077c985092..aec2a90bda 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
@@ -98,9 +98,6 @@ vec3 scaleSoftClipFrag(vec3 l);
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 calcLegacyDistanceAttenuation(float distance, float falloff);
-vec2 getGGX( vec2 brdfPoint );
-void initMaterial( vec3 diffuse, vec3 packedORM,
- out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyEnv,
vec3 pos, vec3 norm, float glossiness, float envIntensity);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index 4fbfaf9898..2ee439f61a 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -52,15 +52,11 @@ uniform mat4 inv_proj;
VARYING vec4 vary_fragcoord;
-vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh );
-vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh );
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 calcLegacyDistanceAttenuation(float distance, float falloff);
-vec3 getLightIntensityPoint(vec3 lightColor, float lightRange, float lightDistance);
vec4 getPosition(vec2 pos_screen);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
vec2 getScreenXY(vec4 clip);
-void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
vec3 srgb_to_linear(vec3 c);
// Util
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
index bcacc44d0b..6424e18079 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
@@ -73,18 +73,15 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
-vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh );
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 calcLegacyDistanceAttenuation(float distance, float falloff);
vec3 colorized_dot(float x);
bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc );
-vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float nl, float noise, vec2 projected_uv);
vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv );
vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n);
vec2 getScreenXY(vec4 clip);
-void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
vec3 srgb_to_linear(vec3 cs);
vec4 texture2DLodSpecular(vec2 tc, float lod);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index 1fc80016cb..27fca64ab3 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -57,15 +57,11 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
uniform vec4 viewport;
-vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh );
-vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh );
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 calcLegacyDistanceAttenuation(float distance, float falloff);
-vec3 getLightIntensityPoint(vec3 lightColor, float lightRange, float lightDistance);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
vec4 getPosition(vec2 pos_screen);
vec2 getScreenXY(vec4 clip);
-void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
vec3 srgb_to_linear(vec3 c);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index 787da799a5..c8d45eb429 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -82,17 +82,14 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
-vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh );
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 calcLegacyDistanceAttenuation(float distance, float falloff);
bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc );
-vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float nl, float noise, vec2 projected_uv);
vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv );
vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n);
vec2 getScreenXY(vec4 clip_point);
-void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
vec3 srgb_to_linear(vec3 c);
vec4 texture2DLodSpecular(vec2 tc, float lod);
@@ -100,6 +97,13 @@ vec4 getPosition(vec2 pos_screen);
const float M_PI = 3.14159265;
+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
+
void main()
{
#if defined(LOCAL_LIGHT_KILL)
@@ -147,6 +151,7 @@ void main()
vec3 dlit = vec3(0, 0, 0);
vec3 slit = vec3(0, 0, 0);
+ vec3 amb_rgb = vec3(0);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl