Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/light.cpp
| Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | NODE_DEFINE(Light) | ||||
| static NodeEnum type_enum; | static NodeEnum type_enum; | ||||
| type_enum.insert("point", LIGHT_POINT); | type_enum.insert("point", LIGHT_POINT); | ||||
| type_enum.insert("distant", LIGHT_DISTANT); | type_enum.insert("distant", LIGHT_DISTANT); | ||||
| 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_COLOR(strength, "Strength", make_float3(1.0f, 1.0f, 1.0f)); | |||||
| 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(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)); | ||||
| Show All 33 Lines | |||||
| void Light::tag_update(Scene *scene) | void Light::tag_update(Scene *scene) | ||||
| { | { | ||||
| scene->light_manager->need_update = true; | scene->light_manager->need_update = true; | ||||
| } | } | ||||
| bool Light::has_contribution(Scene *scene) | bool Light::has_contribution(Scene *scene) | ||||
| { | { | ||||
| if(strength == make_float3(0.0f, 0.0f, 0.0f)) { | |||||
| return false; | |||||
| } | |||||
| if(is_portal) { | if(is_portal) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if(type == LIGHT_BACKGROUND) { | if(type == LIGHT_BACKGROUND) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return (shader) ? shader->has_surface_emission : scene->default_light->has_surface_emission; | return (shader) ? shader->has_surface_emission : scene->default_light->has_surface_emission; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 490 Lines • ▼ Show 20 Lines | void LightManager::device_update_points(Device *, | ||||
| foreach(Light *light, scene->lights) { | foreach(Light *light, scene->lights) { | ||||
| if(!light->is_enabled) { | if(!light->is_enabled) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float3 co = light->co; | float3 co = light->co; | ||||
| Shader *shader = (light->shader) ? light->shader : scene->default_light; | Shader *shader = (light->shader) ? light->shader : scene->default_light; | ||||
| int shader_id = scene->shader_manager->get_shader_id(shader); | int shader_id = scene->shader_manager->get_shader_id(shader); | ||||
| int samples = light->samples; | |||||
| int max_bounces = light->max_bounces; | int max_bounces = light->max_bounces; | ||||
| float random = (float)light->random_id * (1.0f/(float)0xFFFFFFFF); | float random = (float)light->random_id * (1.0f/(float)0xFFFFFFFF); | ||||
| if(!light->cast_shadow) | if(!light->cast_shadow) | ||||
| shader_id &= ~SHADER_CAST_SHADOW; | shader_id &= ~SHADER_CAST_SHADOW; | ||||
| if(!light->use_diffuse) { | if(!light->use_diffuse) { | ||||
| shader_id |= SHADER_EXCLUDE_DIFFUSE; | shader_id |= SHADER_EXCLUDE_DIFFUSE; | ||||
| use_light_visibility = true; | use_light_visibility = true; | ||||
| } | } | ||||
| if(!light->use_glossy) { | if(!light->use_glossy) { | ||||
| shader_id |= SHADER_EXCLUDE_GLOSSY; | shader_id |= SHADER_EXCLUDE_GLOSSY; | ||||
| use_light_visibility = true; | use_light_visibility = true; | ||||
| } | } | ||||
| if(!light->use_transmission) { | if(!light->use_transmission) { | ||||
| shader_id |= SHADER_EXCLUDE_TRANSMIT; | shader_id |= SHADER_EXCLUDE_TRANSMIT; | ||||
| use_light_visibility = true; | use_light_visibility = true; | ||||
| } | } | ||||
| if(!light->use_scatter) { | if(!light->use_scatter) { | ||||
| shader_id |= SHADER_EXCLUDE_SCATTER; | shader_id |= SHADER_EXCLUDE_SCATTER; | ||||
| use_light_visibility = true; | use_light_visibility = true; | ||||
| } | } | ||||
| klights[light_index].type = light->type; | klights[light_index].type = light->type; | ||||
| klights[light_index].samples = samples; | klights[light_index].samples = light->samples; | ||||
| klights[light_index].strength[0] = light->strength.x; | |||||
| klights[light_index].strength[1] = light->strength.y; | |||||
| klights[light_index].strength[2] = light->strength.z; | |||||
| if(light->type == LIGHT_POINT) { | if(light->type == LIGHT_POINT) { | ||||
| shader_id &= ~SHADER_AREA_LIGHT; | shader_id &= ~SHADER_AREA_LIGHT; | ||||
| float radius = light->size; | float radius = light->size; | ||||
| float invarea = (radius > 0.0f)? 1.0f/(M_PI_F*radius*radius): 1.0f; | float invarea = (radius > 0.0f)? 1.0f/(M_PI_F*radius*radius): 1.0f; | ||||
| if(light->use_mis && radius > 0.0f) | if(light->use_mis && radius > 0.0f) | ||||
| ▲ Show 20 Lines • Show All 335 Lines • Show Last 20 Lines | |||||