diff options
author | Graham Linden <graham@lindenlab.com> | 2019-03-07 10:56:26 -0800 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-03-07 10:56:26 -0800 |
commit | 423fa1ac297e39c9395f45490278b8751188b6db (patch) | |
tree | 35b1689b3121f59448e53d06ba22f7d4118df305 /indra/newview/app_settings/shaders/class1/deferred | |
parent | f488e5855a310d0db55baac758da5c2f8621d2ee (diff) |
SL-10618, SL-10698
Fix reflection/distortion map culling planes again.
Fix broken handling of shadow disables in ALM forward shaders.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
7 files changed, 35 insertions, 69 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 9191787273..a5076ef609 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -77,17 +77,11 @@ vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -#if defined(VERT_ATMOSPHERICS) -vec3 getSunlitColor(); -vec3 getAmblitColor(); -vec3 getAdditiveColor(); -vec3 getAtmosAttenuation(); -void calcAtmospherics(vec3 inPositionEye, float ambFactor); -#else void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); -#endif +#ifdef HAS_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +#endif vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) { @@ -142,7 +136,11 @@ void main() vec4 pos = vec4(vary_position, 1.0); vec3 norm = vary_norm; - float shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); + float shadow = 1.0f; + +#ifdef HAS_SHADOW + shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); +#endif #ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); @@ -184,14 +182,7 @@ void main() vec3 additive; vec3 atten; -#if defined(VERT_ATMOSPHERICS) - sunlit = getSunlitColor(); - amblit = getAmblitColor(); - additive = getAdditiveColor(); - atten = getAtmosAttenuation(); -#else calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); -#endif vec2 abnormal = encode_normal(norm.xyz); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 2db737a427..08ddaeceb3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -33,7 +33,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if !HAS_DIFFUSE_LOOKUP +#if !defined(HAS_DIFFUSE_LOOKUP) uniform sampler2D diffuseMap; #endif @@ -62,7 +62,7 @@ uniform float minimum_alpha; void main() { -#if HAS_DIFFUSE_LOOKUP +#ifdef HAS_DIFFUSE_LOOKUP vec4 color = diffuseLookup(vary_texcoord0.xy); #else vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl index 30e560450b..4005d5064d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl @@ -31,7 +31,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#ifndef diffuseLookup +#ifndef HAS_DIFFUSE_LOOKUP uniform sampler2D diffuseMap; #endif @@ -46,7 +46,7 @@ vec3 fullbrightScaleSoftClip(vec3 light); void main() { -#if HAS_DIFFUSE_LOOKUP +#ifdef HAS_DIFFUSE_LOOKUP vec4 color = diffuseLookup(vary_texcoord0.xy); #else vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 4db2b9ae54..dd691fb36b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -41,14 +41,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); -#if defined(VERT_ATMOSPHERICS) -vec3 getSunlitColor(); -vec3 getAmblitColor(); -vec3 getAdditiveColor(); -vec3 getAtmosAttenuation(); -#else void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); -#endif vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); @@ -61,7 +54,9 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +#ifdef HAS_SUN_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); +#endif uniform samplerCube environmentMap; uniform sampler2D lightFunc; @@ -172,11 +167,11 @@ out vec4 frag_data[3]; uniform sampler2D diffuseMap; -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP uniform sampler2D bumpMap; #endif -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP uniform sampler2D specularMap; VARYING vec2 vary_texcoord2; @@ -189,7 +184,7 @@ uniform vec4 specular_color; // specular color RGB and specular exponent (gloss uniform float minimum_alpha; #endif -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP VARYING vec3 vary_mat0; VARYING vec3 vary_mat1; VARYING vec3 vary_mat2; @@ -221,14 +216,14 @@ void main() vec3 gamma_diff = diffcol.rgb; #endif -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP vec4 spec = texture2D(specularMap, vary_texcoord2.xy); spec.rgb *= specular_color.rgb; #else vec4 spec = vec4(specular_color.rgb, 1.0); #endif -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); norm.xyz = norm.xyz * 2 - 1; @@ -255,7 +250,7 @@ void main() #endif vec4 final_specular = spec; -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity * spec.a, 0.0); final_specular.a = specular_color.a * norm.a; #else @@ -268,8 +263,12 @@ void main() //forward rendering, output just lit RGBA vec3 pos = vary_position; - float shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, pos_screen); + float shadow = 1.0f; +#ifdef HAS_SUN_SHADOW + shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, pos_screen); +#endif + spec = final_specular; vec4 diffuse = final_color; @@ -285,14 +284,7 @@ void main() vec3 additive; vec3 atten; -#if defined(VERT_ATMOSPHERICS) - sunlit = getSunlitColor(); - amblit = getAmblitColor(); - additive = getAdditiveColor(); - atten = getAtmosAttenuation(); -#else calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); -#endif vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index 393d1e69da..7e29ada205 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -28,7 +28,7 @@ #define DIFFUSE_ALPHA_MODE_MASK 2 #define DIFFUSE_ALPHA_MODE_EMISSIVE 3 -#if HAS_SKIN +#ifdef HAS_SKIN uniform mat4 modelview_matrix; uniform mat4 projection_matrix; mat4 getObjectSkinnedTransform(); @@ -39,7 +39,7 @@ uniform mat4 modelview_projection_matrix; #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) -#if !HAS_SKIN +#if !defined(HAS_SKIN) uniform mat4 modelview_matrix; #endif @@ -55,7 +55,7 @@ ATTRIBUTE vec3 normal; ATTRIBUTE vec2 texcoord0; -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP ATTRIBUTE vec4 tangent; ATTRIBUTE vec2 texcoord1; @@ -68,7 +68,7 @@ VARYING vec2 vary_texcoord1; VARYING vec3 vary_normal; #endif -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP ATTRIBUTE vec2 texcoord2; VARYING vec2 vary_texcoord2; #endif @@ -78,7 +78,7 @@ VARYING vec2 vary_texcoord0; void main() { -#if HAS_SKIN +#ifdef HAS_SKIN mat4 mat = getObjectSkinnedTransform(); mat = modelview_matrix * mat; @@ -99,17 +99,17 @@ void main() vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; #endif -#if HAS_SPECULAR_MAP +#ifdef HAS_SPECULAR_MAP vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; #endif -#if HAS_SKIN +#ifdef HAS_SKIN vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz); -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); vec3 b = cross(n, t)*tangent.w; @@ -121,7 +121,7 @@ vary_normal = n; #endif //HAS_NORMAL_MAP #else //HAS_SKIN vec3 n = normalize(normal_matrix * normal); -#if HAS_NORMAL_MAP +#ifdef HAS_NORMAL_MAP vec3 t = normalize(normal_matrix * tangent.xyz); vec3 b = cross(n,t)*tangent.w; //vec3 t = cross(b,n) * binormal.w; @@ -137,7 +137,7 @@ vary_normal = n; vertex_color = diffuse_color; #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) -#if !HAS_SKIN +#if !defined(HAS_SKIN) vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; #endif #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index bd187ed5fc..07a24698a9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -71,15 +71,7 @@ vec3 getNorm(vec2 pos_screen); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 fullbrightAtmosTransportFrag(vec3 l, vec3 additive, vec3 atten); -#if defined(VERT_ATMOSPHERICS) -vec3 getPositionEye(); -vec3 getSunlitColor(); -vec3 getAmblitColor(); -vec3 getAdditiveColor(); -vec3 getAtmosAttenuation(); -#else void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); -#endif vec3 scaleSoftClip(vec3 l); vec3 fullbrightScaleSoftClip(vec3 l); @@ -114,14 +106,7 @@ void main() vec3 additive; vec3 atten; -#if defined(VERT_ATMOSPHERICS) - sunlit = getSunlitColor(); - amblit = getAmblitColor(); - additive = getAdditiveColor(); - atten = getAtmosAttenuation(); -#else calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); -#endif float ambient = min(abs(da), 1.0); ambient *= 0.5; diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 628f73da59..be5e3538a7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -167,8 +167,6 @@ void main() vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); -color.rgb = max(fb.rgb, refcol.rgb); - frag_data[0] = vec4(color.rgb, 1); // diffuse frag_data[1] = vec4(0); // speccolor, spec frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), 0.05, 0);// normalxy, 0, 0 |