From cd723967970e3330d5461eaf8a062d6321de5d4f Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 21 Jan 2015 20:06:53 +0100 Subject: Cycles: Optimization for black world backgrounds * If a Background node is set to a black color or zero strength, it now gets removed from the shader graph. * In case the graph is empty (no background node), the kernel will skip evaluating it and save some rendertime. This can help quite a bit in scenes, where the majority of the image consists of a black background. Example: http://www.pasteall.org/pic/show.php?id=82650 In this case the render is ~16% faster. Differential Revision: https://developer.blender.org/D972 --- intern/cycles/render/background.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'intern/cycles/render/background.cpp') diff --git a/intern/cycles/render/background.cpp b/intern/cycles/render/background.cpp index d731b3346fe..f5e51f2e159 100644 --- a/intern/cycles/render/background.cpp +++ b/intern/cycles/render/background.cpp @@ -72,16 +72,23 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene else kbackground->volume_shader = SHADER_NONE; - if(!(visibility & PATH_RAY_DIFFUSE)) - kbackground->surface_shader |= SHADER_EXCLUDE_DIFFUSE; - if(!(visibility & PATH_RAY_GLOSSY)) - kbackground->surface_shader |= SHADER_EXCLUDE_GLOSSY; - if(!(visibility & PATH_RAY_TRANSMIT)) - kbackground->surface_shader |= SHADER_EXCLUDE_TRANSMIT; - if(!(visibility & PATH_RAY_VOLUME_SCATTER)) - kbackground->surface_shader |= SHADER_EXCLUDE_SCATTER; - if(!(visibility & PATH_RAY_CAMERA)) - kbackground->surface_shader |= SHADER_EXCLUDE_CAMERA; + /* No background node, make world shader invisible to all rays, to skip evaluation in kernel. */ + if(scene->shaders[shader]->graph->nodes.size() <= 1) { + kbackground->surface_shader |= SHADER_EXCLUDE_ANY; + } + /* Background present, check visibilities */ + else { + if(!(visibility & PATH_RAY_DIFFUSE)) + kbackground->surface_shader |= SHADER_EXCLUDE_DIFFUSE; + if(!(visibility & PATH_RAY_GLOSSY)) + kbackground->surface_shader |= SHADER_EXCLUDE_GLOSSY; + if(!(visibility & PATH_RAY_TRANSMIT)) + kbackground->surface_shader |= SHADER_EXCLUDE_TRANSMIT; + if(!(visibility & PATH_RAY_VOLUME_SCATTER)) + kbackground->surface_shader |= SHADER_EXCLUDE_SCATTER; + if(!(visibility & PATH_RAY_CAMERA)) + kbackground->surface_shader |= SHADER_EXCLUDE_CAMERA; + } need_update = false; } -- cgit v1.2.3