Cycles: Auto disable World MIS, if we only use a simple color.
When World MIS is enabled by the user, we now check if we actually need it. In case of a simple node setup (no procedurals, no HDRs..) we auto disable MIS internally to save render time. This change is important for upcoming default changes.
This commit is contained in:
@@ -556,13 +556,28 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
|
|||||||
if(scene->lights.size() == 0)
|
if(scene->lights.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* remove background light? */
|
/* Do we have a portal? */
|
||||||
if(!(device->info.advanced_shading)) {
|
bool has_portal = false;
|
||||||
foreach(Light *light, scene->lights) {
|
foreach(Light *light, scene->lights) {
|
||||||
if(light->type == LIGHT_BACKGROUND) {
|
if(light->is_portal) {
|
||||||
|
has_portal = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove background light:
|
||||||
|
* - If unsupported on a device
|
||||||
|
* - If we don't need it (no HDRs etc.)
|
||||||
|
*/
|
||||||
|
foreach(Light *light, scene->lights) {
|
||||||
|
if(light->type == LIGHT_BACKGROUND) {
|
||||||
|
Shader *shader = scene->shaders[scene->background->shader];
|
||||||
|
bool auto_disable_mis = (!has_portal && !shader->has_surface_spatial_varying);
|
||||||
|
if(!(device->info.advanced_shading) || auto_disable_mis) {
|
||||||
|
VLOG(1) << "Background MIS has been disabled. \n";
|
||||||
scene->lights.erase(std::remove(scene->lights.begin(), scene->lights.end(), light), scene->lights.end());
|
scene->lights.erase(std::remove(scene->lights.begin(), scene->lights.end(), light), scene->lights.end());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,7 +755,7 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
|
|||||||
|
|
||||||
void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
|
void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
|
||||||
{
|
{
|
||||||
VLOG(1) << "Total " << scene->lights.size() << " lights.";
|
int lights_size = scene->lights.size();
|
||||||
|
|
||||||
if(!need_update)
|
if(!need_update)
|
||||||
return;
|
return;
|
||||||
@@ -764,6 +779,11 @@ void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *sce
|
|||||||
}
|
}
|
||||||
|
|
||||||
need_update = false;
|
need_update = false;
|
||||||
|
|
||||||
|
if(lights_size != scene->lights.size())
|
||||||
|
VLOG(1) << "Total " << scene->lights.size() << " lights (" << lights_size << " before optimization).";
|
||||||
|
else
|
||||||
|
VLOG(1) << "Total " << scene->lights.size() << " lights.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightManager::device_free(Device *device, DeviceScene *dscene)
|
void LightManager::device_free(Device *device, DeviceScene *dscene)
|
||||||
|
@@ -570,14 +570,20 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
|
|||||||
/* test if we shader contains specific closures */
|
/* test if we shader contains specific closures */
|
||||||
OSLShaderInfo *info = ((OSLShaderManager*)manager)->shader_loaded_info(name);
|
OSLShaderInfo *info = ((OSLShaderManager*)manager)->shader_loaded_info(name);
|
||||||
|
|
||||||
if(info && current_type == SHADER_TYPE_SURFACE) {
|
if(current_type == SHADER_TYPE_SURFACE) {
|
||||||
if(info->has_surface_emission)
|
if(info) {
|
||||||
current_shader->has_surface_emission = true;
|
if(info->has_surface_emission)
|
||||||
if(info->has_surface_transparent)
|
current_shader->has_surface_emission = true;
|
||||||
current_shader->has_surface_transparent = true;
|
if(info->has_surface_transparent)
|
||||||
if(info->has_surface_bssrdf) {
|
current_shader->has_surface_transparent = true;
|
||||||
current_shader->has_surface_bssrdf = true;
|
if(info->has_surface_bssrdf) {
|
||||||
current_shader->has_bssrdf_bump = true; /* can't detect yet */
|
current_shader->has_surface_bssrdf = true;
|
||||||
|
current_shader->has_bssrdf_bump = true; /* can't detect yet */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(node->has_spatial_varying()) {
|
||||||
|
current_shader->has_surface_spatial_varying = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(current_type == SHADER_TYPE_VOLUME) {
|
else if(current_type == SHADER_TYPE_VOLUME) {
|
||||||
@@ -752,6 +758,8 @@ void OSLCompiler::generate_nodes(const ShaderNodeSet& nodes)
|
|||||||
current_shader->has_surface_emission = true;
|
current_shader->has_surface_emission = true;
|
||||||
if(node->has_surface_transparent())
|
if(node->has_surface_transparent())
|
||||||
current_shader->has_surface_transparent = true;
|
current_shader->has_surface_transparent = true;
|
||||||
|
if(node->has_spatial_varying())
|
||||||
|
current_shader->has_surface_spatial_varying = true;
|
||||||
if(node->has_surface_bssrdf()) {
|
if(node->has_surface_bssrdf()) {
|
||||||
current_shader->has_surface_bssrdf = true;
|
current_shader->has_surface_bssrdf = true;
|
||||||
if(node->has_bssrdf_bump())
|
if(node->has_bssrdf_bump())
|
||||||
@@ -839,6 +847,7 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader)
|
|||||||
shader->has_bssrdf_bump = false;
|
shader->has_bssrdf_bump = false;
|
||||||
shader->has_volume = false;
|
shader->has_volume = false;
|
||||||
shader->has_displacement = false;
|
shader->has_displacement = false;
|
||||||
|
shader->has_surface_spatial_varying = false;
|
||||||
shader->has_volume_spatial_varying = false;
|
shader->has_volume_spatial_varying = false;
|
||||||
shader->has_object_dependency = false;
|
shader->has_object_dependency = false;
|
||||||
shader->has_integrator_dependency = false;
|
shader->has_integrator_dependency = false;
|
||||||
|
@@ -152,6 +152,7 @@ Shader::Shader()
|
|||||||
has_volume = false;
|
has_volume = false;
|
||||||
has_displacement = false;
|
has_displacement = false;
|
||||||
has_bssrdf_bump = false;
|
has_bssrdf_bump = false;
|
||||||
|
has_surface_spatial_varying = false;
|
||||||
has_volume_spatial_varying = false;
|
has_volume_spatial_varying = false;
|
||||||
has_object_dependency = false;
|
has_object_dependency = false;
|
||||||
has_integrator_dependency = false;
|
has_integrator_dependency = false;
|
||||||
|
@@ -106,6 +106,7 @@ public:
|
|||||||
bool has_displacement;
|
bool has_displacement;
|
||||||
bool has_surface_bssrdf;
|
bool has_surface_bssrdf;
|
||||||
bool has_bssrdf_bump;
|
bool has_bssrdf_bump;
|
||||||
|
bool has_surface_spatial_varying;
|
||||||
bool has_volume_spatial_varying;
|
bool has_volume_spatial_varying;
|
||||||
bool has_object_dependency;
|
bool has_object_dependency;
|
||||||
bool has_integrator_dependency;
|
bool has_integrator_dependency;
|
||||||
|
@@ -397,7 +397,11 @@ void SVMCompiler::generate_node(ShaderNode *node, ShaderNodeSet& done)
|
|||||||
stack_clear_users(node, done);
|
stack_clear_users(node, done);
|
||||||
stack_clear_temporary(node);
|
stack_clear_temporary(node);
|
||||||
|
|
||||||
if(current_type == SHADER_TYPE_VOLUME) {
|
if(current_type == SHADER_TYPE_SURFACE) {
|
||||||
|
if(node->has_spatial_varying())
|
||||||
|
current_shader->has_surface_spatial_varying = true;
|
||||||
|
}
|
||||||
|
else if(current_type == SHADER_TYPE_VOLUME) {
|
||||||
if(node->has_spatial_varying())
|
if(node->has_spatial_varying())
|
||||||
current_shader->has_volume_spatial_varying = true;
|
current_shader->has_volume_spatial_varying = true;
|
||||||
}
|
}
|
||||||
@@ -761,6 +765,7 @@ void SVMCompiler::compile(Scene *scene,
|
|||||||
shader->has_bssrdf_bump = false;
|
shader->has_bssrdf_bump = false;
|
||||||
shader->has_volume = false;
|
shader->has_volume = false;
|
||||||
shader->has_displacement = false;
|
shader->has_displacement = false;
|
||||||
|
shader->has_surface_spatial_varying = false;
|
||||||
shader->has_volume_spatial_varying = false;
|
shader->has_volume_spatial_varying = false;
|
||||||
shader->has_object_dependency = false;
|
shader->has_object_dependency = false;
|
||||||
shader->has_integrator_dependency = false;
|
shader->has_integrator_dependency = false;
|
||||||
|
Reference in New Issue
Block a user