diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred')
4 files changed, 78 insertions, 78 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index 22408387b1..7e52be7c7d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -48,7 +48,7 @@ vec3 linear_to_srgb(vec3 c);  vec3 srgb_to_linear(vec3 c);  // reflection probe interface -void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, +void sampleReflectionProbesLegacy(out vec3 ambenv, out vec3 glossenv, out vec3 legacyenv,          vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear);  void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 20f063fe3e..f5bf5bab56 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -53,7 +53,7 @@ out vec4 frag_color;  float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);  #endif -void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, +void sampleReflectionProbesLegacy(out vec3 ambenv, out vec3 glossenv, out vec3 legacyenv,          vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear);  void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm);  void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); @@ -276,10 +276,10 @@ float getShadow(vec3 pos, vec3 norm)      #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)          return sampleDirectionalShadow(pos, norm, vary_texcoord0.xy);      #else -        return 1; +        return 1.;      #endif  #else -    return 1; +    return 1.;  #endif  } diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index ae81a4b472..d19ec89cbc 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -49,7 +49,7 @@ layout (std140) uniform ReflectionProbes      mat4 refBox[MAX_REFMAP_COUNT];      // list of bounding spheres for reflection probes sorted by distance to camera (closest first)      vec4 refSphere[MAX_REFMAP_COUNT]; -    // extra parameters +    // extra parameters       //  x - irradiance scale      //  y - radiance scale      //  z - fade in @@ -95,7 +95,7 @@ bool shouldSampleProbe(int i, vec3 pos)      if (refIndex[i].w < 0)      {          vec4 v = refBox[i] * vec4(pos, 1.0); -        if (abs(v.x) > 1 || +        if (abs(v.x) > 1 ||               abs(v.y) > 1 ||              abs(v.z) > 1)          { @@ -222,7 +222,7 @@ void preProbeSample(vec3 pos)                          }                      }                      count++; - +                                          ++neighborIdx;                  } @@ -244,56 +244,56 @@ void preProbeSample(vec3 pos)  // original reference implementation:  /* -bool intersect(const Ray &ray) const -{ -        float t0, t1; // solutions for t if the ray intersects -#if 0 +bool intersect(const Ray &ray) const  +{  +        float t0, t1; // solutions for t if the ray intersects  +#if 0           // geometric solution -        Vec3f L = center - orig; -        float tca = L.dotProduct(dir); +        Vec3f L = center - orig;  +        float tca = L.dotProduct(dir);           // if (tca < 0) return false; -        float d2 = L.dotProduct(L) - tca * tca; -        if (d2 > radius2) return false; -        float thc = sqrt(radius2 - d2); -        t0 = tca - thc; -        t1 = tca + thc; -#else +        float d2 = L.dotProduct(L) - tca * tca;  +        if (d2 > radius2) return false;  +        float thc = sqrt(radius2 - d2);  +        t0 = tca - thc;  +        t1 = tca + thc;  +#else           // analytic solution -        Vec3f L = orig - center; -        float a = dir.dotProduct(dir); -        float b = 2 * dir.dotProduct(L); -        float c = L.dotProduct(L) - radius2; -        if (!solveQuadratic(a, b, c, t0, t1)) return false; -#endif -        if (t0 > t1) std::swap(t0, t1); - -        if (t0 < 0) { -            t0 = t1; // if t0 is negative, let's use t1 instead -            if (t0 < 0) return false; // both t0 and t1 are negative -        } - -        t = t0; - -        return true; +        Vec3f L = orig - center;  +        float a = dir.dotProduct(dir);  +        float b = 2 * dir.dotProduct(L);  +        float c = L.dotProduct(L) - radius2;  +        if (!solveQuadratic(a, b, c, t0, t1)) return false;  +#endif  +        if (t0 > t1) std::swap(t0, t1);  +  +        if (t0 < 0) {  +            t0 = t1; // if t0 is negative, let's use t1 instead  +            if (t0 < 0) return false; // both t0 and t1 are negative  +        }  +  +        t = t0;  +  +        return true;   } */  // adapted -- assume that origin is inside sphere, return intersection of ray with edge of sphere  vec3 sphereIntersect(vec3 origin, vec3 dir, vec3 center, float radius2) -{ -        float t0, t1; // solutions for t if the ray intersects +{  +        float t0, t1; // solutions for t if the ray intersects  -        vec3 L = center - origin; +        vec3 L = center - origin;           float tca = dot(L,dir); -        float d2 = dot(L,L) - tca * tca; - -        float thc = sqrt(radius2 - d2); -        t0 = tca - thc; -        t1 = tca + thc; +        float d2 = dot(L,L) - tca * tca;  +        float thc = sqrt(radius2 - d2);  +        t0 = tca - thc;  +        t1 = tca + thc;  +           vec3 v = origin + dir * t1; -        return v; -} +        return v;  +}   void swap(inout float a, inout float b)  { @@ -305,17 +305,17 @@ void swap(inout float a, inout float b)  // debug implementation, make no assumptions about origin  void sphereIntersectDebug(vec3 origin, vec3 dir, vec3 center, float radius2, float depth, inout vec4 col)  { -    float t[2]; // solutions for t if the ray intersects +    float t[2]; // solutions for t if the ray intersects       // geometric solution -    vec3 L = center - origin; +    vec3 L = center - origin;       float tca = dot(L, dir);      // if (tca < 0) return false; -    float d2 = dot(L, L) - tca * tca; -    if (d2 > radius2) return; -    float thc = sqrt(radius2 - d2); -    t[0] = tca - thc; -    t[1] = tca + thc; +    float d2 = dot(L, L) - tca * tca;  +    if (d2 > radius2) return;  +    float thc = sqrt(radius2 - d2);  +    t[0] = tca - thc;  +    t[1] = tca + thc;       for (int i = 0; i < 2; ++i)      { @@ -404,8 +404,8 @@ void debugBoxCol(vec3 ro, vec3 rd, float t, vec3 p, inout vec4 col)      bool behind = dot(v,v) > dot(pos,pos);      float w = 0.25; - -    if (behind) +    +    if (behind)       {          w *= 0.5;          w /= (length(v)-length(pos))*0.5+1.0; @@ -419,7 +419,7 @@ void debugBoxCol(vec3 ro, vec3 rd, float t, vec3 p, inout vec4 col)  // cribbed from https://iquilezles.org/articles/intersectors/  // axis aligned box centered at the origin, with size boxSize -void boxIntersectionDebug( in vec3 ro, in vec3 p, vec3 boxSize, inout vec4 col) +void boxIntersectionDebug( in vec3 ro, in vec3 p, vec3 boxSize, inout vec4 col)   {      vec3 rd = normalize(p-ro); @@ -446,7 +446,7 @@ void boxIntersectionDebug( in vec3 ro, in vec3 p, vec3 boxSize, inout vec4 col)  void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col)  {      mat4 clipToLocal = refBox[i]; - +          // transform into unit cube space      origin = (clipToLocal * vec4(origin, 1.0)).xyz;      pos = (clipToLocal * vec4(pos, 1.0)).xyz; @@ -464,7 +464,7 @@ void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col)  // dw - distance weight  float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, int i, out float dw)  { -    float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down) +    float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down)       vec3 delta = pos.xyz - origin;      float d2 = max(length(delta), 0.001); @@ -488,7 +488,7 @@ float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, int i, out float dw  // lod - which mip to sample (lower is higher res, sharper reflections)  // c - center of probe  // r2 - radius of probe squared -// i - index of probe +// i - index of probe   vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, int i)  {      // parallax adjustment @@ -507,7 +507,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c,          float rr = r * r; -        v = sphereIntersect(pos, dir, c, +        v = sphereIntersect(pos, dir, c,           refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres                  rr); @@ -518,7 +518,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c,      vec3 d = normalize(v);      v = env_mat * v; - +          vec4 ret = textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), lod) * refParams[i].y;      return ret.rgb; @@ -529,7 +529,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c,  // dir - pixel normal  // w - weight of sample (distance and angular attenuation)  // dw - weight of sample (distance only) -// i - index of probe +// i - index of probe   vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int i, vec3 amblit)  {      // parallax adjustment @@ -547,7 +547,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int          // pad sphere for manual probe extending into automatic probe space          float rr = r * r; -        v = sphereIntersect(pos, dir, c, +        v = sphereIntersect(pos, dir, c,           refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres                  rr); @@ -556,7 +556,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int      v -= c;      v = env_mat * v; - +          vec3 col = textureLod(irradianceProbes, vec4(v.xyz, refIndex[i].x), 0).rgb * refParams[i].x;      col = mix(amblit, col, min(refParams[i].x, 1.0)); @@ -618,7 +618,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod)          col[1] *= 1.0/wsum[1];          col[0] = vec3(0);      } - +          return col[1]+col[0];  } @@ -647,7 +647,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit)          {              continue;          } - +                  {              float w = 0;              float dw = 0; @@ -677,7 +677,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, vec3 amblit)          col[1] *= 1.0/wsum[1];          col[0] = vec3(0);      } - +          return col[1]+col[0];  } @@ -785,7 +785,7 @@ vec4 sampleReflectionProbesDebug(vec3 pos)      return col;  } -void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, +void sampleReflectionProbesLegacy(out vec3 ambenv, out vec3 glossenv, out vec3 legacyenv,          vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit)  {      float reflection_lods = max_probe_lod; @@ -800,7 +800,7 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout          float lod = (1.0-glossiness)*reflection_lods;          glossenv = sampleProbes(pos, normalize(refnormpersp), lod);      } - +          if (envIntensity > 0.0)      {          legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 47b5934b84..f4a1df9c2c 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -70,7 +70,7 @@ vec3  scaleSoftClipFragLinear(vec3 l);  // reflection probe interface  void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,      vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear); -void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, +void sampleReflectionProbesLegacy(out vec3 ambenv, out vec3 glossenv, out vec3 legacyenv,          vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity, bool transparent, vec3 amblit_linear);  void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm);  void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity); @@ -104,8 +104,8 @@ vec3 pbrBaseLight(vec3 diffuseColor,                    vec3 additive,                    vec3 atten); -vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, -                    float perceptualRoughness, +vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,  +                    float perceptualRoughness,                       float metallic,                      vec3 n, // normal                      vec3 v, // surface point to camera @@ -168,7 +168,7 @@ void main()      if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))      { -        vec3 orm = texture(specularRect, tc).rgb; +        vec3 orm = texture(specularRect, tc).rgb;           float perceptualRoughness = orm.g;          float metallic = orm.b;          float ao = orm.r; @@ -176,9 +176,9 @@ void main()          vec3 colorEmissive = texture(emissiveRect, tc).rgb;          // PBR IBL          float gloss      = 1.0 - perceptualRoughness; - +                  sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear); - +                  adjustIrradiance(irradiance, ambocc);          vec3 diffuseColor; @@ -199,7 +199,7 @@ void main()      {          // legacy shaders are still writng sRGB to gbuffer          baseColor.rgb = srgb_to_linear(baseColor.rgb); - +                  spec.rgb = srgb_to_linear(spec.rgb);          float da          = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); @@ -209,7 +209,7 @@ void main()          vec3 legacyenv = vec3(0);          sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear); - +                  adjustIrradiance(irradiance, ambocc);          // apply lambertian IBL only (see pbrIbl) @@ -218,7 +218,7 @@ void main()          vec3 sun_contrib = min(da, scol) * sunlit_linear;          color.rgb += sun_contrib;          color.rgb *= baseColor.rgb; - +                  vec3 refnormpersp = reflect(pos.xyz, norm.xyz);          if (spec.a > 0.0) @@ -247,7 +247,7 @@ void main()          }          color.rgb = mix(color.rgb, baseColor.rgb, baseColor.a); - +                  if (envIntensity > 0.0)          {  // add environment map              applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);  | 
