From cd17687f01420952712a500107e0f93e7ab8d5f8 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:34 -0500 Subject: Second Life viewer sources 1.19.1.0 --- .../shaders/class1/lighting/lightFuncV.glsl | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 linden/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl (limited to 'linden/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl') diff --git a/linden/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/linden/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl new file mode 100644 index 0000000..3e8fdfb --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -0,0 +1,34 @@ +/** + * @file lightFuncV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +float calcDirectionalLight(vec3 n, vec3 l) +{ + float a = max(dot(n,l),0.0); + 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; +} + -- cgit v1.1