diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
3 files changed, 73 insertions, 97 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 925398671c..211e1f5d8d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -114,8 +114,7 @@ bool shouldSampleProbe(int i, vec3 pos) void preProbeSample(vec3 pos) { // TODO: make some sort of structure that reduces the number of distance checks - - for (int i = 0; i < refmapCount; ++i) + for (int i = 1; i < refmapCount; ++i) { // found an influencing probe if (shouldSampleProbe(i, pos)) @@ -200,6 +199,12 @@ void preProbeSample(vec3 pos) } } } + + if (probeInfluences == 0) + { // probe at index 0 is a special fallback probe + probeIndex[0] = 0; + probeInfluences = 1; + } } // from https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection @@ -316,7 +321,7 @@ vec3 boxIntersect(vec3 origin, vec3 dir, int i) // c - center of probe // r2 - radius of probe squared // i - index of probe -vec3 tapRefMap(vec3 pos, vec3 dir, out vec3 vi, out vec3 wi, float lod, vec3 c, float r2, int i) +vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out vec3 vi, out vec3 wi, float lod, vec3 c, int i) { //lod = max(lod, 1); // parallax adjustment @@ -326,10 +331,26 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out vec3 vi, out vec3 wi, float lod, vec3 c, if (refIndex[i].w < 0) { v = boxIntersect(pos, dir, i); + w = 1.0; } else { - v = sphereIntersect(pos, dir, c, r2); + float r = refSphere[i].w; // radius of sphere volume + float rr = r * r; // radius squared + + v = sphereIntersect(pos, dir, c, rr); + + float p = float(abs(refIndex[i].w)); // priority + + float r1 = r * 0.1; // 90% of radius (outer sphere to start interpolating down) + vec3 delta = pos.xyz - refSphere[i].xyz; + float d2 = max(dot(delta, delta), 0.001); + float r2 = r1 * r1; + + float atten = 1.0 - max(d2 - r2, 0.0) / max((rr - r2), 0.001); + + w = 1.0 / d2; + w *= atten; } vi = v; @@ -352,19 +373,32 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out vec3 vi, out vec3 wi, float lod, vec3 c, // c - center of probe // r2 - radius of probe squared // i - index of probe -vec3 tapIrradianceMap(vec3 pos, vec3 dir, vec3 c, float r2, int i) +vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, vec3 c, int i) { - //lod = max(lod, 1); // parallax adjustment - vec3 v; if (refIndex[i].w < 0) { v = boxIntersect(pos, dir, i); + w = 1.0; } else { - v = sphereIntersect(pos, dir, c, r2); + float r = refSphere[i].w; // radius of sphere volume + float p = float(abs(refIndex[i].w)); // priority + float rr = r * r; // radius squred + + v = sphereIntersect(pos, dir, c, rr); + + float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) + vec3 delta = pos.xyz - refSphere[i].xyz; + float d2 = dot(delta, delta); + float r2 = r1 * r1; + + w = 1.0 / d2; + + float atten = 1.0 - max(d2 - r2, 0.0) / (rr - r2); + w *= atten; } v -= c; @@ -387,26 +421,17 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) { continue; } - float r = refSphere[i].w; // radius of sphere volume - float p = float(abs(refIndex[i].w)); // priority - - float rr = r*r; // radius squred - float r1 = r * 0.1; // 90% of radius (outer sphere to start interpolating down) - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - float r2 = r1*r1; - - { - vec3 vi, wi; - float atten = 1.0 - max(d2 - r2, 0.0) / (rr - r2); - float w; - vec3 refcol; + float w; + vec3 vi, wi; + vec3 refcol; + + { if (errorCorrect && refIndex[i].w >= 0) { // error correction is on and this probe is a sphere //take a sample to get depth value, then error correct - refcol = tapRefMap(pos, dir, vi, wi, abs(lod + 2), refSphere[i].xyz, rr, i); + refcol = tapRefMap(pos, dir, w, vi, wi, abs(lod + 2), refSphere[i].xyz, i); //adjust lookup by distance result float d = length(vi - wi); @@ -420,48 +445,20 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) // weight by vector correctness vec3 pi = normalize(wi - pos); - w = max(dot(pi, dir), 0.1); - w = pow(w, 32.0); + w *= max(dot(pi, dir), 0.1); + //w = pow(w, 32.0); } else { - w = 1.0 / d2; - refcol = tapRefMap(pos, dir, vi, wi, lod, refSphere[i].xyz, rr, i); + refcol = tapRefMap(pos, dir, w, vi, wi, lod, refSphere[i].xyz, i); } - w *= atten; - - //w *= p; // boost weight based on priority col += refcol.rgb*w; wsum += w; } } - if (probeInfluences < 1) - { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera - for (int idx = 0; idx < 8; ++idx) - { - if (refIndex[idx].w < 0) - { // don't fallback to box probes, they are *very* specific - continue; - } - int i = idx; - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - - { - vec3 vi, wi; - vec3 refcol = tapRefMap(pos, dir, vi, wi, lod, refSphere[i].xyz, d2, i); - - float w = 1.0/d2; - w *= w; - col += refcol.rgb*w; - wsum += w; - } - } - } - if (wsum > 0.0) { col *= 1.0/wsum; @@ -487,52 +484,17 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir) { continue; } - float r = refSphere[i].w; // radius of sphere volume - float p = float(abs(refIndex[i].w)); // priority - - float rr = r*r; // radius squred - float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - float r2 = r1*r1; { - vec3 refcol = tapIrradianceMap(pos, dir, refSphere[i].xyz, rr, i); - - float w = 1.0/d2; + float w; + vec3 refcol = tapIrradianceMap(pos, dir, w, refSphere[i].xyz, i); - float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); - w *= atten; - //w *= p; // boost weight based on priority col += refcol*w; wsum += w; } } - if (probeInfluences <= 1) - { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera - for (int idx = 0; idx < 8; ++idx) - { - if (refIndex[idx].w < 0) - { // don't fallback to box probes, they are *very* specific - continue; - } - int i = idx; - vec3 delta = pos.xyz-refSphere[i].xyz; - float d2 = dot(delta,delta); - - { - vec3 refcol = tapIrradianceMap(pos, dir, refSphere[i].xyz, d2, i); - - float w = 1.0/d2; - w *= w; - col += refcol*w; - wsum += w; - } - } - } - if (wsum > 0.0) { col *= 1.0/wsum; diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl index 819e6dcf15..a5e0adf8fa 100644 --- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl @@ -26,10 +26,12 @@ out vec4 frag_color; uniform sampler2D diffuseMap; -uniform sampler2D bumpMap; +uniform sampler2D bumpMap; + +#ifdef TRANSPARENT_WATER uniform sampler2D screenTex; -uniform sampler2D refTex; uniform sampler2D screenDepth; +#endif uniform vec4 fogCol; uniform vec3 lightDir; @@ -43,6 +45,7 @@ uniform float kd; uniform vec4 waterPlane; uniform vec3 eyeVec; uniform vec4 waterFogColor; +uniform vec3 waterFogColorLinear; uniform float waterFogKS; uniform vec2 screenRes; @@ -57,8 +60,8 @@ vec4 applyWaterFogViewLinear(vec3 pos, vec4 color); void main() { vec4 color; - - //get detail normals + + //get detail normals vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; @@ -67,8 +70,12 @@ void main() //figure out distortion vector (ripply) vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; distort = distort+wavef.xy*refScale; - + +#ifdef TRANSPARENT_WATER vec4 fb = texture2D(screenTex, distort); - +#else + vec4 fb = vec4(waterFogColorLinear, 0.0); +#endif + frag_color = applyWaterFogViewLinear(vary_position, fb); } diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 9793a0e786..a6517be433 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -55,8 +55,10 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, uniform sampler2D bumpMap; uniform sampler2D bumpMap2; uniform float blend_factor; +#ifdef TRANSPARENT_WATER uniform sampler2D screenTex; uniform sampler2D screenDepth; +#endif uniform sampler2D refTex; @@ -73,6 +75,7 @@ uniform float fresnelScale; uniform float fresnelOffset; uniform float blurMultiplier; uniform vec4 waterFogColor; +uniform vec3 waterFogColorLinear; //bigWave is (refCoord.w, view.w); @@ -174,6 +177,7 @@ void main() vec2 distort2 = distort + waver.xy * refScale / max(dmod * df1, 1.0); distort2 = clamp(distort2, vec2(0), vec2(0.99)); +#ifdef TRANSPARENT_WATER vec4 fb = texture2D(screenTex, distort2); float depth = texture2D(screenDepth, distort2).r; vec3 refPos = getPositionWithNDC(vec3(distort2*2.0-vec2(1.0), depth*2.0-1.0)); @@ -188,6 +192,9 @@ void main() } fb = applyWaterFogViewLinear(refPos, fb); +#else + vec4 fb = vec4(waterFogColorLinear.rgb, 0.0); +#endif vec3 sunlit; vec3 amblit; |