Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/light.cpp
| Show All 26 Lines | |||||
| #include "render/shader.h" | #include "render/shader.h" | ||||
| #include "util/util_foreach.h" | #include "util/util_foreach.h" | ||||
| #include "util/util_hash.h" | #include "util/util_hash.h" | ||||
| #include "util/util_path.h" | #include "util/util_path.h" | ||||
| #include "util/util_progress.h" | #include "util/util_progress.h" | ||||
| #include "util/util_logging.h" | #include "util/util_logging.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| static void shade_background_pixels(Device *device, DeviceScene *dscene, int width, int height, vector<float3>& pixels, Progress& progress) | static void shade_background_pixels(Device *device, DeviceScene *dscene, int width, int height, vector<float3>& pixels, Progress& progress) | ||||
| { | { | ||||
| /* create input */ | /* create input */ | ||||
| device_vector<uint4> d_input(device, "background_input", MEM_READ_ONLY); | device_vector<uint4> d_input(device, "background_input", MEM_READ_ONLY); | ||||
| device_vector<float4> d_output(device, "background_output", MEM_READ_WRITE); | device_vector<float4> d_output(device, "background_output", MEM_READ_WRITE); | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | NODE_DEFINE(Light) | ||||
| type_enum.insert("background", LIGHT_BACKGROUND); | type_enum.insert("background", LIGHT_BACKGROUND); | ||||
| type_enum.insert("area", LIGHT_AREA); | type_enum.insert("area", LIGHT_AREA); | ||||
| type_enum.insert("spot", LIGHT_SPOT); | type_enum.insert("spot", LIGHT_SPOT); | ||||
| SOCKET_ENUM(type, "Type", type_enum, LIGHT_POINT); | SOCKET_ENUM(type, "Type", type_enum, LIGHT_POINT); | ||||
| SOCKET_POINT(co, "Co", make_float3(0.0f, 0.0f, 0.0f)); | SOCKET_POINT(co, "Co", make_float3(0.0f, 0.0f, 0.0f)); | ||||
| SOCKET_VECTOR(dir, "Dir", make_float3(0.0f, 0.0f, 0.0f)); | SOCKET_VECTOR(dir, "Dir", make_float3(0.0f, 0.0f, 0.0f)); | ||||
| SOCKET_FLOAT(sun_angle,"Sun Angle", 0.00918f); //0.526 degrees in radians | |||||
| SOCKET_FLOAT(size, "Size", 0.0f); | SOCKET_FLOAT(size, "Size", 0.0f); | ||||
| SOCKET_VECTOR(axisu, "Axis U", make_float3(0.0f, 0.0f, 0.0f)); | SOCKET_VECTOR(axisu, "Axis U", make_float3(0.0f, 0.0f, 0.0f)); | ||||
| SOCKET_FLOAT(sizeu, "Size U", 1.0f); | SOCKET_FLOAT(sizeu, "Size U", 1.0f); | ||||
| SOCKET_VECTOR(axisv, "Axis V", make_float3(0.0f, 0.0f, 0.0f)); | SOCKET_VECTOR(axisv, "Axis V", make_float3(0.0f, 0.0f, 0.0f)); | ||||
| SOCKET_FLOAT(sizev, "Size V", 1.0f); | SOCKET_FLOAT(sizev, "Size V", 1.0f); | ||||
| SOCKET_BOOLEAN(round, "Round", false); | SOCKET_BOOLEAN(round, "Round", false); | ||||
| ▲ Show 20 Lines • Show All 583 Lines • ▼ Show 20 Lines | if(light->type == LIGHT_POINT) { | ||||
| klights[light_index].co[2] = co.z; | klights[light_index].co[2] = co.z; | ||||
| klights[light_index].spot.radius = radius; | klights[light_index].spot.radius = radius; | ||||
| klights[light_index].spot.invarea = invarea; | klights[light_index].spot.invarea = invarea; | ||||
| } | } | ||||
| else if(light->type == LIGHT_DISTANT) { | else if(light->type == LIGHT_DISTANT) { | ||||
| shader_id &= ~SHADER_AREA_LIGHT; | shader_id &= ~SHADER_AREA_LIGHT; | ||||
| float radius = light->size; | float angle = light->sun_angle / 2.0f; | ||||
| float angle = atanf(radius); | float radius = tanf(angle); | ||||
| float cosangle = cosf(angle); | float cosangle = cosf(angle); | ||||
| float area = M_PI_F*radius*radius; | float area = M_PI_F*radius*radius; | ||||
| float invarea = (area > 0.0f)? 1.0f/area: 1.0f; | float invarea = (area > 0.0f)? 1.0f/area: 1.0f; | ||||
| float3 dir = light->dir; | float3 dir = light->dir; | ||||
| dir = safe_normalize(dir); | dir = safe_normalize(dir); | ||||
| if(light->use_mis && area > 0.0f) | if(light->use_mis && area > 0.0f) | ||||
| ▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines | |||||