summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-09-12 11:48:30 -0500
committerDave Parks <davep@lindenlab.com>2022-09-12 11:48:30 -0500
commitc5af5d10edb26d255d0aa2e27eedbbd3f514024e (patch)
tree459dc84efeb2cc75b980b97311dc769b821b021c /indra/newview/app_settings/shaders/class1/deferred
parentd7c77e5c64ddfef44b3e47f4c7ae6943ff0e860a (diff)
parent03df9545092cc3917e1c3f947ce2270d0ba31134 (diff)
Merge branch 'DRTVWR-559' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl27
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl16
3 files changed, 44 insertions, 17 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 68a57d12f0..449cbeaa28 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -161,7 +161,11 @@ float getDepth(vec2 pos_screen)
vec4 getTexture2DLodAmbient(vec2 tc, float lod)
{
- vec4 ret = texture2DLod(projectionMap, tc, lod);
+#ifndef FXAA_GLSL_120
+ vec4 ret = textureLod(projectionMap, tc, lod);
+#else
+ vec4 ret = texture2D(projectionMap, tc);
+#endif
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = tc-vec2(0.5);
@@ -173,7 +177,11 @@ vec4 getTexture2DLodAmbient(vec2 tc, float lod)
vec4 getTexture2DLodDiffuse(vec2 tc, float lod)
{
- vec4 ret = texture2DLod(projectionMap, tc, lod);
+#ifndef FXAA_GLSL_120
+ vec4 ret = textureLod(projectionMap, tc, lod);
+#else
+ vec4 ret = texture2D(projectionMap, tc);
+#endif
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@@ -216,7 +224,11 @@ vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv)
vec4 texture2DLodSpecular(vec2 tc, float lod)
{
- vec4 ret = texture2DLod(projectionMap, tc, lod);
+#ifndef FXAA_GLSL_120
+ vec4 ret = textureLod(projectionMap, tc, lod);
+#else
+ vec4 ret = texture2D(projectionMap, tc);
+#endif
ret.rgb = srgb_to_linear(ret.rgb);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
index c14a30ef39..bde015d109 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
@@ -76,10 +76,15 @@ uniform vec3 moon_dir;
#endif
#endif
+#ifdef HAS_SHADOW
+ VARYING vec3 vary_fragcoord;
+ uniform vec2 screen_res;
+#endif
VARYING vec3 vary_position;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+
#ifdef HAS_NORMAL_MAP
VARYING vec3 vary_normal;
VARYING vec3 vary_mat0;
@@ -100,7 +105,7 @@ uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlpha
// See: LLRender::syncLightState()
uniform vec4 light_position[8];
uniform vec3 light_direction[8]; // spot direction
-uniform vec4 light_attenuation[8]; // linear, quadratic, ?, ?
+uniform vec4 light_attenuation[8]; // linear, quadratic, is omni, unused, See: LLPipeline::setupHWLights() and syncLightState()
uniform vec3 light_diffuse[8];
vec2 encode_normal(vec3 n);
@@ -116,14 +121,16 @@ 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);
vec3 hue_to_rgb(float hue);
// lp = light position
-// la = light radius
+// la = linear attenuation, light radius
// fa = falloff
+// See: LLRender::syncLightState()
vec3 calcPointLightOrSpotLight(vec3 reflect0, vec3 c_diff,
vec3 lightColor, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln,
float la, float fa, float is_pointlight, float ambiance)
@@ -164,15 +171,8 @@ void main()
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
vec3 pos = vary_position;
-#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
- vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
- scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
- float scol = max(scol_ambocc.r, diffuse.a);
- float ambocc = scol_ambocc.g;
-#else
float scol = 1.0;
float ambocc = 1.0;
-#endif
vec3 sunlit;
vec3 amblit;
@@ -211,6 +211,12 @@ void main()
tnorm = normalize(tnorm.xyz);
norm.xyz = tnorm.xyz;
+#if HAS_SHADOW
+ vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
+ frag *= screen_res;
+ scol = sampleDirectionalShadow(pos.xyz, norm.xyz, frag);
+#endif
+
// RGB = Occlusion, Roughness, Metal
// default values, see LLViewerFetchedTexture::sWhiteImagep since roughnessFactor and metallicFactor are multiplied in
// occlusion 1.0
@@ -304,11 +310,10 @@ irradiance = vec3(amblit);
#endif
}
vec3 col = colorDiffuse + colorEmissive + colorSpec;
-
vec3 light = vec3(0);
// Punctual lights
-#define LIGHT_LOOP(i) light += calcPointLightOrSpotLight( reflect0, c_diff, srgb_to_linear(light_diffuse[i].rgb), albedo.rgb, pos.xyz, n, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w );
+#define LIGHT_LOOP(i) light += srgb_to_linear(vec3(scol)) * calcPointLightOrSpotLight( reflect0, c_diff, srgb_to_linear(2.2*light_diffuse[i].rgb), albedo.rgb, pos.xyz, n, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w );
LIGHT_LOOP(1)
LIGHT_LOOP(2)
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
index 8cc3c11fa1..e0672f09e4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
@@ -46,6 +46,11 @@ uniform mat4 modelview_projection_matrix;
uniform mat4 texture_matrix0;
+#ifdef HAS_SHADOW
+VARYING vec3 vary_fragcoord;
+uniform float near_clip;
+#endif
+
ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec3 normal;
@@ -82,12 +87,17 @@ void main()
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
vary_position = pos;
#endif
- gl_Position = projection_matrix*vec4(pos,1.0);
+ vec4 vert = projection_matrix * vec4(pos,1.0);
#else
//transform vertex
- gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 vert = modelview_projection_matrix * vec4(position.xyz, 1.0);
#endif
-
+ gl_Position = vert;
+
+#if HAS_SHADOW
+ vary_fragcoord.xyz = vert.xyz + vec3(0,0,near_clip);
+#endif
+
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
#ifdef HAS_NORMAL_MAP