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 ++-- indra/newview/pipeline.cpp | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'indra') 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; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 891f83e877..2a1ed1b5ab 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4563,7 +4563,6 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) glLightfv(gllight, GL_POSITION, light_pos_gl.mV); glLightfv(gllight, GL_DIFFUSE, light_color.mV); glLightfv(gllight, GL_AMBIENT, LLColor4::black.mV); - glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV); glLightf (gllight, GL_CONSTANT_ATTENUATION, 0.0f); glLightf (gllight, GL_LINEAR_ATTENUATION, atten); glLightf (gllight, GL_QUADRATIC_ATTENUATION, quad); @@ -4577,11 +4576,16 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV); glLightf (gllight, GL_SPOT_EXPONENT, 1.0f); // 1.0 = good old dot product glLightf (gllight, GL_SPOT_CUTOFF, 90.0f); // hemisphere + glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV); } else // omnidirectional (point) light { glLightf (gllight, GL_SPOT_EXPONENT, 0.0f); glLightf (gllight, GL_SPOT_CUTOFF, 180.0f); + + // we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight + const float specular = {0.f, 0.f, 0.f, 1.f}, + glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV); } cur_light++; if (cur_light >= 8) -- cgit v1.2.3