From b7aa0ce2446dfa586f4727d537cdf02fb643fbe9 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 28 Jan 2010 18:01:12 -0800 Subject: enable basic directional lighting for basic/atmospheric shaders - yay. next, needs the non-shader GL lighting model to be equally dumb (it's too smart - kill the spot angle. --- .../shaders/class1/lighting/lightFuncV.glsl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 3e8fdfb3e4..211de830fa 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -28,7 +28,28 @@ float calcPointLight(vec3 v, vec3 n, vec4 lp, float la) //angular attenuation da *= calcDirectionalLight(n, lv); + + return da; +} + + +float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la) +{ + //get light vector + vec3 lv = lp.xyz-v; + //get distance + float d = length(lv); + + //normalize light vector + lv *= 1.0/d; + + //distance attenuation + float da = clamp(1.0/(la * d), 0.0, 1.0); + + //angular attenuation + da *= dot(lv, -ln) * calcDirectionalLight(n, lv); + return da; } -- cgit v1.2.3 From 4c8266e0a25648cb346400119b0c5ad96de0627c Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 28 Jan 2010 18:36:04 -0800 Subject: fix the shader dp light going negative! --- indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 211de830fa..0f03e336be 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la) float da = clamp(1.0/(la * d), 0.0, 1.0); //angular attenuation - da *= dot(lv, -ln) * calcDirectionalLight(n, lv); + da *= calcDirectionalLight(-ln, lv) * calcDirectionalLight(n, lv); return da; } -- cgit v1.2.3 From ae75d7b9dc3bac4a77068a3c7551ff70e8759a44 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 28 Jan 2010 18:50:10 -0800 Subject: cheaply resurrect the difference between spotlight and omnidirectional, as far as the shader is concerned. not complete. --- indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 0f03e336be..b2d6d23b1e 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -33,7 +33,7 @@ float calcPointLight(vec3 v, vec3 n, vec4 lp, float la) } -float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la) +float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional) { //get light vector vec3 lv = lp.xyz-v; @@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la) float da = clamp(1.0/(la * d), 0.0, 1.0); //angular attenuation - da *= calcDirectionalLight(-ln, lv) * calcDirectionalLight(n, lv); + da *= clamp(dot(-ln, lv)+is_omnidirectional, 0.0, 1.0) * calcDirectionalLight(n, lv); return da; } -- cgit v1.2.3 From 5a1cf512e9f7dbb3b95542bba1f5019e4cd4f9cd Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 28 Jan 2010 21:49:31 -0800 Subject: cheaper, cuter way to deal with spot vs point in the shader --- indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index b2d6d23b1e..4525bf80b2 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -48,7 +48,7 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnid float da = clamp(1.0/(la * d), 0.0, 1.0); //angular attenuation - da *= clamp(dot(-ln, lv)+is_omnidirectional, 0.0, 1.0) * calcDirectionalLight(n, lv); + da *= max(dot(-ln, lv),is_omnidirectional) * calcDirectionalLight(n, lv); return da; } -- cgit v1.2.3 From 7e7331c0e5213ecfe4f563786239e497c197c630 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 28 Jan 2010 23:58:50 -0800 Subject: cheap no-branch goodness for rendering both spotlights and pointlights with the same shader code. kill already-nerfed quadratic attenuation which it seems we won't be supporting any decade soon. --- indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 4525bf80b2..2e41f24afe 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -47,8 +47,12 @@ float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnid //distance attenuation float da = clamp(1.0/(la * d), 0.0, 1.0); + // spotlight coefficient. + float spot = max(dot(-ln, lv), is_omnidirectional); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + //angular attenuation - da *= max(dot(-ln, lv),is_omnidirectional) * calcDirectionalLight(n, lv); + da *= calcDirectionalLight(n, lv); return da; } -- cgit v1.2.3 From a831136347eebc92019c121c5834a7e0fe629eef Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 29 Jan 2010 00:22:13 -0800 Subject: spot-aware light func usage in ALL shaders. --- .../shaders/class1/lighting/lightFuncV.glsl | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 2e41f24afe..d0f58cc1a4 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -12,28 +12,8 @@ float calcDirectionalLight(vec3 n, vec3 l) return a; } -float calcPointLight(vec3 v, vec3 n, vec4 lp, float la) -{ - //get light vector - vec3 lv = lp.xyz-v; - - //get distance - float d = length(lv); - - //normalize light vector - lv *= 1.0/d; - - //distance attenuation - float da = clamp(1.0/(la * d), 0.0, 1.0); - - //angular attenuation - da *= calcDirectionalLight(n, lv); - - return da; -} - -float calcPointLight2(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_omnidirectional) +float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; -- cgit v1.2.3 From fcfcb1860dd6e6fcfd85e4e242011637193f232f Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 29 Jan 2010 00:57:28 -0800 Subject: duh, use the proper param name. --- indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index d0f58cc1a4..2b7e8b125b 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -28,7 +28,7 @@ float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa float da = clamp(1.0/(la * d), 0.0, 1.0); // spotlight coefficient. - float spot = max(dot(-ln, lv), is_omnidirectional); + float spot = max(dot(-ln, lv), is_pointlight); da *= spot*spot; // GL_SPOT_EXPONENT=2 //angular attenuation -- cgit v1.2.3 From c8e4997395c8ffc71f838dcef142a56a5c6b781b Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 29 Jan 2010 01:45:13 -0800 Subject: fix a variety of shader errors, mostly due to my confusing glsl with C++... again --- indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 2b7e8b125b..da49e59b89 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -13,7 +13,7 @@ float calcDirectionalLight(vec3 n, vec3 l) } -float calcPointlightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight) +float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight) { //get light vector vec3 lv = lp.xyz-v; -- cgit v1.2.3 From 21b1b91c448b7d148a840c06d74deabc45af1819 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 6 Oct 2010 12:53:26 -0500 Subject: ATI compatibility pass --- indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl index 4b6d95e177..65b45f8081 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -4,6 +4,8 @@ * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * $/LicenseInfo$ */ + +#version 120 float calcDirectionalLight(vec3 n, vec3 l) -- cgit v1.2.3