From eda11a25a465dd87b187f63da661f2ce02925deb Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 11 Jan 2013 06:37:21 -0500 Subject: Initial (largely complete) gamma correct rendering implementation. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index dd87ddb330..ef04ef5ce6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -59,6 +59,7 @@ void main() vec4 pos = vec4(vary_position, 1.0); vec4 diff= diffuseLookup(vary_texcoord0.xy); + diff.rgb = pow(diff.rgb, vec3(2.2)); vec4 col = vec4(vary_ambient + vary_directional.rgb, vertex_color.a); vec4 color = diff * col; -- cgit v1.2.3 From c107afcb1ed02266d6f63910338c6095fcad9e23 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 26 Mar 2013 16:23:49 -0500 Subject: NORSPEC-57, NORSPEC-58 Remove sRGB and gamma correction from shaders to remove banding and not break all shiny objects. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ef04ef5ce6..dd87ddb330 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -59,7 +59,6 @@ void main() vec4 pos = vec4(vary_position, 1.0); vec4 diff= diffuseLookup(vary_texcoord0.xy); - diff.rgb = pow(diff.rgb, vec3(2.2)); vec4 col = vec4(vary_ambient + vary_directional.rgb, vertex_color.a); vec4 color = diff * col; -- cgit v1.2.3 From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 29 Mar 2013 07:50:08 -0700 Subject: Update Mac and Windows breakpad builds to latest --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl old mode 100644 new mode 100755 -- cgit v1.2.3 From c2df68743d53a9525f67cbec14637db9d56dd9fe Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 8 Apr 2013 23:02:57 -0400 Subject: First pass of per-pixel lit alpha blended objects. --- .../shaders/class1/deferred/alphaF.glsl | 57 +++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index dd87ddb330..abf8da051c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -49,8 +49,53 @@ VARYING vec3 vary_pointlight_col; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +VARYING vec3 vary_norm; uniform mat4 inv_proj; +uniform vec4 light_position[8]; +uniform vec3 light_direction[8]; +uniform vec3 light_attenuation[8]; +uniform vec3 light_diffuse[8]; + + +uniform float shadow_offset; + +float calcDirectionalLight(vec3 n, vec3 l) +{ + float a = pow(max(dot(n,l),0.0), 0.6); + return a; +} + +float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +{ + //get light vector + vec3 lv = lp.xyz-v; + + //get distance + float d = dot(lv,lv); + + float da = 0.0; + + if (d > 0.0 && la > 0.0 && fa > 0.0) + { + //normalize light vector + lv = normalize(lv); + + //distance attenuation + float dist2 = d/la; + da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_pointlight); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + + //angular attenuation + da *= max(pow(dot(n, lv), 0.6), 0.0); + } + + return da; +} + void main() { vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; @@ -60,14 +105,22 @@ void main() vec4 diff= diffuseLookup(vary_texcoord0.xy); - vec4 col = vec4(vary_ambient + vary_directional.rgb, vertex_color.a); + vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; + + vec4 col = vec4(vary_ambient + dlight, vertex_color.a); vec4 color = diff * col; color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); + vec3 light_col = vec3(0,0,0); - color.rgb += diff.rgb * vary_pointlight_col.rgb; + for (int i = 2; i < 8; i++) + { + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + } + + color.rgb += vary_pointlight_col * light_col; frag_color = color; } -- cgit v1.2.3 From 27fbf5efc9192813e5109443c60bfc26f99716ee Mon Sep 17 00:00:00 2001 From: Geenz Date: Tue, 9 Apr 2013 11:46:52 -0400 Subject: Re-added RGB10_A2 normal buffer, this time encoded with a sphere map transform so we can store the environment intensity in the blue channel. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index abf8da051c..4ef69824a1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -62,7 +62,7 @@ uniform float shadow_offset; float calcDirectionalLight(vec3 n, vec3 l) { - float a = pow(max(dot(n,l),0.0), 0.6); + float a = pow(max(dot(n,l),0.0), 0.7); return a; } @@ -90,7 +90,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= spot*spot; // GL_SPOT_EXPONENT=2 //angular attenuation - da *= max(pow(dot(n, lv), 0.6), 0.0); + da *= max(pow(dot(n, lv), 0.7), 0.0); } return da; @@ -120,7 +120,7 @@ void main() light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); } - color.rgb += vary_pointlight_col * light_col; + color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; } -- cgit v1.2.3 From cfc375777871ec3d04b9969793379d0cd78a012e Mon Sep 17 00:00:00 2001 From: Geenz Date: Thu, 11 Apr 2013 14:57:11 -0400 Subject: First pass on alpha blended materials --- .../shaders/class1/deferred/alphaF.glsl | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 4ef69824a1..55dda06b46 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -25,6 +25,10 @@ #extension GL_ARB_texture_rectangle : enable +#define INDEXED 1 +#define NON_INDEXED 2 +#define NON_INDEXED_NO_COLOR 3 + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -33,7 +37,13 @@ out vec4 frag_color; uniform sampler2DRect depthMap; +#if INDEX_MODE != INDEXED +uniform sampler2D diffuseMap; +#endif + +#if INDEX_MODE == INDEXED vec4 diffuseLookup(vec2 texcoord); +#endif uniform vec2 screen_res; @@ -46,7 +56,10 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +#if INDEX_MODE != NON_INDEXED_NO_COLOR VARYING vec4 vertex_color; +#endif + VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; @@ -103,11 +116,21 @@ void main() vec4 pos = vec4(vary_position, 1.0); - vec4 diff= diffuseLookup(vary_texcoord0.xy); +#if INDEX_MODE == INDEXED + vec4 diff = diffuseLookup(vary_texcoord0.xy); +#else + vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); +#endif + +#if INDEX_MODE == NON_INDEXED_NO_COLOR + float vertex_color_alpha = 1.0; +#else + float vertex_color_alpha = vertex_color.a; +#endif vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; - vec4 col = vec4(vary_ambient + dlight, vertex_color.a); + vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); vec4 color = diff * col; color.rgb = atmosLighting(color.rgb); -- cgit v1.2.3 From 19430bfce05748c363bb83c7e78e605ee6af3b14 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 11 Apr 2013 11:57:50 -0700 Subject: NORSPEC-98 fix? for mac shader compiler crasher --- .../shaders/class1/deferred/alphaF.glsl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 4ef69824a1..d6baec0ee0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -105,7 +105,10 @@ void main() vec4 diff= diffuseLookup(vary_texcoord0.xy); - vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; + vec3 n = vary_norm; + vec3 l = light_position[0].xyz; + vec3 dlight = calcDirectionalLight(n, l); + dlight = dlight * vary_directional.rgb * vary_pointlight_col; vec4 col = vec4(vary_ambient + dlight, vertex_color.a); vec4 color = diff * col; @@ -115,11 +118,17 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); - for (int i = 2; i < 8; i++) - { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - } - +#define LIGHT_LOOP(i) \ + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) + color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; -- cgit v1.2.3 From 7d623abfc3c7f6ef99ae3189a592211f4bf696db Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Thu, 11 Apr 2013 20:16:11 -0700 Subject: NORSPEC-98 redux...hopefully fix mac AND linux at the same time --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d6baec0ee0..eff94b143a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -118,7 +118,8 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); -#define LIGHT_LOOP(i) \ +#if MAC_GEFORCE_HACK + #define LIGHT_LOOP(i) \ light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) @@ -128,7 +129,12 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) - +#else + for (int i = 2; i < 8; i++) + { + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + } +#endif color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; -- cgit v1.2.3 From 6257a8394c23b518febdf5ec9c9ecbdce224e046 Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 15 Apr 2013 01:35:21 -0400 Subject: Normal mapped alpha support. Specular and environment map support needs a bit of extra work (in progress). --- .../shaders/class1/deferred/alphaF.glsl | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 55dda06b46..8fb1d6f7b3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -55,14 +55,14 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec2 vary_texcoord0; +VARYING vec3 vary_norm; +VARYING mat3 vary_rotation; #if INDEX_MODE != NON_INDEXED_NO_COLOR VARYING vec4 vertex_color; #endif -VARYING vec2 vary_texcoord0; - -VARYING vec3 vary_norm; uniform mat4 inv_proj; uniform vec4 light_position[8]; @@ -70,13 +70,21 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +uniform sampler2D bumpMap; +uniform samplerCube environmentMap; +uniform mat3 env_mat; + +uniform vec4 specular_color; + uniform float shadow_offset; -float calcDirectionalLight(vec3 n, vec3 l) +vec2 calcDirectionalLight(vec3 n, vec3 l) { - float a = pow(max(dot(n,l),0.0), 0.7); - return a; + vec3 refl = normalize(reflect(vary_position.xyz, n.xyz)); + float a = pow(max(dot(n,l),0.0), 0.7); + refl.x = pow(pow(max(dot(refl, l), 0.0), specular_color.w * 128), 0.6); + return vec2(a, refl.x); } float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) @@ -127,8 +135,15 @@ void main() #else float vertex_color_alpha = vertex_color.a; #endif - - vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; + + vec3 normal = vary_norm; + normal = texture2D(bumpMap, vary_texcoord0.xy).xyz * 2 - 1; + normal = vec3(dot(normal.xyz, vary_rotation[0]), + dot(normal.xyz, vary_rotation[1]), + dot(normal.xyz, vary_rotation[2])); + + vec2 slight = calcDirectionalLight(normal, light_position[0].xyz); + vec3 dlight = slight.x * vary_directional.rgb * vary_pointlight_col; vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); vec4 color = diff * col; @@ -140,9 +155,11 @@ void main() for (int i = 2; i < 8; i++) { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); } - + + vec3 n = normalize(reflect(vary_position.xyz, normal.xyz)); + n = vec3(dot(n, light_position[0].xyz)); color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; -- cgit v1.2.3 From 39544a3b06e3221602444eb81c7df8c1030c6bb5 Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 15 Apr 2013 02:29:03 -0400 Subject: Hooked up normal and specular texture coordinates. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 8fb1d6f7b3..eb0c546af7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -56,6 +56,8 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; VARYING vec3 vary_norm; VARYING mat3 vary_rotation; @@ -137,7 +139,7 @@ void main() #endif vec3 normal = vary_norm; - normal = texture2D(bumpMap, vary_texcoord0.xy).xyz * 2 - 1; + normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; normal = vec3(dot(normal.xyz, vary_rotation[0]), dot(normal.xyz, vary_rotation[1]), dot(normal.xyz, vary_rotation[2])); -- cgit v1.2.3 From a9f3e6d95c03a469ac6b88e8d0ed4034cb978d88 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 16 Apr 2013 12:50:45 -0700 Subject: See if we can run with no ifdefs in alpha shaders on all platforms --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index eff94b143a..4942abbadf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -60,13 +60,13 @@ uniform vec3 light_diffuse[8]; uniform float shadow_offset; -float calcDirectionalLight(vec3 n, vec3 l) +vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = pow(max(dot(n,l),0.0), 0.7); - return a; + return vec3(a,a,a); } -float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -93,7 +93,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(pow(dot(n, lv), 0.7), 0.0); } - return da; + return vec3(da,da,da); } void main() @@ -118,7 +118,6 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); -#if MAC_GEFORCE_HACK #define LIGHT_LOOP(i) \ light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); @@ -129,12 +128,7 @@ void main() LIGHT_LOOP(5) LIGHT_LOOP(6) LIGHT_LOOP(7) -#else - for (int i = 2; i < 8; i++) - { - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - } -#endif + color.rgb += diff.rgb * vary_pointlight_col * light_col; frag_color = color; -- cgit v1.2.3 From 119c0a35f15d0f82ebf99507300357609769520b Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 16 Apr 2013 18:07:25 -0700 Subject: NORSPEC-59 fix? for mac crasher --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index fc628e60cf..8c9fe95590 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -152,10 +152,10 @@ void main() color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); - vec3 light_col = vec3(0,0,0); + col = vec3(0,0,0); #define LIGHT_LOOP(i) \ - light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -165,7 +165,7 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * vary_pointlight_col * light_col; + color.rgb += diff.rgb * vary_pointlight_col * col; frag_color = color; } -- cgit v1.2.3 From e40bcc4e16c8baeb3945e89c5d035d89416896e3 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 17 Apr 2013 09:05:40 -0700 Subject: NORSPEC-59 and NORSPEC-133 work-around crash with RenderDebugGL on and fix breakage in shaders from Mac changes --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 8c9fe95590..e8cbf318a1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -136,8 +136,7 @@ void main() float vertex_color_alpha = vertex_color.a; #endif - vec3 normal = vary_norm; - normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; + vec3 normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; normal = vec3(dot(normal.xyz, vary_rotation[0]), dot(normal.xyz, vary_rotation[1]), dot(normal.xyz, vary_rotation[2])); @@ -152,10 +151,10 @@ void main() color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); - col = vec3(0,0,0); + col = vec4(0,0,0,0); #define LIGHT_LOOP(i) \ - col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -165,7 +164,7 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * vary_pointlight_col * col; + color.rgb += diff.rgb * vary_pointlight_col * col.rgb; frag_color = color; } -- cgit v1.2.3 From bb5bf632c6c3dea22865a86dc8c13f5de9ce06f0 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 17 Apr 2013 15:53:09 -0400 Subject: First pass of gamma correction reimplementation. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 00717cd6a9..a25d0f2773 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -129,7 +129,7 @@ void main() #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - + diff.rgb = pow(diff.rgb, vec3(2.2)); #if INDEX_MODE == NON_INDEXED_NO_COLOR float vertex_color_alpha = 1.0; #else @@ -173,7 +173,6 @@ void main() #endif color.rgb += diff.rgb * vary_pointlight_col * light_col; - frag_color = color; } -- cgit v1.2.3 From 8ed49bb828dc785684bd2c9764e34aa53d077c93 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 17 Apr 2013 16:50:03 -0700 Subject: Simplify ifdefs in alpha shaders for Mac --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e8cbf318a1..057c0a1ec9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -37,11 +37,11 @@ out vec4 frag_color; uniform sampler2DRect depthMap; -#if INDEX_MODE != INDEXED +#if !INDEX_MODE || INDEX_MODE_NO_COLOR uniform sampler2D diffuseMap; #endif -#if INDEX_MODE == INDEXED +#if INDEX_MODE vec4 diffuseLookup(vec2 texcoord); #endif @@ -61,7 +61,7 @@ VARYING vec2 vary_texcoord2; VARYING vec3 vary_norm; VARYING mat3 vary_rotation; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#if !INDEX_MODE_NO_COLOR VARYING vec4 vertex_color; #endif @@ -124,13 +124,13 @@ void main() vec4 pos = vec4(vary_position, 1.0); -#if INDEX_MODE == INDEXED +#if INDEX_MODE vec4 diff= diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif -#if INDEX_MODE == NON_INDEXED_NO_COLOR +#if INDEX_MODE_NO_COLOR float vertex_color_alpha = 1.0; #else float vertex_color_alpha = vertex_color.a; -- cgit v1.2.3 From f76b3d7e7d778fec7f082c46491197cac9867a50 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Thu, 18 Apr 2013 05:30:44 -0700 Subject: NORSPEC-125 fiddle with ifdefs in alpha shaders again in hopes of linking on mobile geforce macs --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 057c0a1ec9..713aae9187 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -25,10 +25,6 @@ #extension GL_ARB_texture_rectangle : enable -#define INDEXED 1 -#define NON_INDEXED 2 -#define NON_INDEXED_NO_COLOR 3 - #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; #else @@ -37,11 +33,13 @@ out vec4 frag_color; uniform sampler2DRect depthMap; -#if !INDEX_MODE || INDEX_MODE_NO_COLOR +#ifndef INDEX_MODE +#ifndef INDEX_MODE_USE_COLOR uniform sampler2D diffuseMap; #endif +#endif -#if INDEX_MODE +#ifdef INDEX_MODE vec4 diffuseLookup(vec2 texcoord); #endif @@ -61,7 +59,7 @@ VARYING vec2 vary_texcoord2; VARYING vec3 vary_norm; VARYING mat3 vary_rotation; -#if !INDEX_MODE_NO_COLOR +#ifdef INDEX_MODE_USE_COLOR VARYING vec4 vertex_color; #endif @@ -124,16 +122,16 @@ void main() vec4 pos = vec4(vary_position, 1.0); -#if INDEX_MODE +#ifdef INDEX_MODE vec4 diff= diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif -#if INDEX_MODE_NO_COLOR - float vertex_color_alpha = 1.0; -#else +#ifdef INDEX_MODE_USE_COLOR float vertex_color_alpha = vertex_color.a; +#else + float vertex_color_alpha = 1.0; #endif vec3 normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; -- cgit v1.2.3 From 1a5bba865c096473164b47a56dbb0ba1e055613d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 18 Apr 2013 18:00:56 -0500 Subject: NORSPEC-90 Cleanup of alpha pool hook ups for materials. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e8cbf318a1..f63e2f7198 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -72,7 +72,6 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -uniform sampler2D bumpMap; uniform samplerCube environmentMap; uniform mat3 env_mat; @@ -125,7 +124,7 @@ void main() vec4 pos = vec4(vary_position, 1.0); #if INDEX_MODE == INDEXED - vec4 diff= diffuseLookup(vary_texcoord0.xy); + vec4 diff = diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif @@ -136,7 +135,7 @@ void main() float vertex_color_alpha = vertex_color.a; #endif - vec3 normal = texture2D(bumpMap, vary_texcoord1.xy).xyz * 2 - 1; + vec3 normal = vec3(0,0,1); normal = vec3(dot(normal.xyz, vary_rotation[0]), dot(normal.xyz, vary_rotation[1]), dot(normal.xyz, vary_rotation[2])); -- cgit v1.2.3 From 28fcb3d54987a056b3dfe4d1d01a75339f8e6689 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 18 Apr 2013 18:31:49 -0500 Subject: NORSPEC-90 Remove unused state from alphaF/alphaV --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f63e2f7198..94ce8a658a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -56,8 +56,6 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; VARYING vec3 vary_norm; VARYING mat3 vary_rotation; @@ -135,11 +133,8 @@ void main() float vertex_color_alpha = vertex_color.a; #endif - vec3 normal = vec3(0,0,1); - normal = vec3(dot(normal.xyz, vary_rotation[0]), - dot(normal.xyz, vary_rotation[1]), - dot(normal.xyz, vary_rotation[2])); - + vec3 normal = vary_norm; + vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); dlight = dlight * vary_directional.rgb * vary_pointlight_col; -- cgit v1.2.3 From 509c35d5bae7dbd938198c3e038011932693ff36 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 18 Apr 2013 19:21:08 -0500 Subject: NORSPEC-90 Cleanup avatar alpha shaders --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 94ce8a658a..495ed33e9e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,16 +35,10 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect depthMap; - #if INDEX_MODE != INDEXED uniform sampler2D diffuseMap; #endif -#if INDEX_MODE == INDEXED -vec4 diffuseLookup(vec2 texcoord); -#endif - uniform vec2 screen_res; vec3 atmosLighting(vec3 light); @@ -57,27 +51,16 @@ VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -VARYING mat3 vary_rotation; #if INDEX_MODE != NON_INDEXED_NO_COLOR VARYING vec4 vertex_color; #endif -uniform mat4 inv_proj; - uniform vec4 light_position[8]; uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -uniform samplerCube environmentMap; -uniform mat3 env_mat; - -uniform vec4 specular_color; - - -uniform float shadow_offset; - vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = pow(max(dot(n,l),0.0), 0.7); -- cgit v1.2.3 From b145007941c0dd9d30fadc834426e22e5a113edf Mon Sep 17 00:00:00 2001 From: Geenz Date: Thu, 18 Apr 2013 23:18:21 -0400 Subject: Fix for alpha blended objects becoming too bright when gamma correction is applied. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 97767964f0..d175d2b518 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -109,7 +109,7 @@ void main() #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - + diff.rgb = pow(diff.rgb, vec3(2.2)); #if INDEX_MODE == NON_INDEXED_NO_COLOR float vertex_color_alpha = 1.0; #else -- cgit v1.2.3 From c5410a5d22ac5234226ab8f67144a753ef2d3019 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Fri, 19 Apr 2013 11:53:58 -0700 Subject: Shader changes for Mac compat --- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 17ac5a276d..ac8393edf8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,7 +35,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if INDEX_MODE != INDEXED +#if (INDEX_MODE != INDEXED) uniform sampler2D diffuseMap; #endif @@ -52,7 +52,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#if (INDEX_MODE != NON_INDEXED_NO_COLOR) VARYING vec4 vertex_color; #endif @@ -104,20 +104,20 @@ void main() vec4 pos = vec4(vary_position, 1.0); -#if INDEX_MODE == INDEXED - vec4 diff= diffuseLookup(vary_texcoord0.xy); +#if (INDEX_MODE == INDEXED) + vec4 diff = diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif diff.rgb = pow(diff.rgb, vec3(2.2)); -#if INDEX_MODE == NON_INDEXED_NO_COLOR +#if (INDEX_MODE == NON_INDEXED_NO_COLOR) float vertex_color_alpha = 1.0; #else float vertex_color_alpha = vertex_color.a; #endif vec3 normal = vary_norm; - + vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); dlight = dlight * vary_directional.rgb * vary_pointlight_col; -- cgit v1.2.3 From 7c0bea5bb4fe60c009a7f262297990f4792b9ae4 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 19 Apr 2013 13:08:57 -0700 Subject: Rework ifdefing and fix windows shader compiler warnings from materialF --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ac8393edf8..7c58749929 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,7 +35,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if (INDEX_MODE != INDEXED) +#if USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif @@ -52,7 +52,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -#if (INDEX_MODE != NON_INDEXED_NO_COLOR) +#if USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif @@ -104,16 +104,18 @@ void main() vec4 pos = vec4(vary_position, 1.0); -#if (INDEX_MODE == INDEXED) +#if USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif + diff.rgb = pow(diff.rgb, vec3(2.2)); -#if (INDEX_MODE == NON_INDEXED_NO_COLOR) - float vertex_color_alpha = 1.0; + +#if USE_VERTEX_COLOR + float vertex_color_alpha = vertex_color.a; #else - float vertex_color_alpha = vertex_color.a; + float vertex_color_alpha = 1.0; #endif vec3 normal = vary_norm; -- cgit v1.2.3 From 8137a3c26f950127d4b37470d1d68c7b43d5c6e4 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Fri, 19 Apr 2013 13:52:10 -0700 Subject: Change #ifs to #ifdefs for mac compiler --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 7c58749929..a3be4bb0c3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,7 +35,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if USE_DIFFUSE_TEX +#ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif @@ -52,7 +52,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -#if USE_VERTEX_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif @@ -104,7 +104,7 @@ void main() vec4 pos = vec4(vary_position, 1.0); -#if USE_INDEXED_TEX +#ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); @@ -112,7 +112,7 @@ void main() diff.rgb = pow(diff.rgb, vec3(2.2)); -#if USE_VERTEX_COLOR +#ifdef USE_VERTEX_COLOR float vertex_color_alpha = vertex_color.a; #else float vertex_color_alpha = 1.0; -- cgit v1.2.3 From 38b222e76bc5fc4dd3f05787a45f38087b4af5cc Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 22 Apr 2013 09:56:08 -0700 Subject: Fix regression in alpha shader on non-Mac from recent changes --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index a3be4bb0c3..ec04f856fb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -106,11 +106,13 @@ void main() #ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); -#else +#endif + +#ifdef USE_DIFFUSE_TEX vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - diff.rgb = pow(diff.rgb, vec3(2.2)); + diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); #ifdef USE_VERTEX_COLOR float vertex_color_alpha = vertex_color.a; -- cgit v1.2.3 From b5868bda0d441823fa9783a1c712c258f4cecfa5 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Mon, 22 Apr 2013 14:12:34 -0700 Subject: Fix avatar alpha shader define setup --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ec04f856fb..9f1fdb4385 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -106,9 +106,7 @@ void main() #ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); -#endif - -#ifdef USE_DIFFUSE_TEX +#else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif -- cgit v1.2.3 From 79318043218a9ec6cb6e52eca936487177554903 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Wed, 24 Apr 2013 06:24:21 -0700 Subject: NORSPEC-59 NORSPEC-125 make materials and alpha shaders work on Mac laptops with nV mobile graphics cards --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d175d2b518..9f1fdb4385 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,7 +35,7 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -#if INDEX_MODE != INDEXED +#ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif @@ -52,7 +52,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif @@ -104,16 +104,18 @@ void main() vec4 pos = vec4(vary_position, 1.0); -#if INDEX_MODE == INDEXED +#ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - diff.rgb = pow(diff.rgb, vec3(2.2)); -#if INDEX_MODE == NON_INDEXED_NO_COLOR - float vertex_color_alpha = 1.0; + + diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + +#ifdef USE_VERTEX_COLOR + float vertex_color_alpha = vertex_color.a; #else - float vertex_color_alpha = vertex_color.a; + float vertex_color_alpha = 1.0; #endif vec3 normal = vary_norm; -- cgit v1.2.3 From 2a96a5f3eae9c0cf5a239a6734a8a656a71c2cb7 Mon Sep 17 00:00:00 2001 From: Geenz Date: Mon, 29 Apr 2013 14:15:59 -0400 Subject: Fix any missing color space conversions where appropriate, tweak the sun's intensity to match pre-gamma correction results, and also mask spotlight specular by the projected texture. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 9f1fdb4385..fec79ebf62 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -121,7 +121,7 @@ void main() vec3 normal = vary_norm; vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(normal, l); + vec3 dlight = calcDirectionalLight(normal, l) * 2.6; dlight = dlight * vary_directional.rgb * vary_pointlight_col; vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); -- cgit v1.2.3 From ad9e30817411b373baf73e63653ad6d10661e35f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 29 Apr 2013 15:01:48 -0500 Subject: NORSPEC-153 Workaround for AMD driver bug that doesn't like '\' on #define's --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index fec79ebf62..737c658126 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -132,8 +132,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); col = vec4(0,0,0,0); - #define LIGHT_LOOP(i) \ - col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) -- cgit v1.2.3 From b06ec66a5d11628905da256e084d0036f39ba529 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 30 Apr 2013 14:49:53 -0500 Subject: MATBUG-78 Fix for alpha lighting distance attenuation not matching opaque distance attenuation --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 737c658126..e2fe4a1e9e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -85,6 +85,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float //distance attenuation float dist2 = d/la; da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + da = pow(da, 2.2) * 2.2; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); -- cgit v1.2.3 From d659b29f6ca180cac774e4576bba9da791510633 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 30 Apr 2013 13:44:35 -0700 Subject: Fix vwr-dev-mat merge bugs in llpanelface (missing Oz fix) and XML --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 9f1fdb4385..737c658126 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -121,7 +121,7 @@ void main() vec3 normal = vary_norm; vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(normal, l); + vec3 dlight = calcDirectionalLight(normal, l) * 2.6; dlight = dlight * vary_directional.rgb * vary_pointlight_col; vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); @@ -132,8 +132,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); col = vec4(0,0,0,0); - #define LIGHT_LOOP(i) \ - col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) -- cgit v1.2.3 From df6bb7ace2f2ca26f5fabf8305e190e7d0066cf1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 6 May 2013 11:11:49 -0500 Subject: MATBUG-78 Fix for alpha lighting falloff not matching for sunlight when shadows are enabled. --- .../shaders/class1/deferred/alphaF.glsl | 111 ++++++++++++++++++++- 1 file changed, 109 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e2fe4a1e9e..50b43f6a8d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,12 +35,24 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +#if HAS_SHADOW +uniform sampler2DShadow shadowMap0; +uniform sampler2DShadow shadowMap1; +uniform sampler2DShadow shadowMap2; +uniform sampler2DShadow shadowMap3; + +uniform vec2 shadow_res; + +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform float shadow_bias; + +#endif + #ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif -uniform vec2 screen_res; - vec3 atmosLighting(vec3 light); vec3 scaleSoftClip(vec3 light); @@ -61,6 +73,8 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +uniform vec2 screen_res; + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -98,6 +112,27 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float return vec3(da,da,da); } +#if HAS_SHADOW +float pcfShadow(sampler2DShadow shadowMap, vec4 stc) +{ + stc.xyz /= stc.w; + stc.z += shadow_bias; + + stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here + + float cs = shadow2D(shadowMap, stc.xyz).x; + float shadow = cs; + + shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; + + return shadow*0.2; +} +#endif + + void main() { vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; @@ -105,6 +140,73 @@ void main() vec4 pos = vec4(vary_position, 1.0); + +#if HAS_SHADOW + float shadow = 0.0; + vec4 spos = pos; + + if (spos.z > -shadow_clip.w) + { + vec4 lpos; + + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + vec4 transition_domain = near_split-far_split; + float weight = 0.0; + + if (spos.z < near_split.z) + { + lpos = shadow_matrix[3]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap3, lpos)*w; + weight += w; + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + + if (spos.z < near_split.y && spos.z > far_split.z) + { + lpos = shadow_matrix[2]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; + w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap2, lpos)*w; + weight += w; + } + + if (spos.z < near_split.x && spos.z > far_split.y) + { + lpos = shadow_matrix[1]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; + w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; + shadow += pcfShadow(shadowMap1, lpos)*w; + weight += w; + } + + if (spos.z > far_split.x) + { + lpos = shadow_matrix[0]*spos; + + float w = 1.0; + w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; + + shadow += pcfShadow(shadowMap0, lpos)*w; + weight += w; + } + + + shadow /= weight; + } + else + { + shadow = 1.0; + } +#endif + #ifdef USE_INDEXED_TEX vec4 diff = diffuseLookup(vary_texcoord0.xy); #else @@ -125,7 +227,12 @@ void main() vec3 dlight = calcDirectionalLight(normal, l) * 2.6; dlight = dlight * vary_directional.rgb * vary_pointlight_col; +#if HAS_SHADOW + vec4 col = vec4(vary_ambient + dlight * shadow, vertex_color_alpha); +#else vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); +#endif + vec4 color = diff * col; color.rgb = atmosLighting(color.rgb); -- cgit v1.2.3 From f3036451564a00da5af4935ca59d22103ba46066 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 3 Jun 2013 17:10:37 -0500 Subject: NORSPEC-195 Fix for incorrect alpha blending with deferred rendering enabled. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 50b43f6a8d..77a53a71aa 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -252,6 +252,8 @@ void main() color.rgb += diff.rgb * vary_pointlight_col * col.rgb; + color.rgb = pow(color.rgb, vec3(1.0/2.2)); + frag_color = color; } -- cgit v1.2.3 From 8d67ad3d86cbc57631c4b56926ff9a0ea5b82897 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 13 Jun 2013 18:13:30 -0500 Subject: NORSPEC-261 No more magic numbers, parity between forward and deferred rendering WRT to windlight and legacy shininess. Reviewed by Graham (a little bit). --- .../shaders/class1/deferred/alphaF.glsl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 77a53a71aa..0899caa2af 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -78,6 +78,7 @@ uniform vec2 screen_res; vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); + a = pow(a, 1.0/1.3); return vec3(a,a,a); } @@ -87,7 +88,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float vec3 lv = lp.xyz-v; //get distance - float d = dot(lv,lv); + float d = length(lv); float da = 0.0; @@ -97,9 +98,11 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float lv = normalize(lv); //distance attenuation - float dist2 = d/la; - da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); - da = pow(da, 2.2) * 2.2; + float dist = d/la; + da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + da *= da; + da *= 1.4; + // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); @@ -212,6 +215,7 @@ void main() #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif + vec4 gamma_diff = diff; diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); @@ -224,7 +228,7 @@ void main() vec3 normal = vary_norm; vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(normal, l) * 2.6; + vec3 dlight = calcDirectionalLight(normal, l); dlight = dlight * vary_directional.rgb * vary_pointlight_col; #if HAS_SHADOW @@ -233,13 +237,16 @@ void main() vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); #endif - vec4 color = diff * col; + vec4 color = gamma_diff * col; color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); + + color.rgb = pow(color.rgb, vec3(2.2)); col = vec4(0,0,0,0); + #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) @@ -250,7 +257,7 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * vary_pointlight_col * col.rgb; + color.rgb += diff.rgb * pow(vary_pointlight_col, vec3(2.2)) * col.rgb; color.rgb = pow(color.rgb, vec3(1.0/2.2)); -- cgit v1.2.3 From 280a9d9827e4e5e0e1408cc8f9c20ef792a6c714 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 25 Jun 2013 18:02:08 -0500 Subject: MATBUG-78 Fix for alpha lighting falloff not matching opaque lighting falloff (again). --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 0899caa2af..143af0576c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -101,7 +101,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float float dist = d/la; da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); da *= da; - da *= 1.4; + da *= 2.0; // spotlight coefficient. -- cgit v1.2.3 From 7df863265f6f536aeae84dceab9140fb4465213c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 28 Jun 2013 13:32:01 -0500 Subject: NORSPEC-290 Shader optimization WIP -- remove a couple normalizes, pows, and divides from various lighting functions. --- .../shaders/class1/deferred/alphaF.glsl | 51 ++++++++++++---------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 143af0576c..af3f362208 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -61,6 +61,7 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec3 vary_pointlight_col_linear; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; @@ -82,7 +83,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) return vec3(a,a,a); } -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -92,14 +93,14 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float float da = 0.0; - if (d > 0.0 && la > 0.0 && fa > 0.0) +// if (d > 0.0 && la > 0.0 && fa > 0.0) { //normalize light vector - lv = normalize(lv); + lv /= d; //distance attenuation - float dist = d/la; - da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + float dist = d*la; + da = clamp(1.0-(dist+fa-1.0)/fa, 0.0, 1.0); da *= da; da *= 2.0; @@ -112,7 +113,7 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float da *= max(dot(n, lv), 0.0); } - return vec3(da,da,da); + return da; } #if HAS_SHADOW @@ -138,6 +139,25 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) void main() { +#ifdef USE_INDEXED_TEX + vec4 diff = diffuseLookup(vary_texcoord0.xy); +#else + vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); +#endif + +#ifdef USE_VERTEX_COLOR + float vertex_color_alpha = vertex_color.a; +#else + float vertex_color_alpha = 1.0; +#endif + + float alpha = vertex_color_alpha*diff.a; + + vec4 gamma_diff = diff; + + diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + + vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; frag *= screen_res; @@ -210,21 +230,6 @@ void main() } #endif -#ifdef USE_INDEXED_TEX - vec4 diff = diffuseLookup(vary_texcoord0.xy); -#else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); -#endif - vec4 gamma_diff = diff; - - diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); - -#ifdef USE_VERTEX_COLOR - float vertex_color_alpha = vertex_color.a; -#else - float vertex_color_alpha = 1.0; -#endif - vec3 normal = vary_norm; vec3 l = light_position[0].xyz; @@ -243,6 +248,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); + //convert to linear space color.rgb = pow(color.rgb, vec3(2.2)); col = vec4(0,0,0,0); @@ -257,8 +263,9 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * pow(vary_pointlight_col, vec3(2.2)) * col.rgb; + color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; + //convert to gamma space color.rgb = pow(color.rgb, vec3(1.0/2.2)); frag_color = color; -- cgit v1.2.3 From d6d2f74fbbf22ba70166a97e15b6c3b39e42ac4d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 1 Jul 2013 16:27:20 -0500 Subject: NORSPEC-290 Shader optimization WIP -- compatibility pass with OpenGL 3.3, slight cleanup. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b666b7b0d9..4b428cb904 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -93,7 +93,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa float da = 0.0; -// if (d > 0.0 && la > 0.0 && fa > 0.0) + //if (d > 0.0 && la > 0.0 && fa > 0.0) { //normalize light vector lv /= d; @@ -230,7 +230,6 @@ void main() } #endif - vec4 gamma_diff = diff; vec3 normal = vary_norm; vec3 l = light_position[0].xyz; -- cgit v1.2.3 From 930de04f51212195a2c7a877d235d4106f4d37e2 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Jul 2013 18:02:28 -0500 Subject: NORSPEC-287 Make alpha sRGB correction curves match OpenGL spec. --- .../shaders/class1/deferred/alphaF.glsl | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 143af0576c..e80e4b0fcf 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -135,6 +135,26 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + void main() { @@ -217,7 +237,7 @@ void main() #endif vec4 gamma_diff = diff; - diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + diff.rgb = srgb_to_linear(diff.rgb); #ifdef USE_VERTEX_COLOR float vertex_color_alpha = vertex_color.a; @@ -243,9 +263,8 @@ void main() color.rgb = scaleSoftClip(color.rgb); - color.rgb = pow(color.rgb, vec3(2.2)); + color.rgb = srgb_to_linear(color.rgb); col = vec4(0,0,0,0); - #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); @@ -257,9 +276,9 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * pow(vary_pointlight_col, vec3(2.2)) * col.rgb; + color.rgb += diff.rgb * srgb_to_linear(vary_pointlight_col) * col.rgb; - color.rgb = pow(color.rgb, vec3(1.0/2.2)); + color.rgb = linear_to_srgb(color.rgb); frag_color = color; } -- cgit v1.2.3 From cf3b7bbe4b932b683d0d30c95505f45d16a1d2a7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Jul 2013 12:59:29 -0500 Subject: NORSPEC-298 Fix for inconsistent alpha lighting when diffuse color is not white. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e80e4b0fcf..640e273415 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -61,6 +61,7 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec3 vary_pointlight_col_linear; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; @@ -228,6 +229,7 @@ void main() { shadow = 1.0; } + #endif #ifdef USE_INDEXED_TEX @@ -276,7 +278,7 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * srgb_to_linear(vary_pointlight_col) * col.rgb; + color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; color.rgb = linear_to_srgb(color.rgb); -- cgit v1.2.3 From 94abe75dea90ee91dd044161d8587279b0bfae13 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 08:15:21 -0700 Subject: NORSPEC-315 NORSPEC-316 NORSPEC-312 fix various haze and gamma correction issues, alpha-blend objects still missing haze underwater --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 640e273415..b64852f17b 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -281,7 +281,7 @@ void main() color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; color.rgb = linear_to_srgb(color.rgb); - + //color.rgb = vec3(1,0,1); frag_color = color; } -- cgit v1.2.3 From caefe0e74cf553de41c6c8748dd2ea5ef4d82c06 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 14:28:54 -0700 Subject: NORSPEC-311 fix alpha / opaque lighting diffs --- .../shaders/class1/deferred/alphaF.glsl | 56 +++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b64852f17b..69b0f8f012 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -136,6 +136,52 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif +#if WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) +{ + //normalize view vector + vec3 view = normalize(pos); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + vec3 srgb_to_linear(vec3 cs) { @@ -240,8 +286,9 @@ void main() vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); - + #ifdef USE_VERTEX_COLOR + diff.rgb *= vertex_color.rgb; float vertex_color_alpha = vertex_color.a; #else float vertex_color_alpha = 1.0; @@ -266,6 +313,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); color.rgb = srgb_to_linear(color.rgb); + col = vec4(0,0,0,0); #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); @@ -281,7 +329,11 @@ void main() color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; color.rgb = linear_to_srgb(color.rgb); - //color.rgb = vec3(1,0,1); + +#if WATER_FOG + color = applyWaterFogDeferred(pos.xyz, color); +#endif + frag_color = color; } -- cgit v1.2.3 From 710b529372f4d7da699318c4761963ae9dde9a63 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 16:29:05 -0700 Subject: NORSPEC-311 NORSPEC-312 make mac happy with shader ifdefs for haze/masking --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 69b0f8f012..69b29269c7 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -136,7 +136,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec4 stc) } #endif -#if WATER_FOG +#ifdef WATER_FOG uniform vec4 waterPlane; uniform vec4 waterFogColor; uniform float waterFogDensity; @@ -330,7 +330,7 @@ void main() color.rgb = linear_to_srgb(color.rgb); -#if WATER_FOG +#ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); #endif -- cgit v1.2.3 From 6f62251a3d29ced4193a9a80965f33fe0318d5a0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 22 Jul 2013 10:29:49 -0700 Subject: MATBUG-306 fix alpha knock-on from underwater lightcurve matching --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 69b29269c7..2eef99dea7 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -288,8 +288,7 @@ void main() diff.rgb = srgb_to_linear(diff.rgb); #ifdef USE_VERTEX_COLOR - diff.rgb *= vertex_color.rgb; - float vertex_color_alpha = vertex_color.a; + float vertex_color_alpha = diff.a * vertex_color.a; #else float vertex_color_alpha = 1.0; #endif @@ -306,8 +305,9 @@ void main() vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); #endif - vec4 color = gamma_diff * col; - + vec4 color = col; + color.rgb *= gamma_diff.rgb; + color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); -- cgit v1.2.3 From 96869baaefae1f322bff5114429e7fa73b6d4bf9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 14:28:52 -0700 Subject: NORSPEC-285 NORSPEC-298 alpha vs diff color differences --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 2eef99dea7..c8c23c6ce4 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -79,7 +79,7 @@ uniform vec2 screen_res; vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); - a = pow(a, 1.0/1.3); + //a = pow(a, 1.0/1.3); return vec3(a,a,a); } -- cgit v1.2.3 From 72a0ae58e909b017c07e543bc99adc1db5e89180 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 16:09:58 -0700 Subject: NORSPEC-293 fix sRGB to linear conversion to not scrooge the darks --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index c8c23c6ce4..b928761358 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -189,6 +189,11 @@ vec3 srgb_to_linear(vec3 cs) cl = { { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + vec3 low_range = cs / vec3(12.92); + + if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) + return low_range; + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); } -- cgit v1.2.3 From e290dd3fa175c2a891cc4f4e0c401edb10cedfb4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 04:03:27 -0700 Subject: NORSPEC-311 make post deferred (alpha objects) respect same gamma ramp as deferred (opaque objects) --- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b928761358..e836e9750f 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,6 +35,8 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +uniform float display_gamma; + #if HAS_SHADOW uniform sampler2DShadow shadowMap0; uniform sampler2DShadow shadowMap1; @@ -204,6 +206,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -295,7 +302,7 @@ void main() #ifdef USE_VERTEX_COLOR float vertex_color_alpha = diff.a * vertex_color.a; #else - float vertex_color_alpha = 1.0; + float vertex_color_alpha = diff.a; #endif vec3 normal = vary_norm; @@ -333,7 +340,7 @@ void main() color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; - color.rgb = linear_to_srgb(color.rgb); + color.rgb = pow(color.rgb,vec3(display_gamma)); #ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); -- cgit v1.2.3 From 7e2c4cd91df9f8d696d77e21e58ba9937977ab3d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 08:26:28 -0700 Subject: NORSPEC-314 fix discrepancies between alpha and non-alpha deferred point/spot atten --- .../shaders/class1/deferred/alphaF.glsl | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e836e9750f..ea6d22d9c2 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -85,7 +85,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) return vec3(a,a,a); } -vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; @@ -93,7 +93,9 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float //get distance float d = length(lv); - float da = 0.0; + float da = 1.0; + + vec3 col = vec3(0); if (d > 0.0 && la > 0.0 && fa > 0.0) { @@ -102,20 +104,25 @@ vec3 calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float //distance attenuation float dist = d/la; - da = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - da *= da; - da *= 2.0; - + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 //angular attenuation - da *= max(dot(n, lv), 0.0); + da *= max(dot(n, lv), 0.0); + + float lit = max(da * dist_atten,0.0); + + col = light_col * lit * diffuse; + + // no spec for alpha shader... } - return vec3(da,da,da); + return max(col, vec3(0.0,0.0,0.0)); } #if HAS_SHADOW @@ -321,15 +328,12 @@ void main() color.rgb *= gamma_diff.rgb; color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - - color.rgb = srgb_to_linear(color.rgb); col = vec4(0,0,0,0); - #define LIGHT_LOOP(i) col.rgb += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); - + #define LIGHT_LOOP(i) col.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + LIGHT_LOOP(1) LIGHT_LOOP(2) LIGHT_LOOP(3) @@ -338,8 +342,12 @@ void main() LIGHT_LOOP(6) LIGHT_LOOP(7) - color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; + // keep it linear + // + color.rgb = srgb_to_linear(color.rgb) + col.rgb; + // ramp directly to display gamma as we're POST-deferred + // color.rgb = pow(color.rgb,vec3(display_gamma)); #ifdef WATER_FOG -- cgit v1.2.3 From d6b4124fb96768aad8840490efa31d9b800cb3ea Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 11:21:40 -0700 Subject: NORSPEC-311 WIP move to per-pixel alpha lighting and make spot/point calcs match more closely --- .../shaders/class1/deferred/alphaF.glsl | 285 ++++++++++++++++++--- 1 file changed, 247 insertions(+), 38 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ea6d22d9c2..f4298d2bde 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -36,6 +36,24 @@ out vec4 frag_color; #endif uniform float display_gamma; +uniform vec4 gamma; +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform float haze_horizon; +uniform float haze_density; +uniform float cloud_shadow; +uniform float density_multiplier; +uniform float distance_multiplier; +uniform float max_y; +uniform vec4 glow; +uniform float scene_light_strength; +uniform mat3 env_mat; +uniform mat3 ssao_effect_mat; + +uniform vec3 sun_dir; #if HAS_SHADOW uniform sampler2DShadow shadowMap0; @@ -55,29 +73,26 @@ uniform float shadow_bias; uniform sampler2D diffuseMap; #endif -vec3 atmosLighting(vec3 light); -vec3 scaleSoftClip(vec3 light); - -VARYING vec3 vary_ambient; -VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; -VARYING vec3 vary_pointlight_col; -VARYING vec3 vary_pointlight_col_linear; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; - -#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; -#endif + +vec3 vary_PositionEye; +vec3 vary_SunlitColor; +vec3 vary_AmblitColor; +vec3 vary_AdditiveColor; +vec3 vary_AtmosAttenuation; + +uniform mat4 inv_proj; +uniform vec2 screen_res; uniform vec4 light_position[8]; uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -uniform vec2 screen_res; - vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -191,6 +206,192 @@ vec4 applyWaterFogDeferred(vec3 pos, vec4 color) } #endif +vec3 getSunlitColor() +{ + return vary_SunlitColor; +} +vec3 getAmblitColor() +{ + return vary_AmblitColor; +} +vec3 getAdditiveColor() +{ + return vary_AdditiveColor; +} +vec3 getAtmosAttenuation() +{ + return vary_AtmosAttenuation; +} + +void setPositionEye(vec3 v) +{ + vary_PositionEye = v; +} + +void setSunlitColor(vec3 v) +{ + vary_SunlitColor = v; +} + +void setAmblitColor(vec3 v) +{ + vary_AmblitColor = v; +} + +void setAdditiveColor(vec3 v) +{ + vary_AdditiveColor = v; +} + +void setAtmosAttenuation(vec3 v) +{ + vary_AtmosAttenuation = v; +} + +void calcAtmospherics(vec3 inPositionEye, float ambFactor) { + + vec3 P = inPositionEye; + setPositionEye(P); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = sunlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + setAtmosAttenuation(temp1.rgb); + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + /* decrease value and saturation (that in HSV, not HSL) for occluded areas + * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html + * // The following line of code performs the equivalent of: + * float ambAlpha = tmpAmbient.a; + * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis + * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); + * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); + */ + tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + + //haze color + setAdditiveColor( + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient))); + + //brightness of surface both sunlight and ambient + setSunlitColor(vec3(sunlight * .5)); + setAmblitColor(vec3(tmpAmbient * .25)); + setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); +} + +vec3 atmosLighting(vec3 light) +{ + light *= getAtmosAttenuation().r; + light += getAdditiveColor(); + return (2.0 * light); +} + +vec3 atmosTransport(vec3 light) { + light *= getAtmosAttenuation().r; + light += getAdditiveColor() * 2.0; + return light; +} +vec3 atmosGetDiffuseSunlightColor() +{ + return getSunlitColor(); +} + +vec3 scaleDownLight(vec3 light) +{ + return (light / vec3(scene_light_strength, scene_light_strength, scene_light_strength)); +} + +vec3 scaleUpLight(vec3 light) +{ + return (light * vec3(scene_light_strength, scene_light_strength, scene_light_strength)); +} + +vec3 atmosAmbient(vec3 light) +{ + return getAmblitColor() + (light * vec3(0.5f, 0.5f, 0.5f)); +} + +vec3 atmosAffectDirectionalLight(float lightIntensity) +{ + return getSunlitColor() * vec3(lightIntensity, lightIntensity, lightIntensity); +} + +vec3 scaleSoftClip(vec3 light) +{ + //soft clip effect: + vec3 zeroes = vec3(0.0f, 0.0f, 0.0f); + vec3 ones = vec3(1.0f, 1.0f, 1.0f); + + light = ones - clamp(light, zeroes, ones); + light = ones - pow(light, gamma.xxx); + + return light; +} + +vec3 fullbrightAtmosTransport(vec3 light) { + float brightness = dot(light.rgb, vec3(0.33333)); + + return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); +} + +vec3 fullbrightScaleSoftClip(vec3 light) +{ + //soft clip effect: + return light; +} + vec3 srgb_to_linear(vec3 cs) { @@ -229,13 +430,15 @@ void main() vec4 pos = vec4(vary_position, 1.0); + float shadow = 1.0; -#if HAS_SHADOW - float shadow = 0.0; +#if HAS_SHADOW vec4 spos = pos; if (spos.z > -shadow_clip.w) { + shadow = 0.0; + vec4 lpos; vec4 near_split = shadow_clip*-0.75; @@ -294,7 +497,6 @@ void main() { shadow = 1.0; } - #endif #ifdef USE_INDEXED_TEX @@ -303,36 +505,43 @@ void main() vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif vec4 gamma_diff = diff; - - diff.rgb = srgb_to_linear(diff.rgb); -#ifdef USE_VERTEX_COLOR - float vertex_color_alpha = diff.a * vertex_color.a; -#else - float vertex_color_alpha = diff.a; -#endif + diff.rgb = srgb_to_linear(diff.rgb); + diff.rgb *= vertex_color.rgb; + + float final_alpha = diff.a * vertex_color.a; - vec3 normal = vary_norm; + vec3 norm = vary_norm; + + calcAtmospherics(pos.xyz, 1.0); - vec3 l = light_position[0].xyz; - vec3 dlight = calcDirectionalLight(normal, l); - dlight = dlight * vary_directional.rgb * vary_pointlight_col; + float da =dot(norm.xyz, sun_dir.xyz); + float final_da = da; + final_da = min(final_da, shadow); + final_da = max(final_da, final_alpha); + final_da = max(final_da, 0.0f); -#if HAS_SHADOW - vec4 col = vec4(vary_ambient + dlight * shadow, vertex_color_alpha); -#else - vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha); -#endif + vec4 color = vec4(0,0,0,0); - vec4 color = col; + color.rgb = atmosAmbient(color.rgb); + color.a = final_alpha; + + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0-ambient); + + color.rgb *= ambient; + + color.rgb += atmosAffectDirectionalLight(final_da); color.rgb *= gamma_diff.rgb; - color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - - col = vec4(0,0,0,0); + color.rgb = mix(atmosLighting(color.rgb), fullbrightAtmosTransport(color.rgb), diff.a); + color.rgb = mix(scaleSoftClip(color.rgb), fullbrightScaleSoftClip(color.rgb), diff.a); + + vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) col.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, normal, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -344,7 +553,7 @@ void main() // keep it linear // - color.rgb = srgb_to_linear(color.rgb) + col.rgb; + color.rgb = srgb_to_linear(color.rgb) + light.rgb; // ramp directly to display gamma as we're POST-deferred // -- cgit v1.2.3 From e681d19ea678ae378807b2054d33b6b1abcb8b6b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 12:17:39 -0700 Subject: MATBUG-306 regression fix, vert color applied in wrong colorspace --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f4298d2bde..e3be7a52ec 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -504,11 +504,11 @@ void main() #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - vec4 gamma_diff = diff; - - diff.rgb = srgb_to_linear(diff.rgb); diff.rgb *= vertex_color.rgb; + vec4 gamma_diff = diff; + diff.rgb = srgb_to_linear(diff.rgb); + float final_alpha = diff.a * vertex_color.a; vec3 norm = vary_norm; -- cgit v1.2.3 From f357269c38a8627aeb67c82c5ee34b49336e0d8b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Jul 2013 09:36:13 -0700 Subject: NORSPEC-325 WIP restore gamma (uncorrected) attenuation and unify sRGB conversion in one place --- .../shaders/class1/deferred/alphaF.glsl | 38 +++------------------- 1 file changed, 5 insertions(+), 33 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e3be7a52ec..075699c591 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -93,10 +93,13 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); - //a = pow(a, 1.0/1.3); + a = pow(a, 1.0/1.3); return vec3(a,a,a); } @@ -392,37 +395,6 @@ vec3 fullbrightScaleSoftClip(vec3 light) return light; } -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - vec3 low_range = cs / vec3(12.92); - - if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) - return low_range; - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} - - void main() { vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; @@ -533,7 +505,7 @@ void main() color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(final_da); + color.rgb += atmosAffectDirectionalLight(pow(final_da, 1.0/1.3)); color.rgb *= gamma_diff.rgb; color.rgb = mix(atmosLighting(color.rgb), fullbrightAtmosTransport(color.rgb), diff.a); -- cgit v1.2.3 From 3045dd6c5113d03fd0b0453ce916fc2a1c27c4e0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Jul 2013 12:13:21 -0700 Subject: Make use of vertex_color selectable per shader with alphaF/alphaV again --- .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 075699c591..52858f45f4 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -77,7 +77,10 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec2 vary_texcoord0; VARYING vec3 vary_norm; + +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; +#endif vec3 vary_PositionEye; vec3 vary_SunlitColor; @@ -476,13 +479,17 @@ void main() #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif + +#ifdef USE_VERTEX_COLOR + float final_alpha = diff.a * vertex_color.a; diff.rgb *= vertex_color.rgb; +#else + float final_alpha = diff.a; +#endif vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); - float final_alpha = diff.a * vertex_color.a; - vec3 norm = vary_norm; calcAtmospherics(pos.xyz, 1.0); -- cgit v1.2.3 From f86a7c04d3c265f4d61d99d1d7fdb7e35c4bc3f6 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 30 Jul 2013 11:33:58 -0700 Subject: NORSPEC-314 rollback unified srgb shader code to see if we can get past Mac 10.6.8 nV driver issues --- .../shaders/class1/deferred/alphaF.glsl | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 52858f45f4..d11f67ee58 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -96,8 +96,42 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec3 calcDirectionalLight(vec3 n, vec3 l) { -- cgit v1.2.3 From 08e429e27df488cb8740eb82f3fb10d5011e6f5d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 5 Aug 2013 06:23:13 -0700 Subject: NORSPEC-285 NORSPEC-293 NORSPEC-298 fix ighting diffs between alpha/non/ALM/non-ALM --- .../shaders/class1/deferred/alphaF.glsl | 48 +++++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d11f67ee58..d0c7cc9dde 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -133,6 +133,23 @@ vec3 linear_to_srgb(vec3 cl) } +vec2 encode_normal(vec3 n) +{ + float f = sqrt(8 * n.z + 8); + return n.xy / f + 0.5; +} + +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc*4-2; + float f = dot(fenc,fenc); + float g = sqrt(1-f/4); + vec3 n; + n.xy = fenc*g; + n.z = 1-f/2; + return n; +} + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -527,33 +544,42 @@ void main() vec3 norm = vary_norm; calcAtmospherics(pos.xyz, 1.0); - - float da =dot(norm.xyz, sun_dir.xyz); + + vec2 abnormal = encode_normal(norm.xyz); + norm.xyz = decode_normal(abnormal.xy); + + float da = dot(norm.xyz, sun_dir.xyz); + float final_da = da; final_da = min(final_da, shadow); - final_da = max(final_da, final_alpha); final_da = max(final_da, 0.0f); + final_da = min(final_da, 1.0f); + final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); color.rgb = atmosAmbient(color.rgb); color.a = final_alpha; - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); + float ambient = abs(da); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(pow(final_da, 1.0/1.3)); + color.rgb += atmosAffectDirectionalLight(final_da); color.rgb *= gamma_diff.rgb; - color.rgb = mix(atmosLighting(color.rgb), fullbrightAtmosTransport(color.rgb), diff.a); - color.rgb = mix(scaleSoftClip(color.rgb), fullbrightScaleSoftClip(color.rgb), diff.a); + color.rgb = mix(diff.rgb, color.rgb, final_alpha); + + color.rgb = atmosLighting(color.rgb); + color.rgb = scaleSoftClip(color.rgb); vec4 light = vec4(0,0,0,0); - + + color.rgb = srgb_to_linear(color.rgb); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z); LIGHT_LOOP(1) @@ -566,11 +592,11 @@ void main() // keep it linear // - color.rgb = srgb_to_linear(color.rgb) + light.rgb; + color.rgb += light.rgb; - // ramp directly to display gamma as we're POST-deferred + // straight to display gamma, we're post-deferred // - color.rgb = pow(color.rgb,vec3(display_gamma)); + color.rgb = linear_to_srgb(color.rgb); #ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); -- cgit v1.2.3 From 51dfcb9c67f7c3464bf3640adfdd87a061f60390 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Aug 2013 15:55:25 -0700 Subject: NORSPEC-342 WIP MATBUG-347 make impostor rendering not contribute to depth for mostly-transparent buffer pixels, aka hair in ALM only --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d0c7cc9dde..f35ff25dcb 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -531,6 +531,19 @@ void main() vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif +#if FOR_IMPOSTOR + vec4 color; + color.rgb = diff.rgb; + color.a = diff.a; + + // Insure we don't pollute depth with invis pixels in impostor rendering + // + if (color.a < 0.01) + { + discard; + } +#else + #ifdef USE_VERTEX_COLOR float final_alpha = diff.a * vertex_color.a; diff.rgb *= vertex_color.rgb; @@ -538,6 +551,7 @@ void main() float final_alpha = diff.a; #endif + vec4 gamma_diff = diff; diff.rgb = srgb_to_linear(diff.rgb); @@ -567,11 +581,10 @@ void main() ambient = (1.0-ambient); color.rgb *= ambient; - color.rgb += atmosAffectDirectionalLight(final_da); color.rgb *= gamma_diff.rgb; - color.rgb = mix(diff.rgb, color.rgb, final_alpha); + //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); @@ -600,6 +613,8 @@ void main() #ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); +#endif + #endif frag_color = color; -- cgit v1.2.3 From e586f0325f23363e0223162f4643c7c4c1dfe4a4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 12 Aug 2013 17:45:11 -0700 Subject: NORSPEC-342 tweak shader to work on mac og glsl --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index f35ff25dcb..d1abebf84c 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -531,7 +531,7 @@ void main() vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif -#if FOR_IMPOSTOR +#ifdef FOR_IMPOSTOR vec4 color; color.rgb = diff.rgb; color.a = diff.a; -- cgit v1.2.3 From 141c34cff46a7f2be868df45aa1a8de7b95fa4a4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 15 Aug 2013 08:00:47 -0700 Subject: NORSPEC-342 NORSPEC-352 make impostor alpha shader use vertex alpha to remedy unsightly blemishes, boxes, and the occasional extra wing. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d1abebf84c..cd7a76db28 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -534,11 +534,17 @@ void main() #ifdef FOR_IMPOSTOR vec4 color; color.rgb = diff.rgb; - color.a = diff.a; + +#ifdef USE_VERTEX_COLOR + float final_alpha = diff.a * vertex_color.a; + diff.rgb *= vertex_color.rgb; +#else + float final_alpha = diff.a; +#endif // Insure we don't pollute depth with invis pixels in impostor rendering // - if (color.a < 0.01) + if (final_alpha < 0.01) { discard; } -- cgit v1.2.3