From 9593e85e144e2141c92abe597653851852501060 Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Sun, 9 Sep 2012 21:01:24 -0400 Subject: Use a customized normalized gaussian specular term. --- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9df9d75905..457189b48e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -309,7 +309,7 @@ void main() // vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r); + vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; -- cgit v1.2.3 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. --- .../app_settings/shaders/class2/deferred/alphaF.glsl | 1 + .../app_settings/shaders/class2/deferred/softenLightF.glsl | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 12706f130b..359864556d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -149,6 +149,7 @@ void main() } vec4 diff = diffuseLookup(vary_texcoord0.xy); + diff.rgb = pow(diff.rgb, vec3(2.2)); vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a); vec4 color = diff * col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 457189b48e..bf4c476138 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -79,6 +79,11 @@ vec3 vary_AmblitColor; vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; +vec3 samplesRGB(vec3 color) +{ + return pow(color, vec3(2.2)); +} + vec4 getPosition_d(vec2 pos_screen, float depth) { vec2 sc = pos_screen.xy*2.0; @@ -103,15 +108,15 @@ vec3 getPositionEye() } vec3 getSunlitColor() { - return vary_SunlitColor; + return samplesRGB(vary_SunlitColor) * 4.4; } vec3 getAmblitColor() { - return vary_AmblitColor; + return samplesRGB(vary_AmblitColor) * 2.2; } vec3 getAdditiveColor() { - return vary_AdditiveColor; + return samplesRGB(vary_AdditiveColor) * 2.2; } vec3 getAtmosAttenuation() { @@ -318,7 +323,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; - col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, + col = mix(col.rgb, samplesRGB(textureCube(environmentMap, env_vec).rgb) * 2.2, max(spec.a-diffuse.a*2.0, 0.0)); } -- cgit v1.2.3 From de0863ed6e91fda0c1b5342b9fecf07c4af47d63 Mon Sep 17 00:00:00 2001 From: Geenz Date: Fri, 11 Jan 2013 07:19:27 -0500 Subject: Linearize spotlight textures. --- .../app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 6 ++++++ indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 5621e47ab7..695887c5ff 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -71,6 +71,8 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); + vec2 dist = tc-vec2(0.5); float det = max(1.0-lod/(proj_lod*0.5), 0.0); @@ -86,6 +88,8 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); float det = min(lod/(proj_lod*0.5), 1.0); @@ -103,6 +107,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); + vec2 dist = tc-vec2(0.5); float d = dot(dist,dist); diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 6d6ad6d565..525dd32106 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -71,6 +71,8 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); + vec2 dist = tc-vec2(0.5); float det = max(1.0-lod/(proj_lod*0.5), 0.0); @@ -86,6 +88,8 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); float det = min(lod/(proj_lod*0.5), 1.0); @@ -103,6 +107,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); + vec2 dist = tc-vec2(0.5); float d = dot(dist,dist); -- cgit v1.2.3 From aa1befd689703d9fea50399201911e0f8fca6ac6 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 30 Jan 2013 12:17:04 -0500 Subject: Specular map support. This is the vast majority of the material parameters implemented at this point for opaque geometry. --- .../newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index bf4c476138..e95991a635 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -283,8 +283,8 @@ void main() vec2 tc = vary_fragcoord.xy; float depth = texture2DRect(depthMap, tc.xy).r; vec3 pos = getPosition_d(tc, depth).xyz; - vec3 norm = texture2DRect(normalMap, tc).xyz; - norm = (norm.xyz-0.5)*2.0; // unpack norm + vec4 norm = texture2DRect(normalMap, tc); + norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); @@ -324,7 +324,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; col = mix(col.rgb, samplesRGB(textureCube(environmentMap, env_vec).rgb) * 2.2, - max(spec.a-diffuse.a*2.0, 0.0)); + max(norm.a-diffuse.a*2.0, 0.0)); } col = atmosLighting(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. --- .../shaders/class2/deferred/alphaF.glsl | 1 - .../shaders/class2/deferred/multiSpotLightF.glsl | 6 ------ .../shaders/class2/deferred/softenLightF.glsl | 21 ++++++++------------- .../shaders/class2/deferred/spotLightF.glsl | 6 ------ 4 files changed, 8 insertions(+), 26 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 359864556d..12706f130b 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -149,7 +149,6 @@ void main() } vec4 diff = diffuseLookup(vary_texcoord0.xy); - diff.rgb = pow(diff.rgb, vec3(2.2)); vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a); vec4 color = diff * col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 695887c5ff..5621e47ab7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -71,8 +71,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); - vec2 dist = tc-vec2(0.5); float det = max(1.0-lod/(proj_lod*0.5), 0.0); @@ -88,8 +86,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); - vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); float det = min(lod/(proj_lod*0.5), 1.0); @@ -107,8 +103,6 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); - vec2 dist = tc-vec2(0.5); float d = dot(dist,dist); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index e95991a635..9df9d75905 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -79,11 +79,6 @@ vec3 vary_AmblitColor; vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; -vec3 samplesRGB(vec3 color) -{ - return pow(color, vec3(2.2)); -} - vec4 getPosition_d(vec2 pos_screen, float depth) { vec2 sc = pos_screen.xy*2.0; @@ -108,15 +103,15 @@ vec3 getPositionEye() } vec3 getSunlitColor() { - return samplesRGB(vary_SunlitColor) * 4.4; + return vary_SunlitColor; } vec3 getAmblitColor() { - return samplesRGB(vary_AmblitColor) * 2.2; + return vary_AmblitColor; } vec3 getAdditiveColor() { - return samplesRGB(vary_AdditiveColor) * 2.2; + return vary_AdditiveColor; } vec3 getAtmosAttenuation() { @@ -283,8 +278,8 @@ void main() vec2 tc = vary_fragcoord.xy; float depth = texture2DRect(depthMap, tc.xy).r; vec3 pos = getPosition_d(tc, depth).xyz; - vec4 norm = texture2DRect(normalMap, tc); - norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm + vec3 norm = texture2DRect(normalMap, tc).xyz; + norm = (norm.xyz-0.5)*2.0; // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); @@ -314,7 +309,7 @@ void main() // vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); + vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; @@ -323,8 +318,8 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; - col = mix(col.rgb, samplesRGB(textureCube(environmentMap, env_vec).rgb) * 2.2, - max(norm.a-diffuse.a*2.0, 0.0)); + col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, + max(spec.a-diffuse.a*2.0, 0.0)); } col = atmosLighting(col); diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 525dd32106..6d6ad6d565 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -71,8 +71,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); - vec2 dist = tc-vec2(0.5); float det = max(1.0-lod/(proj_lod*0.5), 0.0); @@ -88,8 +86,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); - vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); float det = min(lod/(proj_lod*0.5), 1.0); @@ -107,8 +103,6 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); - vec2 dist = tc-vec2(0.5); float d = dot(dist,dist); -- cgit v1.2.3 From 6300f4f768de13823a754831797cb34022f87b60 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 27 Mar 2013 21:59:14 -0500 Subject: NORSPEC-61 Hook up material parameters to shaders. --- .../newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9df9d75905..ff20b63972 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -278,8 +278,8 @@ void main() vec2 tc = vary_fragcoord.xy; float depth = texture2DRect(depthMap, tc.xy).r; vec3 pos = getPosition_d(tc, depth).xyz; - vec3 norm = texture2DRect(normalMap, tc).xyz; - norm = (norm.xyz-0.5)*2.0; // unpack norm + vec4 norm = texture2DRect(normalMap, tc); + norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); @@ -319,7 +319,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, - max(spec.a-diffuse.a*2.0, 0.0)); + max(norm.a-diffuse.a*2.0, 0.0)); } col = atmosLighting(col); -- cgit v1.2.3 From 8da8e05964710bea633af2bee36a7aa89f3a8656 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Apr 2013 01:47:12 -0500 Subject: NORSPEC-58 Followup -- put back blinn phong, and do gamma correction approximation in light curves. Fix fresnel math. --- .../shaders/class2/deferred/multiSpotLightF.glsl | 31 +++++++++++++++++++--- .../shaders/class2/deferred/softenLightF.glsl | 5 ++-- .../shaders/class2/deferred/spotLightF.glsl | 25 +++++++++++++++-- .../shaders/class2/deferred/sunLightF.glsl | 1 + .../shaders/class2/deferred/sunLightSSAOF.glsl | 1 + 5 files changed, 56 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 5621e47ab7..d237ec6236 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -39,6 +39,7 @@ uniform samplerCube environmentMap; uniform sampler2DRect lightMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; +uniform sampler2D lightFunc; uniform mat4 proj_mat; //screen space to light space uniform float proj_near; //near clip for projection @@ -177,7 +178,7 @@ void main() lv = proj_origin-pos.xyz; lv = normalize(lv); float da = dot(norm, lv); - + vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; @@ -203,6 +204,8 @@ void main() lit = da * dist_atten * noise; + lit = pow(lit, 0.7); + col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -241,6 +244,7 @@ void main() float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0); + //stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); if (stc.x < 1.0 && @@ -248,8 +252,29 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; + + vec3 npos = -normalize(pos); + lv = pfinal-pos.xyz; + lv = normalize(lv); + + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb; + } + + //vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); + //col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; } } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index ff20b63972..eafb7d9c75 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -282,7 +282,8 @@ void main() norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - + da = pow(da, 0.7); + vec4 diffuse = texture2DRect(diffuseRect, tc); vec3 col; @@ -309,7 +310,7 @@ void main() // vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r); + vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 6d6ad6d565..af8089ce67 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -39,6 +39,8 @@ uniform samplerCube environmentMap; uniform sampler2DRect lightMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; +uniform sampler2D lightFunc; + uniform mat4 proj_mat; //screen space to light space uniform float proj_near; //near clip for projection @@ -203,6 +205,8 @@ void main() lit = da * dist_atten * noise; + lit = pow(lit, 0.7); + col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -248,8 +252,25 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; + vec3 npos = -normalize(pos); + lv = pfinal-pos.xyz; + lv = normalize(lv); + + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb; + } } } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 890486c4b1..147fb4562e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -138,6 +138,7 @@ void main() float shadow = 0.0; float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + dp_directional_light = pow(dp_directional_light, 0.7); vec3 shadow_pos = pos.xyz + displace*norm; vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 2dcd3d656f..907b96ffe4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -199,6 +199,7 @@ void main() float shadow = 0.0; float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + dp_directional_light = pow(dp_directional_light, 0.7); vec3 shadow_pos = pos.xyz + displace*norm; vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); -- 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. --- .../shaders/class2/deferred/multiSpotLightF.glsl | 13 ++++++++++++- .../shaders/class2/deferred/softenLightF.glsl | 17 ++++++++++++++--- .../shaders/class2/deferred/spotLightF.glsl | 13 ++++++++++++- .../app_settings/shaders/class2/deferred/sunLightF.glsl | 13 ++++++++++++- .../shaders/class2/deferred/sunLightSSAOF.glsl | 13 ++++++++++++- 5 files changed, 62 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index d237ec6236..b3ab8fd510 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -68,6 +68,17 @@ uniform vec2 screen_res; uniform mat4 inv_proj; +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; +} + vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); @@ -155,7 +166,7 @@ void main() } vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = (norm.xyz-0.5)*2.0; // unpack norm + norm = decode_normal(norm.xy); norm = normalize(norm); float l_dist = -dot(lv, proj_n); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index eafb7d9c75..de9b2cd0d1 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -79,6 +79,17 @@ vec3 vary_AmblitColor; vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; +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; +} + vec4 getPosition_d(vec2 pos_screen, float depth) { vec2 sc = pos_screen.xy*2.0; @@ -279,8 +290,8 @@ void main() float depth = texture2DRect(depthMap, tc.xy).r; vec3 pos = getPosition_d(tc, depth).xyz; vec4 norm = texture2DRect(normalMap, tc); - norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm - + float envIntensity = norm.z; + norm.xyz = decode_normal(norm.xy); float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); da = pow(da, 0.7); @@ -320,7 +331,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, - max(norm.a-diffuse.a*2.0, 0.0)); + max(envIntensity-diffuse.a*2.0, 0.0)); } col = atmosLighting(col); diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index af8089ce67..43fc5dbc5e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -69,6 +69,17 @@ uniform vec2 screen_res; uniform mat4 inv_proj; +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; +} + vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); @@ -156,7 +167,7 @@ void main() } vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = (norm.xyz-0.5)*2.0; // unpack norm + norm = decode_normal(norm.xy); norm = normalize(norm); float l_dist = -dot(lv, proj_n); diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 147fb4562e..1e835ae49e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -65,6 +65,17 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; +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; +} + vec4 getPosition(vec2 pos_screen) { float depth = texture2DRect(depthMap, pos_screen.xy).r; @@ -126,7 +137,7 @@ void main() vec4 pos = getPosition(pos_screen); vec4 nmap4 = texture2DRect(normalMap, pos_screen); - nmap4 = vec4((nmap4.xyz-0.5)*2.0,nmap4.w); // unpack norm + nmap4 = vec4(decode_normal(nmap4.xy),nmap4.w); // unpack norm float displace = nmap4.w; vec3 norm = nmap4.xyz; diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 907b96ffe4..a995e9cba1 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -66,6 +66,17 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; +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; +} + vec4 getPosition(vec2 pos_screen) { float depth = texture2DRect(depthMap, pos_screen.xy).r; @@ -187,7 +198,7 @@ void main() vec4 pos = getPosition(pos_screen); vec4 nmap4 = texture2DRect(normalMap, pos_screen); - nmap4 = vec4((nmap4.xyz-0.5)*2.0,nmap4.w); // unpack norm + nmap4 = vec4(decode_normal(nmap4.xy),nmap4.w); // unpack norm float displace = nmap4.w; vec3 norm = nmap4.xyz; -- cgit v1.2.3 From e4faf91bb20c33cba5b060064f03da5f1e863984 Mon Sep 17 00:00:00 2001 From: Geenz Date: Tue, 9 Apr 2013 14:45:27 -0400 Subject: Start using R16F again, and divide the bloom contrib by 6. --- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index de9b2cd0d1..8e638c64eb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -325,7 +325,7 @@ void main() // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib) / 4; + bloom = dot(spec_contrib, spec_contrib) / 6; col += spec_contrib; //add environmentmap -- cgit v1.2.3 From 84475635b9c3db8d42f2f0a256d34c08274f53ed Mon Sep 17 00:00:00 2001 From: Geenz Date: Tue, 9 Apr 2013 16:35:10 -0400 Subject: More per-pixel lighting fanciness. --- .../shaders/class2/deferred/alphaF.glsl | 54 ++++++++++++++++++++-- .../shaders/class2/deferred/alphaNonIndexedF.glsl | 54 ++++++++++++++++++++-- .../class2/deferred/alphaNonIndexedNoColorF.glsl | 52 ++++++++++++++++++++- .../shaders/class2/deferred/alphaV.glsl | 16 ++----- 4 files changed, 156 insertions(+), 20 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 12706f130b..6f10ff8451 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -53,11 +53,53 @@ VARYING vec3 vary_directional; VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; +VARYING vec3 vary_norm; uniform float shadow_bias; uniform mat4 inv_proj; +uniform vec4 light_position[8]; +uniform vec3 light_direction[8]; +uniform vec3 light_attenuation[8]; +uniform vec3 light_diffuse[8]; + +float calcDirectionalLight(vec3 n, vec3 l) +{ + float a = pow(max(dot(n,l),0.0), 0.7); + 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.7), 0.0); + } + + return da; +} + float pcfShadow(sampler2DShadow shadowMap, vec4 stc) { stc.xyz /= stc.w; @@ -147,17 +189,23 @@ void main() { shadow = 1.0; } - + vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; vec4 diff = diffuseLookup(vary_texcoord0.xy); - vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a); + vec4 col = vec4(vary_ambient + dlight *shadow, 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 += diff.rgb * vary_pointlight_col * light_col; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl index 228dc104ac..8fd8bb8066 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl @@ -52,12 +52,54 @@ VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; VARYING vec4 vertex_color; +VARYING vec3 vary_norm; uniform vec2 shadow_res; uniform float shadow_bias; uniform mat4 inv_proj; +uniform vec4 light_position[8]; +uniform vec3 light_direction[8]; +uniform vec3 light_attenuation[8]; +uniform vec3 light_diffuse[8]; + +float calcDirectionalLight(vec3 n, vec3 l) +{ + float a = pow(max(dot(n,l),0.0), 0.7); + 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.7), 0.0); + } + + return da; +} + vec4 getPosition(vec2 pos_screen) { float depth = texture2DRect(depthMap, pos_screen.xy).a; @@ -161,17 +203,23 @@ void main() { shadow = 1.0; } - + vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); - vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a); + vec4 col = vec4(vary_ambient + dlight*shadow, 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 += diff.rgb * vary_pointlight_col * light_col; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl index c3950a10e1..ff75b039b2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl @@ -60,6 +60,47 @@ uniform float shadow_bias; uniform mat4 inv_proj; +uniform vec4 light_position[8]; +uniform vec3 light_direction[8]; +uniform vec3 light_attenuation[8]; +uniform vec3 light_diffuse[8]; + +float calcDirectionalLight(vec3 n, vec3 l) +{ + float a = pow(max(dot(n,l),0.0), 0.7); + 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.7), 0.0); + } + + return da; +} + vec4 getPosition(vec2 pos_screen) { float depth = texture2DRect(depthMap, pos_screen.xy).a; @@ -169,15 +210,22 @@ void main() { shadow = 1.0; } + vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; - vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, 1.0); + vec4 col = vec4(vary_ambient + dlight*shadow, 1.0); 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 += diff.rgb * vary_pointlight_col * light_col; frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 1586aab0f2..79e5d7e572 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -53,6 +53,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +VARYING vec3 vary_norm; uniform float near_clip; uniform float shadow_offset; @@ -110,7 +111,7 @@ void main() vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; vec3 norm = normalize(normal_matrix * normal); - + vary_norm = norm; float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; @@ -119,16 +120,7 @@ void main() //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - - // Collect normal lights - col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z); - col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z); - col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z); - col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z); - col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z); - col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z); - - vary_pointlight_col = col.rgb*diffuse_color.rgb; + vary_pointlight_col = diffuse_color.rgb; col.rgb = vec3(0,0,0); @@ -136,7 +128,7 @@ void main() col.rgb = atmosAmbient(vec3(0.)); vary_ambient = col.rgb*diffuse_color.rgb; - vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a))); + vary_directional.rgb = atmosAffectDirectionalLight(1); col.rgb = col.rgb*diffuse_color.rgb; -- 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/class2/deferred/alphaF.glsl | 35 +++- .../shaders/class2/deferred/alphaNonIndexedF.glsl | 226 -------------------- .../class2/deferred/alphaNonIndexedNoColorF.glsl | 232 --------------------- .../shaders/class2/deferred/alphaSkinnedV.glsl | 5 +- 4 files changed, 31 insertions(+), 467 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl delete mode 100644 indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 6f10ff8451..a349981ea2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -25,25 +25,27 @@ #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 #define frag_color gl_FragColor #endif -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - uniform sampler2DShadow shadowMap0; uniform sampler2DShadow shadowMap1; uniform sampler2DShadow shadowMap2; uniform sampler2DShadow shadowMap3; uniform sampler2DRect depthMap; -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; +#if INDEX_MODE != INDEXED +uniform sampler2D diffuseMap; +#endif + uniform vec2 screen_res; -uniform vec2 shadow_res; vec3 atmosLighting(vec3 light); vec3 scaleSoftClip(vec3 light); @@ -53,8 +55,16 @@ 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; +#if INDEX_MODE != NON_INDEXED_NO_COLOR +VARYING vec4 vertex_color; +#endif + +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform vec2 shadow_res; uniform float shadow_bias; uniform mat4 inv_proj; @@ -190,9 +200,20 @@ void main() shadow = 1.0; } vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; + +#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 - vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color.a); + vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color_alpha); vec4 color = diff * col; color.rgb = atmosLighting(color.rgb); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl deleted file mode 100644 index 8fd8bb8066..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ /dev/null @@ -1,226 +0,0 @@ -/** - * @file alphaF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; -uniform sampler2DRect depthMap; -uniform sampler2D diffuseMap; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform vec2 screen_res; - -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 vec2 vary_texcoord0; -VARYING vec4 vertex_color; -VARYING vec3 vary_norm; - -uniform vec2 shadow_res; -uniform float shadow_bias; - -uniform mat4 inv_proj; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = pow(max(dot(n,l),0.0), 0.7); - 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.7), 0.0); - } - - return da; -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos.xyz /= pos.w; - pos.w = 1.0; - return pos; -} - -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*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; -} - - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - float shadow = 0.0; - vec4 pos = vec4(vary_position, 1.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; - } - vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); - - vec4 col = vec4(vary_ambient + dlight*shadow, vertex_color.a); - vec4 color = diff * col; - - color.rgb = atmosLighting(color.rgb); - - 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); - } - - color.rgb += diff.rgb * vary_pointlight_col * light_col; - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl deleted file mode 100644 index ff75b039b2..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ /dev/null @@ -1,232 +0,0 @@ -/** - * @file alphaNonIndexedNoColorF.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2005, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform float minimum_alpha; - -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; -uniform sampler2DRect depthMap; -uniform sampler2D diffuseMap; - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform vec2 screen_res; - -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 vec2 vary_texcoord0; - -uniform vec2 shadow_res; - -uniform float shadow_bias; - -uniform mat4 inv_proj; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = pow(max(dot(n,l),0.0), 0.7); - 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.7), 0.0); - } - - return da; -} - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).a; - vec2 sc = pos_screen.xy*2.0; - sc /= screen_res; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos.xyz /= pos.w; - pos.w = 1.0; - return pos; -} - -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*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; -} - - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - float shadow = 0.0; - vec4 pos = vec4(vary_position, 1.0); - - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); - - if (diff.a < minimum_alpha) - { - discard; - } - - 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; - } - vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; - - vec4 col = vec4(vary_ambient + dlight*shadow, 1.0); - vec4 color = diff * col; - - color.rgb = atmosLighting(color.rgb); - - 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); - } - - color.rgb += diff.rgb * vary_pointlight_col * light_col; - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl index 9629cfe824..7f4d82ecc6 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl @@ -50,7 +50,7 @@ VARYING vec3 vary_pointlight_col; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; - +VARYING vec3 vary_norm; uniform float near_clip; uniform float shadow_offset; @@ -115,7 +115,8 @@ void main() n.xyz = normalize(n.xyz-pos.xyz); vec3 norm = n.xyz; - + vary_norm = norm; + float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; -- 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 --- .../app_settings/shaders/class2/deferred/alphaF.glsl | 19 ++++++++++++++----- .../shaders/class2/deferred/alphaNonIndexedF.glsl | 19 ++++++++++++++----- .../class2/deferred/alphaNonIndexedNoColorF.glsl | 17 +++++++++++++---- 3 files changed, 41 insertions(+), 14 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 6f10ff8451..f93bf66fa9 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -189,7 +189,10 @@ void main() { shadow = 1.0; } - 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 diff = diffuseLookup(vary_texcoord0.xy); vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color.a); @@ -200,11 +203,17 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); - for (int i = 2; i < 8; i++) - { +#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; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl index 8fd8bb8066..08fbb3c29b 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl @@ -203,7 +203,10 @@ void main() { shadow = 1.0; } - 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 diff = texture2D(diffuseMap,vary_texcoord0.xy); vec4 col = vec4(vary_ambient + dlight*shadow, vertex_color.a); @@ -214,11 +217,17 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); - for (int i = 2; i < 8; i++) - { +#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; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl index ff75b039b2..6567f3fded 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl @@ -210,7 +210,10 @@ void main() { shadow = 1.0; } - 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*shadow, 1.0); vec4 color = diff * col; @@ -220,10 +223,16 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); - for (int i = 2; i < 8; i++) - { +#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; -- 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 --- .../app_settings/shaders/class2/deferred/alphaF.glsl | 16 +++++++++++----- .../shaders/class2/deferred/alphaNonIndexedF.glsl | 13 ++++++++++--- .../shaders/class2/deferred/alphaNonIndexedNoColorF.glsl | 10 ++++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index f93bf66fa9..1a25ea97b7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -64,10 +64,10 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -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) @@ -203,9 +203,10 @@ 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) LIGHT_LOOP(2) LIGHT_LOOP(3) @@ -213,7 +214,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; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl index 08fbb3c29b..39a5a9894d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl @@ -64,10 +64,10 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -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) @@ -217,7 +217,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) @@ -227,6 +228,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; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl index 6567f3fded..4bd9ccca1d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl @@ -223,7 +223,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) @@ -233,7 +234,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 fafa21315f043ab51e3373e825c85646685778a6 Mon Sep 17 00:00:00 2001 From: g Date: Fri, 12 Apr 2013 15:21:35 -0700 Subject: Fix issue with alphaNonIndexedNoColorF shader and static init fail on default spec color (real source of NORSPEC-94, I think) --- .../shaders/class2/deferred/alphaNonIndexedNoColorF.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl index 4bd9ccca1d..566aefea6a 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl @@ -53,6 +53,7 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; VARYING vec2 vary_texcoord0; +VARYING vec3 vary_norm; uniform vec2 shadow_res; @@ -65,10 +66,10 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -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) -- 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/class2/deferred/alphaF.glsl | 20 +++++- .../shaders/class2/deferred/alphaV.glsl | 81 +++++++++++++++++++--- 2 files changed, 91 insertions(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index a349981ea2..0c8d48368f 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -57,6 +57,7 @@ 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; @@ -74,6 +75,12 @@ 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; + float calcDirectionalLight(vec3 n, vec3 l) { float a = pow(max(dot(n,l),0.0), 0.7); @@ -199,7 +206,7 @@ void main() { shadow = 1.0; } - vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; + #if INDEX_MODE == INDEXED vec4 diff = diffuseLookup(vary_texcoord0.xy); @@ -213,6 +220,14 @@ void main() float vertex_color_alpha = vertex_color.a; #endif + 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])); + + vec3 dlight = calcDirectionalLight(normal, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col; + vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color_alpha); vec4 color = diff * col; @@ -223,8 +238,9 @@ 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); } + color.rgb += diff.rgb * vary_pointlight_col * light_col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 79e5d7e572..9a3407372d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -23,16 +23,30 @@ * $/LicenseInfo$ */ +#define INDEXED 1 +#define NON_INDEXED 2 +#define NON_INDEXED_NO_COLOR 3 + uniform mat3 normal_matrix; uniform mat4 texture_matrix0; +uniform mat4 projection_matrix; uniform mat4 modelview_matrix; uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; +#if INDEX_MODE == INDEXED void passTextureIndex(); +#endif ATTRIBUTE vec3 normal; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec2 texcoord0; +ATTRIBUTE vec3 binormal; + +#if HAS_SKIN +mat4 getObjectSkinnedTransform(); +#elif IS_AVATAR_SKIN +mat4 getSkinnedTransform(); +#endif vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); @@ -50,10 +64,14 @@ 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; +VARYING mat3 vary_rotation; uniform float near_clip; uniform float shadow_offset; @@ -102,19 +120,61 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa void main() { + vec4 pos; + vec3 norm; + //transform vertex +#if HAS_SKIN + mat4 trans = getObjectSkinnedTransform(); + trans = modelview_matrix * trans; + + pos = trans * vec4(position.xyz, 1.0); + + norm = position.xyz + normal.xyz; + norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz); + vec4 frag_pos = projection_matrix * pos; + gl_Position = frag_pos; +#elif IS_AVATAR_SKIN + mat4 trans = getSkinnedTransform(); + vec4 pos_in = vec4(position.xyz, 1.0); + pos.x = dot(trans[0], pos_in); + pos.y = dot(trans[1], pos_in); + pos.z = dot(trans[2], pos_in); + pos.w = 1.0; + + norm.x = dot(trans[0].xyz, normal); + norm.y = dot(trans[1].xyz, normal); + norm.z = dot(trans[2].xyz, normal); + norm = normalize(norm); + + vec4 frag_pos = projection_matrix * pos; + gl_Position = frag_pos; +#else + norm = normalize(normal_matrix * normal); vec4 vert = vec4(position.xyz, 1.0); - passTextureIndex(); - vec4 pos = (modelview_matrix * vert); + pos = (modelview_matrix * vert); gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); +#endif +#if INDEX_MODE == INDEXED + passTextureIndex(); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - - vec3 norm = normalize(normal_matrix * normal); +#else + vary_texcoord0 = texcoord0; +#endif + vary_norm = norm; float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; - + + vec3 n = norm; + vec3 b = normalize(normal_matrix * binormal); + vec3 t = cross(b, n); + + vary_rotation[0] = vec3(t.x, b.x, n.x); + vary_rotation[1] = vec3(t.y, b.y, n.y); + vary_rotation[2] = vec3(t.z, b.z, n.z); + calcAtmospherics(pos.xyz); //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); @@ -132,11 +192,16 @@ void main() col.rgb = col.rgb*diffuse_color.rgb; +#if INDEX_MODE != NON_INDEXED_NO_COLOR vertex_color = col; - - +#endif +#if HAS_SKIN + vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); +#elif IS_AVATAR_SKIN + vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); +#else pos = modelview_projection_matrix * vert; vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); - +#endif } -- 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/class2/deferred/alphaF.glsl | 4 +++- indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 0c8d48368f..7bc6a9b1dd 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/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; @@ -221,7 +223,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])); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 9a3407372d..5f2961c90e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -41,6 +41,9 @@ ATTRIBUTE vec3 normal; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec2 texcoord0; ATTRIBUTE vec3 binormal; +ATTRIBUTE vec2 texcoord1; +ATTRIBUTE vec2 texcoord2; + #if HAS_SKIN mat4 getObjectSkinnedTransform(); @@ -69,6 +72,8 @@ VARYING vec4 vertex_color; #endif VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; VARYING vec3 vary_norm; VARYING mat3 vary_rotation; @@ -155,7 +160,8 @@ void main() pos = (modelview_matrix * vert); gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); #endif - + vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; + vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; #if INDEX_MODE == INDEXED passTextureIndex(); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; -- cgit v1.2.3 From 359b6cad5b8ae2a88927d53eaa12b58a126e0d1c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 15 Apr 2013 14:12:16 -0500 Subject: NORSPEC-117 Fix distance attenuation to not use pow(lit, 0.7) function so distance falloff is still soft --- .../newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 4 +--- indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index b3ab8fd510..90b6856c5c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -213,9 +213,7 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); + lit = pow(da,0.7) * dist_atten * noise; col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 43fc5dbc5e..5fd6f0afb7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -214,9 +214,7 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); + lit = pow(da, 0.7) * dist_atten * noise; col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; -- 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/class2/deferred/alphaF.glsl | 12 +++--------- .../shaders/class2/deferred/alphaNonIndexedF.glsl | 11 ++--------- .../shaders/class2/deferred/alphaNonIndexedNoColorF.glsl | 14 ++++---------- 3 files changed, 9 insertions(+), 28 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 1a25ea97b7..b71b8c0dfc 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -70,7 +70,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) 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; @@ -97,7 +97,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); } float pcfShadow(sampler2DShadow shadowMap, vec4 stc) @@ -203,7 +203,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); @@ -214,12 +213,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; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl index 39a5a9894d..9670d59399 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl @@ -70,7 +70,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) 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; @@ -97,7 +97,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); } vec4 getPosition(vec2 pos_screen) @@ -217,7 +217,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); @@ -228,12 +227,6 @@ 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; diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl index 566aefea6a..fae279fba0 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl @@ -72,7 +72,7 @@ vec3 calcDirectionalLight(vec3 n, vec3 l) 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; @@ -99,7 +99,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); } vec4 getPosition(vec2 pos_screen) @@ -224,8 +224,7 @@ void main() color.rgb = scaleSoftClip(color.rgb); vec3 light_col = vec3(0,0,0); -#if MAC_GEFORCE_HACK - #define LIGHT_LOOP(i) + #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) @@ -235,12 +234,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/class2/deferred/alphaF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 42467a1b60..e55023c384 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -240,10 +240,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) @@ -253,7 +253,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 67af268b785e8a47d7db10aa3a566c269b0f16e3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 17 Apr 2013 01:51:39 -0500 Subject: NORSPEC-90 Alpha pool hookups for materials. --- .../app_settings/shaders/class2/deferred/alphaF.glsl | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 486e806434..111e88c6e9 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -39,7 +39,6 @@ uniform sampler2DShadow shadowMap0; uniform sampler2DShadow shadowMap1; uniform sampler2DShadow shadowMap2; uniform sampler2DShadow shadowMap3; -uniform sampler2DRect depthMap; #if INDEX_MODE != INDEXED uniform sampler2D diffuseMap; @@ -77,10 +76,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; - uniform vec4 specular_color; vec3 calcDirectionalLight(vec3 n, vec3 l) @@ -210,7 +205,6 @@ void main() } #if INDEX_MODE == INDEXED - vec4 diff = diffuseLookup(vary_texcoord0.xy); #else vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); @@ -223,11 +217,7 @@ void main() #endif vec3 normal = vary_norm; - 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])); - + vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); dlight = dlight * vary_directional.rgb * vary_pointlight_col; @@ -260,6 +250,7 @@ void main() color.rgb += diff.rgb * vary_pointlight_col * light_col; - frag_color = color; + frag_color = vec4(1,0,1,1); + //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 --- .../app_settings/shaders/class2/deferred/alphaF.glsl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index e55023c384..69bcca88b5 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -68,7 +68,6 @@ VARYING vec4 vertex_color; uniform mat4 shadow_matrix[6]; uniform vec4 shadow_clip; -uniform vec2 shadow_res; uniform float shadow_bias; uniform mat4 inv_proj; @@ -210,11 +209,11 @@ void main() shadow = 1.0; } -#if INDEX_MODE == INDEXED - - vec4 diff = diffuseLookup(vary_texcoord0.xy); + vec4 diff; +#if INDEX_MODE == INDEXED + diff = diffuseLookup(vary_texcoord0.xy); #else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); + diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif #if INDEX_MODE == NON_INDEXED_NO_COLOR @@ -223,8 +222,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])); @@ -232,7 +230,6 @@ void main() vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); dlight = dlight * vary_directional.rgb * vary_pointlight_col; - vec4 diff = diffuseLookup(vary_texcoord0.xy); vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color_alpha); vec4 color = diff * col; @@ -240,10 +237,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) @@ -253,7 +250,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. --- .../newview/app_settings/shaders/class2/deferred/alphaF.glsl | 2 +- .../newview/app_settings/shaders/class2/deferred/alphaV.glsl | 8 +++++--- .../shaders/class2/deferred/multiSpotLightF.glsl | 8 ++++++-- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 12 +++++++----- .../app_settings/shaders/class2/deferred/spotLightF.glsl | 8 ++++++-- 5 files changed, 25 insertions(+), 13 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 486e806434..df6eb04a62 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -215,7 +215,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 diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 5f2961c90e..db5e5620dc 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -186,17 +186,19 @@ void main() //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - vary_pointlight_col = diffuse_color.rgb; + vec3 dff = pow(diffuse_color.rgb, vec3(2.2)); + + vary_pointlight_col = dff; col.rgb = vec3(0,0,0); // Add windlight lights col.rgb = atmosAmbient(vec3(0.)); - vary_ambient = col.rgb*diffuse_color.rgb; vary_directional.rgb = atmosAffectDirectionalLight(1); + vary_ambient = col.rgb*dff; - col.rgb = col.rgb*diffuse_color.rgb; + col.rgb = col.rgb*dff; #if INDEX_MODE != NON_INDEXED_NO_COLOR vertex_color = col; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index b3ab8fd510..cfdb53b5cc 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -82,6 +82,7 @@ vec3 decode_normal (vec2 enc) vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -97,6 +98,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -114,6 +116,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -193,6 +196,7 @@ void main() vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + diff_tex = pow(diff_tex, vec3(2.2)); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -214,8 +218,6 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; @@ -235,6 +237,8 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); + spec.rgb = pow(spec.rgb, vec3(2.2)); + if (spec.a > 0.0) { vec3 ref = reflect(normalize(pos), norm); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 8e638c64eb..e8f3a02c5a 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -60,6 +60,7 @@ uniform float density_multiplier; uniform float distance_multiplier; uniform float max_y; uniform vec4 glow; +uniform float global_gamma; uniform float scene_light_strength; uniform mat3 env_mat; uniform vec4 shadow_clip; @@ -233,9 +234,9 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { + tmpAmbient))); //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); + setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * 3.3); + setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * 3.3); + setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * 3.3); } vec3 atmosLighting(vec3 light) @@ -293,9 +294,9 @@ void main() float envIntensity = norm.z; norm.xyz = decode_normal(norm.xy); float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - da = pow(da, 0.7); vec4 diffuse = texture2DRect(diffuseRect, tc); + diffuse.rgb = pow(diffuse.rgb, vec3(2.2)); vec3 col; float bloom = 0.0; @@ -303,6 +304,7 @@ void main() if (diffuse.a < 0.9) { vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); + spec.rgb = pow(spec.rgb, vec3(2.2)); vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float scol = max(scol_ambocc.r, diffuse.a); @@ -330,7 +332,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; - col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, + col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2, max(envIntensity-diffuse.a*2.0, 0.0)); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 43fc5dbc5e..7ce327d1e0 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -83,6 +83,7 @@ vec3 decode_normal (vec2 enc) vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -98,6 +99,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -115,6 +117,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -194,6 +197,8 @@ void main() vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + + diff_tex = pow(diff_tex, vec3(2.2)); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -215,8 +220,6 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; lit = da * dist_atten * noise; - - lit = pow(lit, 0.7); col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; @@ -236,6 +239,7 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); + spec.rgb = pow(spec.rgb, vec3(2.2)); if (spec.a > 0.0) { vec3 ref = reflect(normalize(pos), norm); -- cgit v1.2.3 From fc965b3c897140ba794f0ece9ad3e943e79a0fcb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 18 Apr 2013 00:15:18 -0500 Subject: NORSPEC-135 Fix for environment map not showing up if glossiness is zero. --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 8e638c64eb..5fb22c7f4d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -315,11 +315,13 @@ void main() col *= diffuse.rgb; + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + if (spec.a > 0.0) // specular reflection { // the old infinite-sky shiny reflection // - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + float sa = dot(refnormpersp, sun_dir.xyz); vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); @@ -327,8 +329,10 @@ void main() vec3 spec_contrib = dumbshiny * spec.rgb; bloom = dot(spec_contrib, spec_contrib) / 6; col += spec_contrib; + } - //add environmentmap + if (envIntensity > 0.0) + { //add environmentmap vec3 env_vec = env_mat * refnormpersp; col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, max(envIntensity-diffuse.a*2.0, 0.0)); -- 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/class2/deferred/alphaF.glsl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 5faa94fb03..293613e74c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -217,7 +217,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); vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); @@ -244,7 +244,6 @@ void main() color.rgb += diff.rgb * vary_pointlight_col * col.rgb; - frag_color = vec4(1,0,1,1); - //frag_color = color; + frag_color = color; } -- 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 --- .../app_settings/shaders/class2/deferred/alphaF.glsl | 2 +- .../app_settings/shaders/class2/deferred/alphaV.glsl | 18 +----------------- 2 files changed, 2 insertions(+), 18 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 293613e74c..c765962352 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -217,7 +217,7 @@ void main() float vertex_color_alpha = vertex_color.a; #endif - vec3 normal = vec3(0,0,1); + vec3 normal = vary_norm; vec3 l = light_position[0].xyz; vec3 dlight = calcDirectionalLight(normal, l); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 5f2961c90e..63953b37bf 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -40,10 +40,6 @@ void passTextureIndex(); ATTRIBUTE vec3 normal; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec3 binormal; -ATTRIBUTE vec2 texcoord1; -ATTRIBUTE vec2 texcoord2; - #if HAS_SKIN mat4 getObjectSkinnedTransform(); @@ -72,11 +68,8 @@ VARYING vec4 vertex_color; #endif VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; VARYING vec3 vary_norm; -VARYING mat3 vary_rotation; uniform float near_clip; uniform float shadow_offset; @@ -160,8 +153,7 @@ void main() pos = (modelview_matrix * vert); gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); #endif - vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; - vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; + #if INDEX_MODE == INDEXED passTextureIndex(); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; @@ -173,14 +165,6 @@ void main() float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz)); vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset; - vec3 n = norm; - vec3 b = normalize(normal_matrix * binormal); - vec3 t = cross(b, n); - - vary_rotation[0] = vec3(t.x, b.x, n.x); - vary_rotation[1] = vec3(t.y, b.y, n.y); - vary_rotation[2] = vec3(t.z, b.z, n.z); - calcAtmospherics(pos.xyz); //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); -- cgit v1.2.3 From 6b836eacafd21c1ccac2c7276483ed393a4b406e Mon Sep 17 00:00:00 2001 From: Geenz Date: Thu, 18 Apr 2013 19:43:30 -0400 Subject: Use GL_SRGB8_ALPHA8 for the diffuse and specular buffers, and correct gamma *before* glow and other post processing effects that don't care about being gamma correct. --- .../newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 2 -- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 2 -- indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | 3 --- 3 files changed, 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index cfdb53b5cc..31f5c8afbb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -196,7 +196,6 @@ void main() vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; - diff_tex = pow(diff_tex, vec3(2.2)); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -237,7 +236,6 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); - spec.rgb = pow(spec.rgb, vec3(2.2)); if (spec.a > 0.0) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index e8f3a02c5a..c7e5908d39 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -296,7 +296,6 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); - diffuse.rgb = pow(diffuse.rgb, vec3(2.2)); vec3 col; float bloom = 0.0; @@ -304,7 +303,6 @@ void main() if (diffuse.a < 0.9) { vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - spec.rgb = pow(spec.rgb, vec3(2.2)); vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float scol = max(scol_ambocc.r, diffuse.a); diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 7ce327d1e0..65a14c542c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -197,8 +197,6 @@ void main() vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; - - diff_tex = pow(diff_tex, vec3(2.2)); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -239,7 +237,6 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); - spec.rgb = pow(spec.rgb, vec3(2.2)); if (spec.a > 0.0) { vec3 ref = reflect(normalize(pos), norm); -- 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 --- indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl | 7 ------- indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index c765962352..76a045a3bb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -56,10 +56,7 @@ 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; #if INDEX_MODE != NON_INDEXED_NO_COLOR VARYING vec4 vertex_color; @@ -69,15 +66,11 @@ uniform mat4 shadow_matrix[6]; uniform vec4 shadow_clip; uniform float shadow_bias; -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 vec4 specular_color; - vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = pow(max(dot(n,l),0.0), 0.7); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 63953b37bf..44abbdfe54 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -38,7 +38,9 @@ ATTRIBUTE vec3 position; void passTextureIndex(); #endif ATTRIBUTE vec3 normal; +#if INDEX_MODE != NON_INDEXED_NO_COLOR ATTRIBUTE vec4 diffuse_color; +#endif ATTRIBUTE vec2 texcoord0; #if HAS_SKIN @@ -167,6 +169,10 @@ void main() calcAtmospherics(pos.xyz); +#if INDEX_MODE == NON_INDEXED_NO_COLOR + vec4 diffuse_color = vec4(1,1,1,1); +#endif + //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); -- cgit v1.2.3 From b6a6479c372e311b45e27eafd368e2045ca21790 Mon Sep 17 00:00:00 2001 From: Geenz Date: Thu, 18 Apr 2013 21:31:10 -0400 Subject: Mitigation for light attenuation looking different with gamma correction. Assume that light attenuation wants to be linearized before we apply gamma correction. --- indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 1 + indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | 1 + 2 files changed, 2 insertions(+) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 31f5c8afbb..cb8d1f6910 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -184,6 +184,7 @@ void main() float fa = falloff+1.0; float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0); + dist_atten = pow(dist_atten, 2.2) * 2.2; if (dist_atten <= 0.0) { discard; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 65a14c542c..87180fd3e4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -185,6 +185,7 @@ void main() float fa = falloff+1.0; float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0); + dist_atten = pow(dist_atten, 2.2) * 2.2; if (dist_atten <= 0.0) { discard; -- 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/class2/deferred/alphaF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 76a045a3bb..db58c19057 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -203,7 +203,7 @@ void main() #else 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 f9ff68b5e3b016a53fe987e5b51442741ca88f15 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 19 Apr 2013 02:56:15 -0500 Subject: Cleanup specular highlights from spot lights --- .../shaders/class2/deferred/multiSpotLightF.glsl | 77 ++++++++++++---------- 1 file changed, 42 insertions(+), 35 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index cb8d1f6910..cfd50ec1ec 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -82,7 +82,6 @@ vec3 decode_normal (vec2 enc) vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -98,7 +97,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -116,7 +114,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -169,6 +166,9 @@ void main() } vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + + float envIntensity = norm.z; + norm = decode_normal(norm.xy); norm = normalize(norm); @@ -184,7 +184,6 @@ void main() float fa = falloff+1.0; float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0); - dist_atten = pow(dist_atten, 2.2) * 2.2; if (dist_atten <= 0.0) { discard; @@ -197,7 +196,11 @@ void main() vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; - + + vec4 spec = texture2DRect(specularRect, frag.xy); + + + float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && proj_tc.x < 1.0 && @@ -205,11 +208,13 @@ void main() proj_tc.x > 0.0 && proj_tc.y > 0.0) { - float lit = 0.0; float amb_da = proj_ambiance; - + float lit = 0.0; + if (da > 0.0) { + lit = da * dist_atten * noise; + float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); float lod = diff * proj_lod; @@ -217,8 +222,6 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -235,10 +238,36 @@ void main() col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; } + + if (spec.a > 0.0) + { + float lit = da * dist_atten * noise; + vec3 npos = -normalize(pos); + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*color.rgb*spec.rgb*shadow; + //col += spec.rgb; + } + } - vec4 spec = texture2DRect(specularRect, frag.xy); - if (spec.a > 0.0) + + + + if (envIntensity > 0.0) { vec3 ref = reflect(normalize(pos), norm); @@ -256,7 +285,7 @@ void main() { stc.xy /= stc.w; - float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0); + float fatten = clamp(envIntensity*envIntensity+envIntensity*0.5, 0.25, 1.0); //stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); @@ -266,29 +295,7 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - - vec3 npos = -normalize(pos); - lv = pfinal-pos.xyz; - lv = normalize(lv); - - vec3 h = normalize(lv+npos); - float nh = dot(norm, h); - float nv = dot(norm, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; - - float gtdenom = 2 * nh; - float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); - - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb; - } - - //vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - //col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; + col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-envIntensity*proj_lod).rgb*shadow*spec.rgb; } } } -- cgit v1.2.3 From 6881b01ea9f652507cb5dfc5da70458ca80c6d52 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 19 Apr 2013 17:20:52 -0500 Subject: NORSPEC-139 Fix for non-fullscreen spotlight lighting mismatching fullscreen spotlight lighting --- .../shaders/class2/deferred/multiSpotLightF.glsl | 1 + .../shaders/class2/deferred/spotLightF.glsl | 69 +++++++++++++--------- 2 files changed, 41 insertions(+), 29 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index cfd50ec1ec..76da91094c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -184,6 +184,7 @@ void main() float fa = falloff+1.0; float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0); + dist_atten = pow(dist_atten, 2.2) * 2.2; if (dist_atten <= 0.0) { discard; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 87180fd3e4..2cc563ff67 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -41,7 +41,6 @@ uniform sampler2D noiseMap; uniform sampler2D projectionMap; uniform sampler2D lightFunc; - uniform mat4 proj_mat; //screen space to light space uniform float proj_near; //near clip for projection uniform vec3 proj_p; //plane projection is emitting from (in screen space) @@ -83,7 +82,6 @@ vec3 decode_normal (vec2 enc) vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -99,7 +97,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -117,7 +114,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = pow(ret.rgb, vec3(2.2)); vec2 dist = tc-vec2(0.5); @@ -170,6 +166,7 @@ void main() } vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + float envIntensity = norm.z; norm = decode_normal(norm.xy); norm = normalize(norm); @@ -199,6 +196,10 @@ void main() vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + vec4 spec = texture2DRect(specularRect, frag.xy); + + + float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && proj_tc.x < 1.0 && @@ -206,11 +207,13 @@ void main() proj_tc.x > 0.0 && proj_tc.y > 0.0) { - float lit = 0.0; float amb_da = proj_ambiance; + float lit = 0.0; if (da > 0.0) { + lit = da * dist_atten * noise; + float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); float lod = diff * proj_lod; @@ -218,8 +221,6 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; - lit = da * dist_atten * noise; - col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -236,9 +237,36 @@ void main() col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; } - - vec4 spec = texture2DRect(specularRect, frag.xy); + if (spec.a > 0.0) + { + float lit = da * dist_atten * noise; + vec3 npos = -normalize(pos); + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*color.rgb*spec.rgb*shadow; + //col += spec.rgb; + } + } + + + + + + if (envIntensity > 0.0) { vec3 ref = reflect(normalize(pos), norm); @@ -256,8 +284,9 @@ void main() { stc.xy /= stc.w; - float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0); + float fatten = clamp(envIntensity*envIntensity+envIntensity*0.5, 0.25, 1.0); + //stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); if (stc.x < 1.0 && @@ -265,25 +294,7 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - vec3 npos = -normalize(pos); - lv = pfinal-pos.xyz; - lv = normalize(lv); - - vec3 h = normalize(lv+npos); - float nh = dot(norm, h); - float nv = dot(norm, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; - - float gtdenom = 2 * nh; - float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); - - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb; - } + col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-envIntensity*proj_lod).rgb*shadow*spec.rgb; } } } -- 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 --- .../shaders/class2/deferred/alphaF.glsl | 29 +++++------ .../shaders/class2/deferred/alphaV.glsl | 60 +++++++++++++--------- 2 files changed, 49 insertions(+), 40 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index db58c19057..73c85c0419 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/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 @@ -40,7 +36,7 @@ uniform sampler2DShadow shadowMap1; uniform sampler2DShadow shadowMap2; uniform sampler2DShadow shadowMap3; -#if INDEX_MODE != INDEXED +#ifdef USE_DIFFUSE_TEX uniform sampler2D diffuseMap; #endif @@ -58,7 +54,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 @@ -198,20 +194,23 @@ void main() } vec4 diff; -#if INDEX_MODE == INDEXED + +#ifdef USE_INDEXED_TEX diff = diffuseLookup(vary_texcoord0.xy); -#else +#endif + +#ifdef USE_DIFFUSE_TEX diff = texture2D(diffuseMap,vary_texcoord0.xy); #endif - diff.rgb = pow(diff.rgb, vec3(2.2)); -#if INDEX_MODE == NON_INDEXED_NO_COLOR + diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); + float vertex_color_alpha = 1.0; -#else - float vertex_color_alpha = vertex_color.a; + +#ifdef USE_VERTEX_COLOR + 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; @@ -220,9 +219,9 @@ void main() vec4 color = diff * col; color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - col = vec4(0,0,0,0); + + col = vec4(0.0f,0.0f,0.0f,0.0f); #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); diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 46fd8da4f8..127c1709b8 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -23,10 +23,6 @@ * $/LicenseInfo$ */ -#define INDEXED 1 -#define NON_INDEXED 2 -#define NON_INDEXED_NO_COLOR 3 - uniform mat3 normal_matrix; uniform mat4 texture_matrix0; uniform mat4 projection_matrix; @@ -34,25 +30,31 @@ uniform mat4 modelview_matrix; uniform mat4 modelview_projection_matrix; ATTRIBUTE vec3 position; -#if INDEX_MODE == INDEXED + +#ifdef USE_INDEXED_TEX void passTextureIndex(); #endif + ATTRIBUTE vec3 normal; -#if INDEX_MODE != NON_INDEXED_NO_COLOR + +#ifdef USE_VERTEX_COLOR ATTRIBUTE vec4 diffuse_color; #endif + ATTRIBUTE vec2 texcoord0; -#if HAS_SKIN +#ifdef HAS_SKIN mat4 getObjectSkinnedTransform(); -#elif IS_AVATAR_SKIN +#else +#ifdef IS_AVATAR_SKIN mat4 getSkinnedTransform(); #endif +#endif vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); void calcAtmospherics(vec3 inPositionEye); -float calcDirectionalLight(vec3 n, vec3 l); +vec3 calcDirectionalLight(vec3 n, vec3 l); vec3 atmosAmbient(vec3 light); vec3 atmosAffectDirectionalLight(float lightIntensity); @@ -65,12 +67,11 @@ VARYING vec3 vary_fragcoord; VARYING vec3 vary_position; VARYING vec3 vary_pointlight_col; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR VARYING vec4 vertex_color; #endif VARYING vec2 vary_texcoord0; - VARYING vec3 vary_norm; uniform float near_clip; @@ -82,13 +83,13 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; -float calcDirectionalLight(vec3 n, vec3 l) +vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); - 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; @@ -115,7 +116,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa da *= max(dot(n, lv), 0.0); } - return da; + return vec3(da,da,da); } void main() @@ -124,7 +125,7 @@ void main() vec3 norm; //transform vertex -#if HAS_SKIN +#ifdef HAS_SKIN mat4 trans = getObjectSkinnedTransform(); trans = modelview_matrix * trans; @@ -134,7 +135,9 @@ void main() norm = normalize((trans * vec4(norm, 1.0)).xyz - pos.xyz); vec4 frag_pos = projection_matrix * pos; gl_Position = frag_pos; -#elif IS_AVATAR_SKIN +#else + +#ifdef IS_AVATAR_SKIN mat4 trans = getSkinnedTransform(); vec4 pos_in = vec4(position.xyz, 1.0); pos.x = dot(trans[0], pos_in); @@ -156,7 +159,9 @@ void main() gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); #endif -#if INDEX_MODE == INDEXED +#endif + +#ifdef USE_INDEXED_TEX passTextureIndex(); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; #else @@ -169,37 +174,42 @@ void main() calcAtmospherics(pos.xyz); -#if INDEX_MODE == NON_INDEXED_NO_COLOR +#ifndef USE_VERTEX_COLOR vec4 diffuse_color = vec4(1,1,1,1); #endif //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.)); vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a); - vec3 dff = pow(diffuse_color.rgb, vec3(2.2)); + vec3 dff = pow(diffuse_color.rgb, vec3(2.2f,2.2f,2.2f)); vary_pointlight_col = dff; col.rgb = vec3(0,0,0); // Add windlight lights - col.rgb = atmosAmbient(vec3(0.)); + col.rgb = atmosAmbient(col.rgb); - vary_directional.rgb = atmosAffectDirectionalLight(1); + vary_directional.rgb = atmosAffectDirectionalLight(1.0f); vary_ambient = col.rgb*dff; col.rgb = col.rgb*dff; -#if INDEX_MODE != NON_INDEXED_NO_COLOR +#ifdef USE_VERTEX_COLOR vertex_color = col; #endif -#if HAS_SKIN +#ifdef HAS_SKIN vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip); -#elif IS_AVATAR_SKIN +#else + +#ifdef IS_AVATAR_SKIN vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); #else pos = modelview_projection_matrix * vert; vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); #endif + +#endif + } -- cgit v1.2.3 From 4102d3fb06c42846796cccb39a03d520c90b325c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 25 Apr 2013 16:03:19 -0500 Subject: NORSPEC-106 Fix for emissive mask overriding environment mask. --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 3d39394c32..466714c108 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -300,7 +300,6 @@ void main() vec3 col; float bloom = 0.0; - if (diffuse.a < 0.9) { vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); @@ -331,22 +330,19 @@ void main() col += spec_contrib; } + col = mix(col, diffuse.rgb, diffuse.a); + if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2, - max(envIntensity-diffuse.a*2.0, 0.0)); + envIntensity); } col = atmosLighting(col); col = scaleSoftClip(col); - - col = mix(col, diffuse.rgb, diffuse.a); - } - else - { - col = diffuse.rgb; } + frag_color.rgb = col; frag_color.a = bloom; -- 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. --- .../shaders/class2/deferred/multiSpotLightF.glsl | 9 ++++----- .../shaders/class2/deferred/softenLightF.glsl | 8 ++++---- .../shaders/class2/deferred/spotLightF.glsl | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 76da91094c..9ddbb6da6a 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -200,7 +200,7 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); - + vec3 dlit = vec3(0, 0, 0); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -221,9 +221,9 @@ void main() vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); - vec3 lcol = color.rgb * plcol.rgb * plcol.a; + dlit = color.rgb * plcol.rgb * plcol.a; - col = lcol*lit*diff_tex*shadow; + col = dlit*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -242,7 +242,6 @@ void main() if (spec.a > 0.0) { - float lit = da * dist_atten * noise; vec3 npos = -normalize(pos); //vec3 ref = dot(pos+lv, norm); @@ -259,7 +258,7 @@ void main() if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb*shadow; + col += dlit*scol*spec.rgb*shadow; //col += spec.rgb; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 3d39394c32..f95fe59be2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -234,9 +234,9 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { + tmpAmbient))); //brightness of surface both sunlight and ambient - setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * 3.3); - setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * 3.3); - setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * 3.3); + setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * global_gamma); + setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * global_gamma); + setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * global_gamma); } vec3 atmosLighting(vec3 light) @@ -311,7 +311,7 @@ void main() calcAtmospherics(pos.xyz, ambocc); col = atmosAmbient(vec3(0)); - col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); + col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, diffuse.a)); col *= diffuse.rgb; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 2cc563ff67..aa964fa0a3 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -79,9 +79,15 @@ vec3 decode_normal (vec2 enc) return n; } +vec4 correctWithGamma(vec4 col) +{ + return vec4(pow(col.rgb, vec3(2.2)), col.a); +} + vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -97,6 +103,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -114,6 +121,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -198,7 +206,7 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); - + vec3 dlit = vec3(0, 0, 0); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -219,9 +227,9 @@ void main() vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); - vec3 lcol = color.rgb * plcol.rgb * plcol.a; + dlit = color.rgb * plcol.rgb * plcol.a; - col = lcol*lit*diff_tex*shadow; + col = dlit*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -240,7 +248,6 @@ void main() if (spec.a > 0.0) { - float lit = da * dist_atten * noise; vec3 npos = -normalize(pos); //vec3 ref = dot(pos+lv, norm); @@ -257,7 +264,7 @@ void main() if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb*shadow; + col += dlit*scol*spec.rgb*shadow; //col += spec.rgb; } } -- 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/class2/deferred/alphaF.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 73c85c0419..13b629a6c8 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -223,8 +223,7 @@ void main() col = vec4(0.0f,0.0f,0.0f,0.0f); - #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/class2/deferred/alphaF.glsl | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 13b629a6c8..d2e85ba8a0 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -91,6 +91,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 --- .../app_settings/shaders/class2/deferred/alphaF.glsl | 3 +-- .../shaders/class2/deferred/multiSpotLightF.glsl | 9 ++++----- .../shaders/class2/deferred/softenLightF.glsl | 8 ++++---- .../shaders/class2/deferred/spotLightF.glsl | 17 ++++++++++++----- 4 files changed, 21 insertions(+), 16 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 73c85c0419..13b629a6c8 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -223,8 +223,7 @@ void main() col = vec4(0.0f,0.0f,0.0f,0.0f); - #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) diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 76da91094c..9ddbb6da6a 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -200,7 +200,7 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); - + vec3 dlit = vec3(0, 0, 0); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -221,9 +221,9 @@ void main() vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); - vec3 lcol = color.rgb * plcol.rgb * plcol.a; + dlit = color.rgb * plcol.rgb * plcol.a; - col = lcol*lit*diff_tex*shadow; + col = dlit*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -242,7 +242,6 @@ void main() if (spec.a > 0.0) { - float lit = da * dist_atten * noise; vec3 npos = -normalize(pos); //vec3 ref = dot(pos+lv, norm); @@ -259,7 +258,7 @@ void main() if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb*shadow; + col += dlit*scol*spec.rgb*shadow; //col += spec.rgb; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 466714c108..15584548cc 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -234,9 +234,9 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { + tmpAmbient))); //brightness of surface both sunlight and ambient - setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * 3.3); - setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * 3.3); - setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * 3.3); + setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * global_gamma); + setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * global_gamma); + setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * global_gamma); } vec3 atmosLighting(vec3 light) @@ -310,7 +310,7 @@ void main() calcAtmospherics(pos.xyz, ambocc); col = atmosAmbient(vec3(0)); - col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); + col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, diffuse.a)); col *= diffuse.rgb; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 2cc563ff67..aa964fa0a3 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -79,9 +79,15 @@ vec3 decode_normal (vec2 enc) return n; } +vec4 correctWithGamma(vec4 col) +{ + return vec4(pow(col.rgb, vec3(2.2)), col.a); +} + vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -97,6 +103,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -114,6 +121,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -198,7 +206,7 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); - + vec3 dlit = vec3(0, 0, 0); float noise = texture2D(noiseMap, frag.xy/128.0).b; if (proj_tc.z > 0.0 && @@ -219,9 +227,9 @@ void main() vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); - vec3 lcol = color.rgb * plcol.rgb * plcol.a; + dlit = color.rgb * plcol.rgb * plcol.a; - col = lcol*lit*diff_tex*shadow; + col = dlit*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -240,7 +248,6 @@ void main() if (spec.a > 0.0) { - float lit = da * dist_atten * noise; vec3 npos = -normalize(pos); //vec3 ref = dot(pos+lv, norm); @@ -257,7 +264,7 @@ void main() if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb*shadow; + col += dlit*scol*spec.rgb*shadow; //col += spec.rgb; } } -- cgit v1.2.3 From 0938ce04f7d12439740285b61db3dd0bdadebb4f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 May 2013 16:42:07 -0500 Subject: Fix up specular highlights and gamma correction for projectors. --- .../shaders/class2/deferred/multiSpotLightF.glsl | 16 +++++++++++++--- .../app_settings/shaders/class2/deferred/spotLightF.glsl | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 9ddbb6da6a..a6b0f7e7c1 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -79,10 +79,17 @@ vec3 decode_normal (vec2 enc) return n; } +vec4 correctWithGamma(vec4 col) +{ + return vec4(pow(col.rgb, vec3(2.2)), col.a); +} + + vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - + ret = correctWithGamma(ret); + vec2 dist = tc-vec2(0.5); float det = max(1.0-lod/(proj_lod*0.5), 0.0); @@ -97,7 +104,8 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - + ret = correctWithGamma(ret); + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); float det = min(lod/(proj_lod*0.5), 1.0); @@ -114,7 +122,8 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - + ret = correctWithGamma(ret); + vec2 dist = tc-vec2(0.5); float d = dot(dist,dist); @@ -243,6 +252,7 @@ void main() if (spec.a > 0.0) { vec3 npos = -normalize(pos); + dlit *= min(da*6.0, 1.0) * dist_atten; //vec3 ref = dot(pos+lv, norm); vec3 h = normalize(lv+npos); diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index aa964fa0a3..91ff1f1e76 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -248,6 +248,7 @@ void main() if (spec.a > 0.0) { + dlit *= min(da*6.0, 1.0) * dist_atten; vec3 npos = -normalize(pos); //vec3 ref = dot(pos+lv, norm); -- cgit v1.2.3 From 73404da266ffd5560d6faef5243d45c3478c1d6e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 May 2013 16:48:27 -0500 Subject: Fix for sky being too bright with advanced lighting enabled --- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 15584548cc..10a598a85c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -330,8 +330,6 @@ void main() col += spec_contrib; } - col = mix(col, diffuse.rgb, diffuse.a); - if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; @@ -341,6 +339,8 @@ void main() col = atmosLighting(col); col = scaleSoftClip(col); + + col = mix(col.rgb, diffuse.rgb, diffuse.a); } -- 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/class2/deferred/alphaF.glsl | 241 --------------------- 1 file changed, 241 deletions(-) delete mode 100644 indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl deleted file mode 100644 index d2e85ba8a0..0000000000 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ /dev/null @@ -1,241 +0,0 @@ -/** - * @file alphaF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#extension GL_ARB_texture_rectangle : enable - -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif - -uniform sampler2DShadow shadowMap0; -uniform sampler2DShadow shadowMap1; -uniform sampler2DShadow shadowMap2; -uniform sampler2DShadow shadowMap3; - -#ifdef USE_DIFFUSE_TEX -uniform sampler2D diffuseMap; -#endif - -uniform vec2 screen_res; -uniform vec2 shadow_res; - -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 vec2 vary_texcoord0; -VARYING vec3 vary_norm; - -#ifdef USE_VERTEX_COLOR -VARYING vec4 vertex_color; -#endif - -uniform mat4 shadow_matrix[6]; -uniform vec4 shadow_clip; -uniform float shadow_bias; - -uniform vec4 light_position[8]; -uniform vec3 light_direction[8]; -uniform vec3 light_attenuation[8]; -uniform vec3 light_diffuse[8]; - -vec3 calcDirectionalLight(vec3 n, vec3 l) -{ - float a = pow(max(dot(n,l),0.0), 0.7); - return vec3(a,a,a); -} - -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; - - //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); - da = pow(da, 2.2) * 2.2; - - // 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.7), 0.0); - } - - return vec3(da,da,da); -} - -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; -} - - -void main() -{ - vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; - frag *= screen_res; - - float shadow = 0.0; - vec4 pos = vec4(vary_position, 1.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; - } - - vec4 diff; - -#ifdef USE_INDEXED_TEX - diff = diffuseLookup(vary_texcoord0.xy); -#endif - -#ifdef USE_DIFFUSE_TEX - diff = texture2D(diffuseMap,vary_texcoord0.xy); -#endif - diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f)); - - float vertex_color_alpha = 1.0; - -#ifdef USE_VERTEX_COLOR - 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; - - vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color_alpha); - vec4 color = diff * col; - - color.rgb = atmosLighting(color.rgb); - color.rgb = scaleSoftClip(color.rgb); - - col = vec4(0.0f,0.0f,0.0f,0.0f); - - #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) - LIGHT_LOOP(3) - LIGHT_LOOP(4) - LIGHT_LOOP(5) - LIGHT_LOOP(6) - LIGHT_LOOP(7) - - color.rgb += diff.rgb * vary_pointlight_col * col.rgb; - - frag_color = color; -} - -- cgit v1.2.3 From b5ecd3865728e048be8bf394fc8d1a06a317d88f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 May 2013 17:11:47 -0500 Subject: Fix for bad light map generation/sampling. --- .../app_settings/shaders/class2/deferred/sunLightF.glsl | 13 +++++-------- .../app_settings/shaders/class2/deferred/sunLightSSAOF.glsl | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 1e835ae49e..fa2f415e15 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -136,11 +136,9 @@ void main() vec4 pos = getPosition(pos_screen); - vec4 nmap4 = texture2DRect(normalMap, pos_screen); - nmap4 = vec4(decode_normal(nmap4.xy),nmap4.w); // unpack norm - float displace = nmap4.w; - vec3 norm = nmap4.xyz; - + vec3 norm = texture2DRect(normalMap, pos_screen).xyz; + norm = decode_normal(norm.xy); // unpack norm + /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL { frag_color = vec4(0.0); // doesn't matter @@ -149,9 +147,8 @@ void main() float shadow = 0.0; float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); - dp_directional_light = pow(dp_directional_light, 0.7); - - vec3 shadow_pos = pos.xyz + displace*norm; + + vec3 shadow_pos = pos.xyz; vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index a995e9cba1..847fea6c08 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -197,11 +197,9 @@ void main() vec4 pos = getPosition(pos_screen); - vec4 nmap4 = texture2DRect(normalMap, pos_screen); - nmap4 = vec4(decode_normal(nmap4.xy),nmap4.w); // unpack norm - float displace = nmap4.w; - vec3 norm = nmap4.xyz; - + vec3 norm = texture2DRect(normalMap, pos_screen).xyz; + norm = decode_normal(norm.xy); // unpack norm + /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL { frag_color = vec4(0.0); // doesn't matter @@ -210,9 +208,8 @@ void main() float shadow = 0.0; float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); - dp_directional_light = pow(dp_directional_light, 0.7); - - vec3 shadow_pos = pos.xyz + displace*norm; + + vec3 shadow_pos = pos.xyz; vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); -- cgit v1.2.3 From e6c2a7652952f60f26cdee4484128c45340240ee Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 17 May 2013 12:19:08 -0500 Subject: NORSPEC-187 Directional ambient work in progress. --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 10a598a85c..ee6aaddb00 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -296,7 +296,7 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); - + vec3 col; float bloom = 0.0; @@ -310,6 +310,14 @@ void main() calcAtmospherics(pos.xyz, ambocc); col = atmosAmbient(vec3(0)); + + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0-ambient); + + col *= ambient; + col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, diffuse.a)); col *= diffuse.rgb; -- cgit v1.2.3 From 88a42cd453b19e66551a36d635981da5aaa04933 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 17 May 2013 13:54:58 -0500 Subject: NORSPEC-187 Add directionality to ambient lighting. --- indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl index 127c1709b8..13c6ffc607 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl @@ -83,6 +83,8 @@ uniform vec3 light_direction[8]; uniform vec3 light_attenuation[8]; uniform vec3 light_diffuse[8]; +uniform vec3 sun_dir; + vec3 calcDirectionalLight(vec3 n, vec3 l) { float a = max(dot(n,l),0.0); @@ -190,6 +192,13 @@ void main() // Add windlight lights col.rgb = atmosAmbient(col.rgb); + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); + ambient *= 0.5; + ambient *= ambient; + ambient = (1.0-ambient); + + col.rgb *= ambient; + vary_directional.rgb = atmosAffectDirectionalLight(1.0f); vary_ambient = col.rgb*dff; -- cgit v1.2.3 From 743d1a777e5c2827d50051c3f5e0942a870a6ff9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 May 2013 18:48:09 -0500 Subject: NORSPEC-198, NORSPEC-176, NORSPEC-106, NORSPEC-202 et al -- Material matrix testing based overhaul WIP Reviewed by Graham --- .../shaders/class2/deferred/softenLightF.glsl | 67 +++++++++++++++------- 1 file changed, 47 insertions(+), 20 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index ee6aaddb00..31b2a32f7f 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -38,7 +38,6 @@ uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; uniform samplerCube environmentMap; uniform sampler2D lightFunc; -uniform vec3 gi_quad; uniform float blur_size; uniform float blur_fidelity; @@ -66,11 +65,7 @@ uniform mat3 env_mat; uniform vec4 shadow_clip; uniform mat3 ssao_effect_mat; -uniform mat4 inv_proj; -uniform vec2 screen_res; - uniform vec3 sun_dir; - VARYING vec2 vary_fragcoord; vec3 vary_PositionEye; @@ -80,6 +75,9 @@ vec3 vary_AmblitColor; vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; +uniform mat4 inv_proj; +uniform vec2 screen_res; + vec3 decode_normal (vec2 enc) { vec2 fenc = enc*4-2; @@ -130,7 +128,6 @@ vec3 getAtmosAttenuation() return vary_AtmosAttenuation; } - void setPositionEye(vec3 v) { vary_PositionEye = v; @@ -251,6 +248,15 @@ vec3 atmosTransport(vec3 light) { light += getAdditiveColor() * 2.0; 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 atmosGetDiffuseSunlightColor() { return getSunlitColor(); @@ -285,6 +291,13 @@ vec3 scaleSoftClip(vec3 light) return light; } + +vec3 fullbrightScaleSoftClip(vec3 light) +{ + //soft clip effect: + return light; +} + void main() { vec2 tc = vary_fragcoord.xy; @@ -292,14 +305,14 @@ void main() vec3 pos = getPosition_d(tc, depth).xyz; vec4 norm = texture2DRect(normalMap, tc); float envIntensity = norm.z; - norm.xyz = decode_normal(norm.xy); + norm.xyz = decode_normal(norm.xy); // unpack norm + float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); vec4 diffuse = texture2DRect(diffuseRect, tc); vec3 col; float bloom = 0.0; - { vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); @@ -310,15 +323,14 @@ void main() calcAtmospherics(pos.xyz, ambocc); col = atmosAmbient(vec3(0)); - float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); - col *= ambient; + col.rgb *= ambient; - col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, diffuse.a)); + col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, 0.0)); col *= diffuse.rgb; @@ -331,27 +343,42 @@ void main() float sa = dot(refnormpersp, sun_dir.xyz); vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); - + // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; bloom = dot(spec_contrib, spec_contrib) / 6; col += spec_contrib; } - + + + col = mix(col.rgb, pow(diffuse.rgb, vec3(1.0/2.2)), diffuse.a); + + if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; - col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2, - envIntensity); - } - col = atmosLighting(col); - col = scaleSoftClip(col); + float exponent = mix(2.2, 1.0, diffuse.a); + vec3 refcol = pow(textureCube(environmentMap, env_vec).rgb, vec3(exponent))*exponent; + + col = mix(col.rgb, refcol, + envIntensity); + + } - col = mix(col.rgb, diffuse.rgb, diffuse.a); + float exponent = mix(1.0, 2.2, diffuse.a); + col = pow(col, vec3(exponent)); + + if (norm.w < 0.5) + { + col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); + } + + //col = vec3(1,0,1); + //col.g = envIntensity; } - frag_color.rgb = col; frag_color.a = bloom; } -- cgit v1.2.3 From c120feb18d2b98abf6071846d2806da16b710632 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sun, 9 Jun 2013 06:12:11 -0700 Subject: NORSPEC-246 WIP fix handling of encoded normals with single FP only cards --- .../shaders/class2/deferred/multiSpotLightF.glsl | 46 +++++++++++++++++----- .../shaders/class2/deferred/softenLightF.glsl | 46 +++++++++++++++++----- .../shaders/class2/deferred/spotLightF.glsl | 46 +++++++++++++++++----- .../shaders/class2/deferred/sunLightF.glsl | 46 +++++++++++++++++----- .../shaders/class2/deferred/sunLightSSAOF.glsl | 46 +++++++++++++++++----- 5 files changed, 180 insertions(+), 50 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index a6b0f7e7c1..f7023be150 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -68,16 +68,42 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + float f = sqrt(2 * n.z + 2); + return (n.xy / vec2(f)) + vec2(0.5f); +} + +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc - 0.5f; + float f = dot(fenc,fenc); + f = clamp(f,0.0f,1.0f); + float g = sqrt(1-f); + vec3 n; + n.xy = fenc*g; + n.z = 1.0f - (f * 0.5f); + return normalize(n); +} +#else +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; +} +#endif vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 31b2a32f7f..6e35641277 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,16 +78,42 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + float f = sqrt(2 * n.z + 2); + return (n.xy / vec2(f)) + vec2(0.5f); +} + +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc - 0.5f; + float f = dot(fenc,fenc); + f = clamp(f,0.0f,1.0f); + float g = sqrt(1-f); + vec3 n; + n.xy = fenc*g; + n.z = 1.0f - (f * 0.5f); + return normalize(n); +} +#else +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; +} +#endif vec4 getPosition_d(vec2 pos_screen, float depth) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 91ff1f1e76..0436c80710 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -68,16 +68,42 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + float f = sqrt(2 * n.z + 2); + return (n.xy / vec2(f)) + vec2(0.5f); +} + +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc - 0.5f; + float f = dot(fenc,fenc); + f = clamp(f,0.0f,1.0f); + float g = sqrt(1-f); + vec3 n; + n.xy = fenc*g; + n.z = 1.0f - (f * 0.5f); + return normalize(n); +} +#else +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; +} +#endif vec4 correctWithGamma(vec4 col) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index fa2f415e15..640701572d 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -65,16 +65,42 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + float f = sqrt(2 * n.z + 2); + return (n.xy / vec2(f)) + vec2(0.5f); +} + +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc - 0.5f; + float f = dot(fenc,fenc); + f = clamp(f,0.0f,1.0f); + float g = sqrt(1-f); + vec3 n; + n.xy = fenc*g; + n.z = 1.0f - (f * 0.5f); + return normalize(n); +} +#else +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; +} +#endif vec4 getPosition(vec2 pos_screen) { diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 847fea6c08..6db26cec4c 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -66,16 +66,42 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + float f = sqrt(2 * n.z + 2); + return (n.xy / vec2(f)) + vec2(0.5f); +} + +vec3 decode_normal (vec2 enc) +{ + vec2 fenc = enc - 0.5f; + float f = dot(fenc,fenc); + f = clamp(f,0.0f,1.0f); + float g = sqrt(1-f); + vec3 n; + n.xy = fenc*g; + n.z = 1.0f - (f * 0.5f); + return normalize(n); +} +#else +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; +} +#endif vec4 getPosition(vec2 pos_screen) { -- cgit v1.2.3 From 33a2608da5a85b01acbfcced10128a2c42760928 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sun, 9 Jun 2013 20:55:02 -0700 Subject: NORSPEC-246 fix issues with normal encoding on precision-deprived hardware and remove haxors --- .../shaders/class2/deferred/multiSpotLightF.glsl | 16 ++++++---------- .../shaders/class2/deferred/softenLightF.glsl | 16 ++++++---------- .../app_settings/shaders/class2/deferred/spotLightF.glsl | 16 ++++++---------- .../app_settings/shaders/class2/deferred/sunLightF.glsl | 16 ++++++---------- .../shaders/class2/deferred/sunLightSSAOF.glsl | 16 ++++++---------- 5 files changed, 30 insertions(+), 50 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index f7023be150..db60c8ea51 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -71,20 +71,16 @@ uniform mat4 inv_proj; #ifdef SINGLE_FP_ONLY vec2 encode_normal(vec3 n) { - float f = sqrt(2 * n.z + 2); - return (n.xy / vec2(f)) + vec2(0.5f); + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); } vec3 decode_normal (vec2 enc) { - vec2 fenc = enc - 0.5f; - float f = dot(fenc,fenc); - f = clamp(f,0.0f,1.0f); - float g = sqrt(1-f); - vec3 n; - n.xy = fenc*g; - n.z = 1.0f - (f * 0.5f); - return normalize(n); + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; } #else vec2 encode_normal(vec3 n) diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 6e35641277..08b456dd96 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -81,20 +81,16 @@ uniform vec2 screen_res; #ifdef SINGLE_FP_ONLY vec2 encode_normal(vec3 n) { - float f = sqrt(2 * n.z + 2); - return (n.xy / vec2(f)) + vec2(0.5f); + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); } vec3 decode_normal (vec2 enc) { - vec2 fenc = enc - 0.5f; - float f = dot(fenc,fenc); - f = clamp(f,0.0f,1.0f); - float g = sqrt(1-f); - vec3 n; - n.xy = fenc*g; - n.z = 1.0f - (f * 0.5f); - return normalize(n); + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; } #else vec2 encode_normal(vec3 n) diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 0436c80710..4fc9a6ad87 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -71,20 +71,16 @@ uniform mat4 inv_proj; #ifdef SINGLE_FP_ONLY vec2 encode_normal(vec3 n) { - float f = sqrt(2 * n.z + 2); - return (n.xy / vec2(f)) + vec2(0.5f); + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); } vec3 decode_normal (vec2 enc) { - vec2 fenc = enc - 0.5f; - float f = dot(fenc,fenc); - f = clamp(f,0.0f,1.0f); - float g = sqrt(1-f); - vec3 n; - n.xy = fenc*g; - n.z = 1.0f - (f * 0.5f); - return normalize(n); + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; } #else vec2 encode_normal(vec3 n) diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 640701572d..c1ed32f7e7 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -68,20 +68,16 @@ uniform float spot_shadow_offset; #ifdef SINGLE_FP_ONLY vec2 encode_normal(vec3 n) { - float f = sqrt(2 * n.z + 2); - return (n.xy / vec2(f)) + vec2(0.5f); + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); } vec3 decode_normal (vec2 enc) { - vec2 fenc = enc - 0.5f; - float f = dot(fenc,fenc); - f = clamp(f,0.0f,1.0f); - float g = sqrt(1-f); - vec3 n; - n.xy = fenc*g; - n.z = 1.0f - (f * 0.5f); - return normalize(n); + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; } #else vec2 encode_normal(vec3 n) diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 6db26cec4c..8a029109a6 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -69,20 +69,16 @@ uniform float spot_shadow_offset; #ifdef SINGLE_FP_ONLY vec2 encode_normal(vec3 n) { - float f = sqrt(2 * n.z + 2); - return (n.xy / vec2(f)) + vec2(0.5f); + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); } vec3 decode_normal (vec2 enc) { - vec2 fenc = enc - 0.5f; - float f = dot(fenc,fenc); - f = clamp(f,0.0f,1.0f); - float g = sqrt(1-f); - vec3 n; - n.xy = fenc*g; - n.z = 1.0f - (f * 0.5f); - return normalize(n); + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; } #else vec2 encode_normal(vec3 n) -- cgit v1.2.3 From df3df9de4fb47cf00f51f5bcaab82ac4ca48bf74 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Sun, 9 Jun 2013 21:12:40 -0700 Subject: NORSPEC-246 fix shader compile errors from missing return --- indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl | 1 + indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 1 + indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl | 1 + indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl | 1 + indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl | 1 + 5 files changed, 5 insertions(+) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index db60c8ea51..2300487a90 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -73,6 +73,7 @@ vec2 encode_normal(vec3 n) { vec2 sn; sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; } vec3 decode_normal (vec2 enc) diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 08b456dd96..520b3bbd47 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -83,6 +83,7 @@ vec2 encode_normal(vec3 n) { vec2 sn; sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; } vec3 decode_normal (vec2 enc) diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 4fc9a6ad87..9e062e46d7 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -73,6 +73,7 @@ vec2 encode_normal(vec3 n) { vec2 sn; sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; } vec3 decode_normal (vec2 enc) diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index c1ed32f7e7..334baad8b4 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -70,6 +70,7 @@ vec2 encode_normal(vec3 n) { vec2 sn; sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; } vec3 decode_normal (vec2 enc) diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 8a029109a6..cfce215faf 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -71,6 +71,7 @@ vec2 encode_normal(vec3 n) { vec2 sn; sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; } vec3 decode_normal (vec2 enc) -- cgit v1.2.3 From 1f2125cc1263bda3352e195654f963777d9926a6 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 13 Jun 2013 11:45:54 -0400 Subject: correct DOS line endings --- .../shaders/class2/deferred/multiSpotLightF.glsl | 64 +++++++++++----------- .../shaders/class2/deferred/softenLightF.glsl | 64 +++++++++++----------- .../shaders/class2/deferred/spotLightF.glsl | 64 +++++++++++----------- .../shaders/class2/deferred/sunLightF.glsl | 64 +++++++++++----------- .../shaders/class2/deferred/sunLightSSAOF.glsl | 64 +++++++++++----------- 5 files changed, 160 insertions(+), 160 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred') diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 2300487a90..eaacb93cb9 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -68,38 +68,38 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; +} + +vec3 decode_normal (vec2 enc) +{ + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; +} +#else +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; +} #endif vec4 correctWithGamma(vec4 col) diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 520b3bbd47..4fe2f1551e 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,38 +78,38 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; +} + +vec3 decode_normal (vec2 enc) +{ + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; +} +#else +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; +} #endif vec4 getPosition_d(vec2 pos_screen, float depth) diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 9e062e46d7..bdb713d682 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -68,38 +68,38 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; +} + +vec3 decode_normal (vec2 enc) +{ + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; +} +#else +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; +} #endif vec4 correctWithGamma(vec4 col) diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 334baad8b4..7b09dd29dd 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -65,38 +65,38 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; +} + +vec3 decode_normal (vec2 enc) +{ + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; +} +#else +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; +} #endif vec4 getPosition(vec2 pos_screen) diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index cfce215faf..01e34ed792 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -66,38 +66,38 @@ uniform float shadow_offset; uniform float spot_shadow_bias; uniform float spot_shadow_offset; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else -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; -} +#ifdef SINGLE_FP_ONLY +vec2 encode_normal(vec3 n) +{ + vec2 sn; + sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); + return sn; +} + +vec3 decode_normal (vec2 enc) +{ + vec3 n; + n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); + n.z = sqrt(1.0f - dot(n.xy,n.xy)); + return n; +} +#else +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; +} #endif vec4 getPosition(vec2 pos_screen) -- cgit v1.2.3