summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings')
-rw-r--r--indra/newview/app_settings/settings.xml41
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl27
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl82
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/gbufferUtil.glsl59
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/globalF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl5
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/moonF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/starsF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl5
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl49
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl31
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl33
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl81
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl36
-rw-r--r--indra/newview/app_settings/shaders/class3/environment/waterF.glsl36
40 files changed, 476 insertions, 205 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index f4c8e50e46..42ed222643 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7783,6 +7783,17 @@
<key>Value</key>
<integer>0</integer>
</map>
+ <key>RenderEnableEmissiveBuffer</key>
+ <map>
+ <key>Comment</key>
+ <string>Enable emissive buffer in gbuffer. Should only be disabled in GL3 mode.</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>1</integer>
+ </map>
<key>RenderHDRIExposure</key>
<map>
<key>Comment</key>
@@ -7830,7 +7841,7 @@
<key>RenderMaxOpenGLVersion</key>
<map>
<key>Comment</key>
- <string>Maximum OpenGL version to attempt use (minimum 3.2 maximum 4.6). Requires restart.</string>
+ <string>Maximum OpenGL version to attempt use (minimum 3.1 maximum 4.6). Requires restart.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@@ -9300,14 +9311,25 @@
<key>RenderSkySunlightScale</key>
<map>
<key>Comment</key>
- <string>Sunlight scale fudge factor for matching with pre-PBR viewer</string>
+ <string>Sunlight scale fudge factor for matching with pre-PBR viewer when HDR is disabled</string>
<key>Persist</key>
- <integer>1</integer>
+ <integer>0</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>1.0</real>
</map>
+ <key>RenderHDRSkySunlightScale</key>
+ <map>
+ <key>Comment</key>
+ <string>Sunlight scale fudge factor for matching with pre-PBR viewer when HDR is enabled</string>
+ <key>Persist</key>
+ <integer>0</integer>
+ <key>Type</key>
+ <string>F32</string>
+ <key>Value</key>
+ <real>1.0</real>
+ </map>
<key>RenderSkyAmbientScale</key>
<map>
<key>Comment</key>
@@ -9317,7 +9339,7 @@
<key>Type</key>
<string>F32</string>
<key>Value</key>
- <real>0.7</real>
+ <real>1.0</real>
</map>
<key>RenderReflectionProbeMaxLocalLightAmbiance</key>
@@ -16454,5 +16476,16 @@
<key>Value</key>
<integer>1</integer>
</map>
+ <key>RenderVintageMode</key>
+ <map>
+ <key>Comment</key>
+ <string>Disable different rendering pipeline features to improve performance on older machines that makes the world look closer to how it used to prior to V7.</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
</map>
</llsd>
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 32b768cc63..cc4cd8366c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -36,7 +36,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -52,7 +52,10 @@ void main()
frag_data[0] = vec4(diff.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 79c1b392e9..a2341a80ab 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -40,7 +40,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -52,18 +52,21 @@ void main()
{
discard;
}
- col *= vertex_color;
+ col *= vertex_color;
- vec3 norm = texture(bumpMap, vary_texcoord0.xy).rgb * 2.0 - 1.0;
+ vec3 norm = texture(bumpMap, vary_texcoord0.xy).rgb * 2.0 - 1.0;
- vec3 tnorm = vec3(dot(norm,vary_mat0),
- dot(norm,vary_mat1),
- dot(norm,vary_mat2));
+ vec3 tnorm = vec3(dot(norm,vary_mat0),
+ dot(norm,vary_mat1),
+ dot(norm,vary_mat2));
- frag_data[0] = vec4(col.rgb, 0.0);
- frag_data[1] = vertex_color.aaaa; // spec
- //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
- vec3 nvn = normalize(tnorm);
- frag_data[2] = encodeNormal(nvn, GBUFFER_FLAG_HAS_ATMOS);
- frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
+ frag_data[0] = vec4(col.rgb, 0.0);
+ frag_data[1] = vertex_color.aaaa; // spec
+ //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
+ vec3 nvn = normalize(tnorm);
+ frag_data[2] = encodeNormal(nvn, vertex_color.a, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
+ frag_data[3] = vec4(0, 0, 0, 0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
index 450d4c4c4a..8c51b4a36b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
@@ -114,9 +114,15 @@ void main()
color.rgb *= 2.0;
/// Gamma correct for WL (soft clip effect).
- frag_data[0] = vec4(0);
+
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0,0,0,GBUFFER_FLAG_SKIP_ATMOS);
+
+#if defined(HAS_EMISSIVE)
+ frag_data[0] = vec4(0);
frag_data[3] = vec4(color.rgb, alpha1);
+#else
+ frag_data[0] = vec4(color.rgb, alpha1);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 0e8d8d010b..86a78f3687 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -48,8 +48,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
-uniform sampler2D normalMap;
-uniform sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D depthMap;
uniform sampler2D projectionMap; // rgba
uniform sampler2D brdfLut;
@@ -62,6 +62,8 @@ uniform float proj_lod ; // (number of mips in proj map)
uniform float proj_range; // range between near clip and far clip plane of projection
uniform float proj_ambiance;
+uniform int classic_mode;
+
// light params
uniform vec3 color; // light_color
uniform float size; // light_size
@@ -73,11 +75,11 @@ const float M_PI = 3.14159265;
const float ONE_OVER_PI = 0.3183098861;
vec3 srgb_to_linear(vec3 cs);
+vec3 linear_to_srgb(vec3 cs);
vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
vec4 decodeNormal(vec4 norm);
-
float calcLegacyDistanceAttenuation(float distance, float falloff)
{
float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0);
@@ -152,6 +154,12 @@ vec4 getNorm(vec2 screenpos)
return norm;
}
+vec4 getNormRaw(vec2 screenpos)
+{
+ vec4 norm = texture(normalMap, screenpos.xy);
+ return norm;
+}
+
// get linear depth value given a depth buffer sample d and znear and zfar values
float linearDepth(float d, float znear, float zfar)
{
@@ -352,13 +360,15 @@ vec2 BRDF(float NoV, float roughness)
}
// set colorDiffuse and colorSpec to the results of GLTF PBR style IBL
-vec3 pbrIbl(vec3 diffuseColor,
+void pbrIbl(vec3 diffuseColor,
vec3 specularColor,
vec3 radiance, // radiance map sample
vec3 irradiance, // irradiance map sample
float ao, // ambient occlusion factor
float nv, // normal dot view vector
- float perceptualRough)
+ float perceptualRough,
+ out vec3 diffuseOut,
+ out vec3 specularOut)
{
// retrieve a scale and bias to F0. See [1], Figure 3
vec2 brdf = BRDF(clamp(nv, 0.0, 1.0), 1.0-perceptualRough);
@@ -368,7 +378,8 @@ vec3 pbrIbl(vec3 diffuseColor,
vec3 diffuse = diffuseLight * diffuseColor;
vec3 specular = specularLight * (specularColor * brdf.x + brdf.y);
- return (diffuse + specular) * ao;
+ diffuseOut = diffuse * ao;
+ specularOut = specular * ao;
}
@@ -431,12 +442,15 @@ float microfacetDistribution(PBRInfo pbrInputs)
return roughnessSq / (M_PI * f * f);
}
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l) //surface point to light
+ vec3 l,
+ out float nl,
+ out vec3 diff,
+ out vec3 spec) //surface point to light
{
// make sure specular highlights from punctual lights don't fall off of polished surfaces
perceptualRoughness = max(perceptualRoughness, 8.0/255.0);
@@ -485,10 +499,11 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
// Calculation of analytical lighting contribution
vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
vec3 specContrib = F * G * D / (4.0 * NdotL * NdotV);
- // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
- vec3 color = NdotL * (diffuseContrib + specContrib);
- return clamp(color, vec3(0), vec3(10));
+ nl = NdotL;
+
+ diff = diffuseContrib;
+ spec = specContrib;
}
vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
@@ -522,7 +537,12 @@ vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
vec3 intensity = spot_atten * dist_atten * lightColor * 3.0; //magic number to balance with legacy materials
- color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
+ float nl = 0;
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
+
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, nl, diffPunc, specPunc);
+ color = intensity * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
return color;
@@ -541,10 +561,44 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v,
vec3 color = vec3(0);
float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0);
+ vec3 iblDiff = vec3(0);
+ vec3 iblSpec = vec3(0);
+ pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness, iblDiff, iblSpec);
+
+ color += iblDiff;
+
+ // For classic mode, we use a special version of pbrPunctual that basically gives us a deconstructed form of the lighting.
+ float nl = 0;
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), nl, diffPunc, specPunc);
- color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness);
+ // Depending on the sky, we combine these differently.
+ if (classic_mode > 0)
+ {
+ // Reconstruct the diffuse lighting that we do for blinn-phong materials here.
+ // A special note about why we do some really janky stuff for classic mode.
+ // Since adding classic mode, we've moved the lambertian diffuse multiply out from pbrPunctual and instead handle it in the different light type calcs.
+ // For classic mode, this baiscally introduces a double multiplication that we need to somehow avoid
+ // Using one of the old mobile gamma correction tricks (val * val to "linearize", sqrt(val) to bring back into sRGB), we can _mostly_ avert this
+ // This will never be 100% correct, but at the very least we can make it look mostly correct with legacy skies and classic mode.
+
+ float da = pow(sqrt(nl), 1.2);
+
+ vec3 sun_contrib = vec3(min(da, scol));
+
+ // Multiply by PI to account for lambertian diffuse colors. Otherwise things will be too dark when lit by the sun on legacy skies.
+ sun_contrib = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit * 0.7) * M_PI;
+
+ // Manually recombine everything here. We have to separate the shading to ensure that lighting is able to more closely match blinn-phong.
+ color.rgb = srgb_to_linear(iblDiff) + clamp(sun_contrib * (da * (diffPunc.rgb + specPunc.rgb) * scol), vec3(0), vec3(10));
+ }
+ else
+ {
+ color += clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10)) * sunlit * 3.0 * scol;
+ }
- color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir)) * sunlit * 3.0 * scol; //magic number to balance with legacy materials
+ color.rgb += iblSpec.rgb;
color += colorEmissive;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
index fadf06d592..1307ee3bcc 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
@@ -39,7 +39,7 @@ in vec2 vary_texcoord0;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -55,7 +55,10 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
index 10d06da416..5415ee80d0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
@@ -36,7 +36,7 @@ in vec4 vertex_color;
in vec2 vary_texcoord0;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -52,6 +52,9 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
index f7c8fc9596..d2ef7888a3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
@@ -33,7 +33,7 @@ uniform sampler2D diffuseMap;
in vec3 vary_normal;
in vec2 vary_texcoord0;
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -47,7 +47,10 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index d83f5a3145..85573d3baf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -35,7 +35,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -44,7 +44,10 @@ void main()
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
- frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
+ frag_data[2] = encodeNormal(nvn.xyz, vertex_color.a, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
+ frag_data[3] = vec4(0, 0, 0, 0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
index 6d8943e7ae..ad4efc863b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
@@ -33,7 +33,7 @@ in vec2 vary_texcoord0;
in vec3 vary_position;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
vec3 linear_to_srgb(vec3 c);
@@ -48,6 +48,9 @@ void main()
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vec4(spec, vertex_color.a); // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
- frag_data[3] = vec4(vertex_color.a, 0, 0, 0);
+ frag_data[2] = encodeNormal(nvn.xyz, vertex_color.a, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
+ frag_data[3] = vec4(0, 0, 0, 0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
index 67890032df..e4d89827f1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl
@@ -35,7 +35,8 @@ uniform sampler2D exposureMap;
uniform float dt;
uniform vec2 noiseVec;
-uniform vec3 dynamic_exposure_params;
+uniform vec4 dynamic_exposure_params;
+uniform vec4 dynamic_exposure_params2;
float lum(vec3 col)
{
@@ -53,11 +54,11 @@ void main()
L /= max_L;
L = pow(L, 2.0);
float s = mix(dynamic_exposure_params.z, dynamic_exposure_params.y, L);
-
#ifdef USE_LAST_EXPOSURE
float prev = texture(exposureMap, vec2(0.5,0.5)).r;
- s = mix(prev, s, min(dt*2.0*abs(prev-s), 0.04));
+ float speed = -log(dynamic_exposure_params.w) / dynamic_exposure_params2.w;
+ s = mix(prev, s, 1 - exp(-speed * dt));
#endif
frag_color = max(vec4(s, s, s, dt), vec4(0.0));
diff --git a/indra/newview/app_settings/shaders/class1/deferred/gbufferUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/gbufferUtil.glsl
new file mode 100644
index 0000000000..1ccc6e9fbc
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/gbufferUtil.glsl
@@ -0,0 +1,59 @@
+/**
+ * @file class1/deferred/gbufferUtil.glsl
+ *
+ * $LicenseInfo:firstyear=2024&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2007, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+
+#if defined(HAS_EMISSIVE)
+uniform sampler2D emissiveRect;
+#endif
+
+vec4 getNormRaw(vec2 screenpos);
+vec4 decodeNormal(vec4 norm);
+
+GBufferInfo getGBuffer(vec2 screenpos)
+{
+ GBufferInfo ret;
+ vec4 diffInfo = vec4(0);
+ vec4 specInfo = vec4(0);
+ vec4 emissInfo = vec4(0);
+
+ diffInfo = texture(diffuseRect, screenpos.xy);
+ specInfo = texture(specularRect, screenpos.xy);
+ vec4 normInfo = getNormRaw(screenpos);
+
+#if defined(HAS_EMISSIVE)
+ emissInfo = texture(emissiveRect, screenpos.xy);
+#endif
+
+ ret.albedo = diffInfo;
+ ret.normal = decodeNormal(normInfo).xyz;
+ ret.specular = specInfo;
+ ret.envIntensity = normInfo.b;
+ ret.gbufferFlag = normInfo.w;
+ ret.emissive = emissInfo;
+
+ return ret;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
index 16120508d5..9060d358cf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/globalF.glsl
@@ -43,15 +43,19 @@ void mirrorClip(vec3 pos)
}
}
-vec4 encodeNormal(vec3 norm, float gbuffer_flag)
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag)
{
- return vec4(norm * 0.5 + 0.5, gbuffer_flag);
+ float f = sqrt(8 * n.z + 8);
+ return vec4(n.xy / f + 0.5, env, gbuffer_flag);
}
vec4 decodeNormal(vec4 norm)
{
- norm.xyz = norm.xyz * 2.0 - 1.0;
- return norm;
+ vec2 fenc = norm.xy*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec4 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
}
-
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl
index 5c09950712..ca8c4caf16 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl
@@ -35,5 +35,8 @@ void main()
frag_data[0] = color*texture(diffuseMap, vary_texcoord0.xy);
frag_data[1] = vec4(0.0);
frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index a6bca68cb0..9493afcc5e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -38,7 +38,7 @@ in vec2 vary_texcoord0;
vec3 linear_to_srgb(vec3 c);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -55,5 +55,8 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = spec;
frag_data[2] = vec4(norm.xyz, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
index 3432bf07ef..4acab159cb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
@@ -51,8 +51,8 @@ void main()
vec4 norm = texture(normalMap, tc);
- if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI) &&
- !GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS))
+ if (!GET_GBUFFER_FLAG(norm.w, GBUFFER_FLAG_HAS_HDRI) &&
+ !GET_GBUFFER_FLAG(norm.w, GBUFFER_FLAG_SKIP_ATMOS))
{
// Apply the diffuse luminance scale to objects but not the sky
// Prevents underexposing when looking at bright environments
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index c23729ef30..855fe69693 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -44,7 +44,9 @@ void main()
frag_data[0] = vec4(0.5, 0, 1, 0); // gbuffer is sRGB for legacy materials
frag_data[1] = vec4(0); // XYZ = Specular color. W = Specular exponent.
frag_data[2] = vec4(0); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
#endif
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
index 585de99e1d..29b4aafc03 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
@@ -56,7 +56,13 @@ void main()
frag_data[0] = vec4(0);
frag_data[1] = vec4(0.0);
frag_data[2] = vec4(0.0, 0.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
+
+#if defined(HAS_EMISSIVE)
+ frag_data[0] = vec4(0);
frag_data[3] = vec4(c.rgb, c.a);
+#else
+ frag_data[0] = vec4(c.rgb, c.a);
+#endif
// Added and commented out for a ground truth. Do not uncomment - Geenz
//gl_FragDepth = 0.999985f;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
index c0d4c387af..dd9e883fdf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
@@ -61,7 +61,7 @@ uniform vec4 clipPlane;
uniform float clipSign;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
uniform mat3 normal_matrix;
@@ -114,8 +114,11 @@ void main()
// See: C++: addDeferredAttachments(), GLSL: softenLightF
frag_data[0] = max(vec4(col, 0.0), vec4(0)); // Diffuse
frag_data[1] = max(vec4(spec.rgb,0.0), vec4(0)); // PBR linear packed Occlusion, Roughness, Metal.
- frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags
+ frag_data[2] = encodeNormal(tnorm, 0, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = max(vec4(emissive,0), vec4(0)); // PBR sRGB Emissive
+#endif
}
#else
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
index b434479511..1b90cf9fde 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
@@ -162,7 +162,7 @@ in vec4[2] vary_coords;
#endif
void mirrorClip(vec3 position);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
float terrain_mix(TerrainMix tm, vec4 tms4);
@@ -430,7 +430,10 @@ void main()
#endif
frag_data[0] = max(vec4(pbr_mix.col.xyz, 0.0), vec4(0)); // Diffuse
frag_data[1] = max(vec4(mix_orm.rgb, base_color_factor_alpha), vec4(0)); // PBR linear packed Occlusion, Roughness, Metal.
- frag_data[2] = encodeNormal(tnorm, GBUFFER_FLAG_HAS_PBR); // normal, flags
+ frag_data[2] = encodeNormal(tnorm, 0, GBUFFER_FLAG_HAS_PBR); // normal, flags
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = max(vec4(mix_emissive,0), vec4(0)); // PBR sRGB Emissive
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
index 6791fe44d9..e77e972873 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
@@ -25,7 +25,7 @@
// debug stub
-float random (vec2 uv)
+float random (vec2 uv)
{
return 0.f;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
index 41e42b5173..7639a5e6fc 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
@@ -117,8 +117,13 @@ void main()
frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_SKIP_ATMOS);
}
- frag_data[0] = vec4(0);
frag_data[1] = vec4(0);
+
+#if defined(HAS_EMISSIVE)
+ frag_data[0] = vec4(0);
frag_data[3] = vec4(color.rgb, 1.0);
+#else
+ frag_data[0] = vec4(color.rgb, 1.0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
index 6f45adc68d..dac272c686 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
@@ -58,9 +58,14 @@ void main()
col.a = (col.a * factor) * 32.0f;
col.a *= twinkle();
- frag_data[0] = vec4(0);
frag_data[1] = vec4(0.0f);
frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
+
+#if defined(HAS_EMISSIVE)
+ frag_data[0] = vec4(0);
frag_data[3] = col;
+#else
+ frag_data[0] = col;
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl
index e3441add35..6dce67d2c5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl
@@ -48,6 +48,11 @@ void main()
frag_data[0] = vec4(0);
frag_data[1] = vec4(0.0f);
frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
+#if defined(HAS_EMISSIVE)
+ frag_data[0] = vec4(0);
frag_data[3] = c;
+#else
+ frag_data[0] = c;
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 5ff84b5937..ff6f1c0ba3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -39,7 +39,7 @@ in vec4 vary_texcoord0;
in vec4 vary_texcoord1;
void mirrorClip(vec3 position);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -61,7 +61,10 @@ void main()
frag_data[0] = max(outColor, vec4(0));
frag_data[1] = vec4(0.0,0.0,0.0,-1.0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index 0894eff660..a96c8bada5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -37,7 +37,7 @@ in vec3 vary_position;
uniform float minimum_alpha;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
void main()
{
@@ -51,6 +51,9 @@ void main()
frag_data[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = encodeNormal(nvn.xyz, GBUFFER_FLAG_HAS_ATMOS);
+ frag_data[2] = encodeNormal(nvn.xyz, 0, GBUFFER_FLAG_HAS_ATMOS);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
index 1d8a92bac7..daab7c1911 100644
--- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
+++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
@@ -64,7 +64,7 @@ in vec2 base_color_uv;
in vec2 emissive_uv;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
@@ -243,8 +243,11 @@ void main()
#else
frag_data[0] = max(vec4(basecolor.rgb, 0.0), vec4(0));
frag_data[1] = max(vec4(orm.rgb,0.0), vec4(0));
- frag_data[2] = encodeNormal(norm, GBUFFER_FLAG_HAS_PBR);
+ frag_data[2] = encodeNormal(norm, 0, GBUFFER_FLAG_HAS_PBR);
+
+//#if defined(HAS_EMISSIVE)
frag_data[3] = max(vec4(emissive,0), vec4(0));
+//#endif
#endif
#endif
diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl
index 6a628bc852..f55b83d056 100644
--- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl
+++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl
@@ -197,7 +197,7 @@ out vec3 vary_fragcoord;
layout (std140) uniform GLTFJoints
{
- mat3x4 gltf_joints[MAX_NODES_PER_GLTF_OBJECT];
+ vec4 gltf_joints[MAX_NODES_PER_GLTF_OBJECT];
};
@@ -210,27 +210,22 @@ mat4 getGLTFTransform()
vec4 w = weight4;
- uint i1 = joint.x;
- uint i2 = joint.y;
- uint i3 = joint.z;
- uint i4 = joint.w;
+ uint i1 = joint.x*3u;
+ uint i2 = joint.y*3u;
+ uint i3 = joint.z*3u;
+ uint i4 = joint.w*3u;
- mat3 mat = mat3(gltf_joints[i1])*w.x;
- mat += mat3(gltf_joints[i2])*w.y;
- mat += mat3(gltf_joints[i3])*w.z;
- mat += mat3(gltf_joints[i4])*w.w;
-
- vec3 trans = vec3(gltf_joints[i1][0].w,gltf_joints[i1][1].w,gltf_joints[i1][2].w)*w.x;
- trans += vec3(gltf_joints[i2][0].w,gltf_joints[i2][1].w,gltf_joints[i2][2].w)*w.y;
- trans += vec3(gltf_joints[i3][0].w,gltf_joints[i3][1].w,gltf_joints[i3][2].w)*w.z;
- trans += vec3(gltf_joints[i4][0].w,gltf_joints[i4][1].w,gltf_joints[i4][2].w)*w.w;
+ // lerp the joints
+ vec4 v0 = gltf_joints[i1+0u] * w.x + gltf_joints[i2+0u] * w.y + gltf_joints[i3+0u] * w.z + gltf_joints[i4+0u] * w.w;
+ vec4 v1 = gltf_joints[i1+1u] * w.x + gltf_joints[i2+1u] * w.y + gltf_joints[i3+1u] * w.z + gltf_joints[i4+1u] * w.w;
+ vec4 v2 = gltf_joints[i1+2u] * w.x + gltf_joints[i2+2u] * w.y + gltf_joints[i3+2u] * w.z + gltf_joints[i4+2u] * w.w;
+ //unpack into return matrix
mat4 ret;
-
- ret[0] = vec4(mat[0], 0);
- ret[1] = vec4(mat[1], 0);
- ret[2] = vec4(mat[2], 0);
- ret[3] = vec4(trans, 1.0);
+ ret[0] = vec4(v0.xyz, 0);
+ ret[1] = vec4(v1.xyz, 0);
+ ret[2] = vec4(v2.xyz, 0);
+ ret[3] = vec4(v0.w, v1.w, v2.w, 1.0);
return ret;
}
@@ -239,7 +234,7 @@ mat4 getGLTFTransform()
layout (std140) uniform GLTFNodes
{
- mat3x4 gltf_nodes[MAX_NODES_PER_GLTF_OBJECT];
+ vec4 gltf_nodes[MAX_NODES_PER_GLTF_OBJECT];
};
uniform int gltf_node_id = 0;
@@ -247,13 +242,17 @@ uniform int gltf_node_id = 0;
mat4 getGLTFTransform()
{
mat4 ret;
- mat3x4 src = gltf_nodes[gltf_node_id];
+ int idx = gltf_node_id*3;
+
+ vec4 src0 = gltf_nodes[idx+0];
+ vec4 src1 = gltf_nodes[idx+1];
+ vec4 src2 = gltf_nodes[idx+2];
- ret[0] = vec4(src[0].xyz, 0);
- ret[1] = vec4(src[1].xyz, 0);
- ret[2] = vec4(src[2].xyz, 0);
+ ret[0] = vec4(src0.xyz, 0);
+ ret[1] = vec4(src1.xyz, 0);
+ ret[2] = vec4(src2.xyz, 0);
- ret[3] = vec4(src[0].w, src[1].w, src[2].w, 1);
+ ret[3] = vec4(src0.w, src1.w, src2.w, 1);
return ret;
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
index ee821d3884..b63dba3cc9 100644
--- a/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/occlusionF.glsl
@@ -31,5 +31,8 @@ void main()
frag_data[0] = vec4(0, 0, 0, 0);
frag_data[1] = vec4(0, 0, 0, 0);
frag_data[2] = vec4(1, 0, 0, GBUFFER_FLAG_HAS_PBR);
+
+#if defined(HAS_EMISSIVE)
frag_data[3] = vec4(1, 0, 0, 0);
+#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
index af10ecce9a..02108a9ec1 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
@@ -41,6 +41,7 @@ uniform float scene_light_strength;
uniform float sun_moon_glow_factor;
uniform float sky_sunlight_scale;
uniform float sky_ambient_scale;
+uniform int classic_mode;
float getAmbientClamp() { return 1.0f; }
@@ -121,7 +122,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
// brightness of surface both sunlight and ambient
sunlit = sunlight.rgb;
- amblit = tmpAmbient;
+ amblit = pow(tmpAmbient.rgb, vec3(0.9)) * 0.57;
additive *= vec3(1.0 - combined_haze);
@@ -142,18 +143,22 @@ float ambientLighting(vec3 norm, vec3 light_dir)
return ambient;
}
-
// return lit amblit in linear space, leave sunlit and additive in sRGB space
void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 additive,
out vec3 atten)
{
calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten);
+ amblit *= ambientLighting(norm, light_dir);
+
+ if (classic_mode < 1)
+ {
+ amblit = srgb_to_linear(amblit);
+ sunlit = srgb_to_linear(sunlit);
+ }
+
// multiply to get similar colors as when the "scaleSoftClip" implementation was doubling color values
// (allows for mixing of light sources other than sunlight e.g. reflection probes)
sunlit *= sky_sunlight_scale;
amblit *= sky_ambient_scale;
-
- amblit = srgb_to_linear(amblit);
- amblit *= ambientLighting(norm, light_dir);
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index f4a8051427..95110005dc 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -111,13 +111,6 @@ vec3 pbrBaseLight(vec3 diffuseColor,
vec3 additive,
vec3 atten);
-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
-
vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
diff --git a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl
index 35848ff4cd..2657b2b54e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/reflectionProbeF.glsl
@@ -32,12 +32,13 @@ uniform samplerCube environmentMap;
uniform mat3 env_mat;
vec3 srgb_to_linear(vec3 c);
+vec3 linear_to_srgb(vec3 c);
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear)
{
- ambenv = vec3(reflection_probe_ambiance * 0.25);
-
+ ambenv = mix(ambenv, vec3(reflection_probe_ambiance * 0.25), reflection_probe_ambiance);
+
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
vec3 env_vec = env_mat * refnormpersp;
glossenv = srgb_to_linear(texture(environmentMap, env_vec).rgb);
@@ -58,23 +59,23 @@ vec4 sampleReflectionProbesDebug(vec3 pos)
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)
{
- ambenv = vec3(reflection_probe_ambiance * 0.25);
-
+ ambenv = mix(ambenv, vec3(reflection_probe_ambiance * 0.25), reflection_probe_ambiance);
+
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
vec3 env_vec = env_mat * refnormpersp;
- legacyenv = srgb_to_linear(texture(environmentMap, env_vec).rgb);
+ legacyenv = texture(environmentMap, env_vec).rgb;
glossenv = legacyenv;
}
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)
{
- color = mix(color.rgb, legacyenv*1.5, envIntensity);
+ color = srgb_to_linear(mix(linear_to_srgb(color.rgb), legacyenv*2.0, envIntensity));
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
index 7b82aa1a0d..487db0a6ae 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
@@ -64,8 +64,6 @@ void main()
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
- vec3 sunlit_linear = srgb_to_linear(sunlit);
-
// mask off atmospherics below water (when camera is under water)
bool do_atmospherics = false;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index fb541ab51d..140bd731ff 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -51,7 +51,7 @@ uniform mat3 normal_matrix;
in vec3 vary_position;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
@@ -415,8 +415,11 @@ void main()
frag_data[0] = max(vec4(diffcol.rgb, emissive), vec4(0)); // gbuffer is sRGB for legacy materials
frag_data[1] = max(vec4(spec.rgb, glossiness), vec4(0)); // XYZ = Specular color. W = Specular exponent.
- frag_data[2] = encodeNormal(norm, flag); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
- frag_data[3] = vec4(env, 0, 0, 0);
+ frag_data[2] = encodeNormal(norm, env, flag); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
+
+#if defined(HAS_EMISSIVE)
+ frag_data[3] = vec4(0, 0, 0, 0);
+#endif
#endif
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index 4ed778371f..8db3bcd363 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -27,9 +27,6 @@
out vec4 frag_color;
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D lightFunc;
uniform vec3 env_mat[3];
@@ -55,13 +52,17 @@ vec3 srgb_to_linear(vec3 c);
// Util
vec3 hue_to_rgb(float hue);
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l); //surface point to light
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
+GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
@@ -73,18 +74,19 @@ void main()
discard;
}
- vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG()
- vec3 n = norm.xyz;
+ GBufferInfo gb = getGBuffer(tc);
- vec4 spec = texture(specularRect, tc);
- vec3 diffuse = texture(diffuseRect, tc).rgb;
+ vec3 n = gb.normal;
+
+ vec4 spec = gb.specular;
+ vec3 diffuse = gb.albedo.rgb;
vec3 h, l, v = -normalize(pos);
float nh, nv, vh, lightDist;
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture(emissiveRect, tc).rgb;
+ vec3 colorEmissive = gb.emissive.rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
@@ -113,8 +115,11 @@ void main()
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
vec3 intensity = dist_atten * lightColor * 3.25;
-
- final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
+ float nl = 0;
+ vec3 diff = vec3(0);
+ vec3 specPunc = vec3(0);
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, nl, diff, specPunc);
+ final_color += intensity * clamp(nl * (diff + specPunc), vec3(0), vec3(10));
}
}
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index 6c13757149..987089fcc9 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -27,9 +27,6 @@
out vec4 frag_color;
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D lightFunc;
uniform vec3 env_mat[3];
@@ -57,24 +54,29 @@ vec2 getScreenCoord(vec4 clip);
vec3 srgb_to_linear(vec3 c);
float getDepth(vec2 tc);
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l); //surface point to light
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
+
+GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
vec3 final_color = vec3(0);
vec2 tc = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
+ GBufferInfo gb = getGBuffer(tc);
- vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG()
- vec3 n = norm.xyz;
+ vec3 n = gb.normal;
- vec3 diffuse = texture(diffuseRect, tc).rgb;
- vec4 spec = texture(specularRect, tc);
+ vec3 diffuse = gb.albedo.rgb;
+ vec4 spec = gb.specular;
// Common half vectors calcs
vec3 lv = trans_center.xyz-pos;
@@ -89,9 +91,9 @@ void main()
float dist = lightDist / size;
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture(emissiveRect, tc).rgb;
+ vec3 colorEmissive = gb.emissive.rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
@@ -104,7 +106,14 @@ void main()
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
vec3 intensity = dist_atten * color * 3.25; // Legacy attenuation, magic number to balance with legacy materials
- final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv));
+
+ float nl = 0;
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
+
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
+
+ final_color += intensity* clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
else
{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
index dc135243a6..5eda28bd8a 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
@@ -66,7 +66,7 @@ void main()
vec4 fcol = texture(diffuseMap, tc);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(norm.w, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = specCol.rgb;
float perceptualRoughness = orm.g;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 802d049e74..ae6c23be05 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -23,16 +23,12 @@
* $/LicenseInfo$
*/
+/*[EXTRA_CODE_HERE]*/
+
#define FLT_MAX 3.402823466e+38
out vec4 frag_color;
-vec4 decodeNormal(vec4 norm);
-
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
-
const float M_PI = 3.14159265;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
@@ -56,6 +52,8 @@ uniform mat3 ssao_effect_mat;
uniform vec3 sun_dir;
uniform vec3 moon_dir;
uniform int sun_up_factor;
+uniform int classic_mode;
+
in vec2 vary_fragcoord;
uniform mat4 inv_proj;
@@ -105,13 +103,7 @@ vec3 pbrBaseLight(vec3 diffuseColor,
vec3 additive,
vec3 atten);
-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
-
+GBufferInfo getGBuffer(vec2 screenpos);
void adjustIrradiance(inout vec3 irradiance, float ambocc)
{
@@ -128,13 +120,15 @@ void main()
vec2 tc = vary_fragcoord.xy;
float depth = getDepth(tc.xy);
vec4 pos = getPositionWithDepth(tc, depth);
- vec4 norm = getNorm(tc);
- vec3 colorEmissive = texture(emissiveRect, tc).rgb;
- float envIntensity = colorEmissive.r;
+
+ GBufferInfo gb = getGBuffer(tc);
+
+ vec3 colorEmissive = gb.emissive.rgb;
+ float envIntensity = gb.envIntensity;
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
- vec4 baseColor = texture(diffuseRect, tc);
- vec4 spec = texture(specularRect, tc); // NOTE: PBR linear Emissive
+ vec4 baseColor = gb.albedo;
+ vec4 spec = gb.specular; // NOTE: PBR linear Emissive
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
vec2 scol_ambocc = texture(lightMap, vary_fragcoord.xy).rg;
@@ -159,26 +153,26 @@ void main()
vec3 additive;
vec3 atten;
- calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
+ calcAtmosphericVarsLinear(pos.xyz, gb.normal, light_dir, sunlit, amblit, additive, atten);
- vec3 sunlit_linear = srgb_to_linear(sunlit);
+ vec3 sunlit_linear = sunlit;
vec3 amblit_linear = amblit;
- vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
float ao = orm.r;
+ vec3 irradiance = amblit_linear;
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
- sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear);
+ sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, gb.normal, gloss, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
@@ -187,17 +181,21 @@ void main()
calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor);
vec3 v = -normalize(pos.xyz);
- color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
+ color = pbrBaseLight(diffuseColor, specularColor, metallic, v, gb.normal, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
}
- else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI))
+ else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_HDRI))
{
// actual HDRI sky, just copy color value
color = colorEmissive.rgb;
}
- else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS))
+ else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_SKIP_ATMOS))
{
//should only be true of WL sky, port over base color value and scale for fake HDR
+#if defined(HAS_EMISSIVE)
color = colorEmissive.rgb;
+#else
+ color = baseColor.rgb;
+#endif
color = srgb_to_linear(color);
color *= sky_hdr_scale;
}
@@ -208,31 +206,43 @@ void main()
spec.rgb = srgb_to_linear(spec.rgb);
- float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
+ float da = clamp(dot(gb.normal, light_dir.xyz), 0.0, 1.0);
- vec3 irradiance = vec3(0);
+ vec3 irradiance = amblit;
vec3 glossenv = vec3(0);
vec3 legacyenv = vec3(0);
- sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear);
+ sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, gb.normal, spec.a, envIntensity, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
// apply lambertian IBL only (see pbrIbl)
color.rgb = irradiance;
- vec3 sun_contrib = min(da, scol) * sunlit_linear;
- color.rgb += sun_contrib;
+ if (classic_mode > 0)
+ {
+ da = pow(da,1.2);
+ vec3 sun_contrib = vec3(min(da, scol));
+
+ color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7);
+ sunlit_linear = srgb_to_linear(sunlit_linear);
+ }
+ else
+ {
+ vec3 sun_contrib = min(da, scol) * sunlit_linear;
+ color.rgb += sun_contrib;
+ }
+
color.rgb *= baseColor.rgb;
- vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
+ vec3 refnormpersp = reflect(pos.xyz, gb.normal);
if (spec.a > 0.0)
{
vec3 lv = light_dir.xyz;
vec3 h, l, v = -normalize(pos.xyz);
float nh, nl, nv, vh, lightDist;
- vec3 n = norm.xyz;
+ vec3 n = gb.normal;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
if (nl > 0.0 && nh > 0.0)
@@ -249,7 +259,7 @@ void main()
}
// add radiance map
- applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz);
+ applyGlossEnv(color, glossenv, spec, pos.xyz, gb.normal);
}
@@ -257,10 +267,11 @@ void main()
if (envIntensity > 0.0)
{ // add environment map
- applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
+ applyLegacyEnv(color, legacyenv, spec, pos.xyz, gb.normal, envIntensity);
}
}
+ //color.r = classic_mode > 0 ? 1.0 : 0.0;
frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index bc4d36d10d..78db8ccf5b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -27,9 +27,6 @@
out vec4 frag_color;
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform samplerCube environmentMap;
uniform sampler2D lightMap;
uniform sampler2D lightFunc;
@@ -80,12 +77,17 @@ vec4 getPosition(vec2 pos_screen);
const float M_PI = 3.14159265;
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l); //surface point to light
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
+
+GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
@@ -118,8 +120,9 @@ void main()
shadow = clamp(shadow, 0.0, 1.0);
}
- vec4 norm = getNorm(tc);
- vec3 n = norm.xyz;
+ GBufferInfo gb = getGBuffer(tc);
+
+ vec3 n = gb.normal;
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
if (dist_atten <= 0.0)
@@ -132,14 +135,14 @@ void main()
float nh, nl, nv, vh, lightDist;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
- vec3 diffuse = texture(diffuseRect, tc).rgb;
- vec4 spec = texture(specularRect, tc);
+ vec3 diffuse = gb.albedo.rgb;
+ vec4 spec = gb.specular;
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))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
@@ -151,6 +154,8 @@ void main()
diffuseColor *= 1.0 - metallic;
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
// We need this additional test inside a light's frustum since a spotlight's ambiance can be applied
if (proj_tc.x > 0.0 && proj_tc.x < 1.0
@@ -168,16 +173,21 @@ void main()
dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
vec3 intensity = dist_atten * dlit * 3.25 * shadow; // Legacy attenuation, magic number to balance with legacy materials
- final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
+
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
+
+ final_color += intensity * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy ) * 3.25; //magic number to balance with legacy ambiance
- final_color += amb_rgb * pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, -lv);
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
+
+ final_color += amb_rgb * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
}
else
{
- float envIntensity = texture(emissiveRect, tc).r;
+ float envIntensity = gb.envIntensity;
diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb);
diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
index 03da5b020f..84c287fc50 100644
--- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
@@ -42,20 +42,25 @@ vec2 BRDF(float NoV, float roughness);
void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor);
-vec3 pbrIbl(vec3 diffuseColor,
+void pbrIbl(vec3 diffuseColor,
vec3 specularColor,
vec3 radiance, // radiance map sample
vec3 irradiance, // irradiance map sample
float ao, // ambient occlusion factor
float nv, // normal dot view vector
- float perceptualRoughness);
-
-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
+ out vec3 diffuse,
+ out vec3 specular);
+
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+ float perceptualRoughness,
+ float metallic,
+ vec3 n, // normal
+ vec3 v, // surface point to camera
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
vec3 pbrBaseLight(vec3 diffuseColor,
vec3 specularColor,
@@ -257,13 +262,20 @@ void main()
float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0);
- vec3 punctual = pbrPunctual(vec3(0), specularColor, 0.1, metallic, normalize(wavef+up*max(dist, 32.0)/32.0*(1.0-vdu)), v, normalize(light_dir));
+ float nl = 0;
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
- vec3 color = punctual * sunlit_linear * 2.75 * shadow;
+ pbrPunctual(vec3(0), specularColor, 0.1, metallic, normalize(wavef+up*max(dist, 32.0)/32.0*(1.0-vdu)), v, normalize(light_dir), nl, diffPunc, specPunc);
- vec3 ibl = pbrIbl(vec3(0), vec3(1), radiance, vec3(0), ao, NdotV, 0.0);
+ vec3 punctual = clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
+
+ vec3 color = punctual * sunlit_linear * 2.75 * shadow;
+ vec3 iblDiff;
+ vec3 iblSpec;
+ pbrIbl(vec3(0), vec3(1), radiance, vec3(0), ao, NdotV, 0.0, iblDiff, iblSpec);
- color += ibl;
+ color += iblDiff + iblSpec;
float nv = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0);
vec2 brdf = BRDF(clamp(nv, 0.0, 1.0), 1.0);