Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/background.cpp
| Show All 28 Lines | |||||
| #include "util/util_types.h" | #include "util/util_types.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| NODE_DEFINE(Background) | NODE_DEFINE(Background) | ||||
| { | { | ||||
| NodeType *type = NodeType::add("background", create); | NodeType *type = NodeType::add("background", create); | ||||
| SOCKET_FLOAT(ao_factor, "AO Factor", 0.0f); | |||||
| SOCKET_FLOAT(ao_distance, "AO Distance", FLT_MAX); | |||||
| SOCKET_BOOLEAN(use_shader, "Use Shader", true); | SOCKET_BOOLEAN(use_shader, "Use Shader", true); | ||||
| SOCKET_BOOLEAN(use_ao, "Use AO", false); | |||||
| SOCKET_UINT(visibility, "Visibility", PATH_RAY_ALL_VISIBILITY); | SOCKET_UINT(visibility, "Visibility", PATH_RAY_ALL_VISIBILITY); | ||||
| SOCKET_BOOLEAN(transparent, "Transparent", false); | SOCKET_BOOLEAN(transparent, "Transparent", false); | ||||
| SOCKET_BOOLEAN(transparent_glass, "Transparent Glass", false); | SOCKET_BOOLEAN(transparent_glass, "Transparent Glass", false); | ||||
| SOCKET_FLOAT(transparent_roughness_threshold, "Transparent Roughness Threshold", 0.0f); | SOCKET_FLOAT(transparent_roughness_threshold, "Transparent Roughness Threshold", 0.0f); | ||||
| SOCKET_FLOAT(volume_step_size, "Volume Step Size", 0.1f); | SOCKET_FLOAT(volume_step_size, "Volume Step Size", 0.1f); | ||||
| Show All 25 Lines | void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene) | ||||
| device_free(device, dscene); | device_free(device, dscene); | ||||
| Shader *bg_shader = get_shader(scene); | Shader *bg_shader = get_shader(scene); | ||||
| /* set shader index and transparent option */ | /* set shader index and transparent option */ | ||||
| KernelBackground *kbackground = &dscene->data.background; | KernelBackground *kbackground = &dscene->data.background; | ||||
| kbackground->ao_factor = (use_ao) ? ao_factor : 0.0f; | |||||
| kbackground->ao_bounces_factor = ao_factor; | |||||
| kbackground->ao_distance = ao_distance; | |||||
| kbackground->transparent = transparent; | kbackground->transparent = transparent; | ||||
| kbackground->surface_shader = scene->shader_manager->get_shader_id(bg_shader); | kbackground->surface_shader = scene->shader_manager->get_shader_id(bg_shader); | ||||
| if (transparent && transparent_glass) { | if (transparent && transparent_glass) { | ||||
| /* Square twice, once for principled BSDF convention, and once for | /* Square twice, once for principled BSDF convention, and once for | ||||
| * faster comparison in kernel with anisotropic roughness. */ | * faster comparison in kernel with anisotropic roughness. */ | ||||
| kbackground->transparent_roughness_squared_threshold = sqr( | kbackground->transparent_roughness_squared_threshold = sqr( | ||||
| sqr(transparent_roughness_threshold)); | sqr(transparent_roughness_threshold)); | ||||
| Show All 38 Lines | |||||
| { | { | ||||
| Shader *bg_shader = get_shader(scene); | Shader *bg_shader = get_shader(scene); | ||||
| if (bg_shader && bg_shader->is_modified()) { | if (bg_shader && bg_shader->is_modified()) { | ||||
| /* Tag as modified to update the KernelBackground visibility information. | /* Tag as modified to update the KernelBackground visibility information. | ||||
| * We only tag the use_shader socket as modified as it is related to the shader | * We only tag the use_shader socket as modified as it is related to the shader | ||||
| * and to avoid doing unnecessary updates anywhere else. */ | * and to avoid doing unnecessary updates anywhere else. */ | ||||
| tag_use_shader_modified(); | tag_use_shader_modified(); | ||||
| } | } | ||||
| if (ao_factor_is_modified() || use_ao_is_modified()) { | |||||
| scene->integrator->tag_update(scene, Integrator::BACKGROUND_AO_MODIFIED); | |||||
| } | |||||
| } | } | ||||
| Shader *Background::get_shader(const Scene *scene) | Shader *Background::get_shader(const Scene *scene) | ||||
| { | { | ||||
| return (use_shader) ? ((shader) ? shader : scene->default_background) : scene->default_empty; | return (use_shader) ? ((shader) ? shader : scene->default_background) : scene->default_empty; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||