From 6548f7efefb2e9db25e8c6ca8b7d4ed6b9725543 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 4 Jun 2012 17:17:10 +0000 Subject: Cycles: spot lamp support. --- intern/cycles/render/light.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'intern/cycles/render/light.cpp') diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 267cb8e6d3a..1bf1cde4a1c 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -109,6 +109,9 @@ Light::Light() map_resolution = 512; + spot_angle = M_PI_F/4.0f; + spot_smooth = 0.0f; + cast_shadow = true; shader = 0; } @@ -451,6 +454,17 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce light_data[i*LIGHT_SIZE + 2] = make_float4(0.0f, axisv.x, axisv.y, axisv.z); light_data[i*LIGHT_SIZE + 3] = make_float4(0.0f, dir.x, dir.y, dir.z); } + else if(light->type == LIGHT_SPOT) { + shader_id &= ~SHADER_AREA_LIGHT; + + float spot_angle = cosf(light->spot_angle*0.5f); + float spot_smooth = (1.0f - spot_angle)*light->spot_smooth; + + light_data[i*LIGHT_SIZE + 0] = make_float4(__int_as_float(light->type), co.x, co.y, co.z); + light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), light->size, dir.x, dir.y); + light_data[i*LIGHT_SIZE + 2] = make_float4(dir.z, spot_angle, spot_smooth, 0.0f); + light_data[i*LIGHT_SIZE + 3] = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + } } device->tex_alloc("__light_data", dscene->light_data); -- cgit v1.2.3