Merged revision(s) 57828-57907 from trunk/blender into soc-2013-dingto
authorThomas Dinges <blender@dingto.org>
Mon, 1 Jul 2013 15:23:48 +0000 (15:23 +0000)
committerThomas Dinges <blender@dingto.org>
Mon, 1 Jul 2013 15:23:48 +0000 (15:23 +0000)
1  2 
intern/cycles/render/scene.h
intern/cycles/render/shader.cpp

index be50279ba741a6437d1ceaf09973a2ae9e53655b,0790d4159c5a12a9e60033342833aa048917bece..8f5bc4ead950092ed939aae90cdeb4492a7caddf
@@@ -105,8 -105,8 +105,8 @@@ public
        /* integrator */
        device_vector<uint> sobol_directions;
  
 -      /* images */
 -      device_vector<uchar4> tex_image[TEX_EXTENDED_NUM_IMAGES];
 +      /* CPU images */
 +      device_vector<uchar4> tex_image[TEX_EXTENDED_NUM_IMAGES_CPU];
        device_vector<float4> tex_float_image[TEX_EXTENDED_NUM_FLOAT_IMAGES];
  
        /* opencl images */
@@@ -180,7 -180,6 +180,6 @@@ public
        int default_surface;
        int default_light;
        int default_background;
-       int default_holdout;
        int default_empty;
  
        /* device */
index 76b5b2baaa62b2dcb932de6d4113f5fe95738d86,21b43380f2cf951496b6ac451ff3f36aa7dea1c8..72a0645c779eea96d0a67775123e4bf3d8b29dfe
@@@ -16,8 -16,8 +16,9 @@@
   * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   */
  
+ #include "background.h"
  #include "bssrdf.h"
 +#include "blackbody.h"
  #include "device.h"
  #include "graph.h"
  #include "light.h"
@@@ -51,7 -51,6 +52,7 @@@ Shader::Shader(
        has_surface_transparent = false;
        has_surface_emission = false;
        has_surface_bssrdf = false;
 +      has_converter_blackbody = false;
        has_volume = false;
        has_displacement = false;
  
@@@ -128,7 -127,6 +129,7 @@@ ShaderManager::ShaderManager(
  {
        need_update = true;
        bssrdf_table_offset = TABLE_OFFSET_INVALID;
 +      blackbody_table_offset = TABLE_OFFSET_INVALID;
  }
  
  ShaderManager::~ShaderManager()
@@@ -194,10 -192,10 +195,10 @@@ void ShaderManager::device_update_shade
        foreach(Shader *shader, scene->shaders)
                shader->used = false;
  
+       scene->shaders[scene->background->shader]->used = true;
        scene->shaders[scene->default_surface]->used = true;
        scene->shaders[scene->default_light]->used = true;
        scene->shaders[scene->default_background]->used = true;
-       scene->shaders[scene->default_holdout]->used = true;
        scene->shaders[scene->default_empty]->used = true;
  
        foreach(Mesh *mesh, scene->meshes)
@@@ -220,7 -218,6 +221,7 @@@ void ShaderManager::device_update_commo
        uint *shader_flag = dscene->shader_flag.resize(shader_flag_size);
        uint i = 0;
        bool has_surface_bssrdf = false;
 +      bool has_converter_blackbody = false;
  
        foreach(Shader *shader, scene->shaders) {
                uint flag = 0;
                        flag |= SD_HOMOGENEOUS_VOLUME;
                if(shader->has_surface_bssrdf)
                        has_surface_bssrdf = true;
 +              if(shader->has_converter_blackbody)
 +                      has_converter_blackbody = true;
  
                shader_flag[i++] = flag;
                shader_flag[i++] = shader->pass_id;
                scene->lookup_tables->remove_table(bssrdf_table_offset);
                bssrdf_table_offset = TABLE_OFFSET_INVALID;
        }
 +
 +      /* blackbody lookup table */
 +      KernelBLACKBODY *kblackbody = &dscene->data.blackbody;
 +      
 +      if(has_converter_blackbody && blackbody_table_offset == TABLE_OFFSET_INVALID) {
 +              vector<float> table = blackbody_table();
 +              blackbody_table_offset = scene->lookup_tables->add_table(dscene, table);
 +              
 +              kblackbody->table_offset = (int)blackbody_table_offset;
 +      }
 +      else if(!has_converter_blackbody && blackbody_table_offset != TABLE_OFFSET_INVALID) {
 +              scene->lookup_tables->remove_table(blackbody_table_offset);
 +              blackbody_table_offset = TABLE_OFFSET_INVALID;
 +      }
 +
  }
  
  void ShaderManager::device_free_common(Device *device, DeviceScene *dscene, Scene *scene)
                bssrdf_table_offset = TABLE_OFFSET_INVALID;
        }
  
 +      if(blackbody_table_offset != TABLE_OFFSET_INVALID) {
 +              scene->lookup_tables->remove_table(blackbody_table_offset);
 +              blackbody_table_offset = TABLE_OFFSET_INVALID;
 +      }
 +
        device->tex_free(dscene->shader_flag);
        dscene->shader_flag.clear();
  }
@@@ -353,22 -328,6 +354,6 @@@ void ShaderManager::add_default(Scene *
                scene->default_background = scene->shaders.size() - 1;
        }
  
-       /* default holdout */
-       {
-               graph = new ShaderGraph();
-               closure = graph->add(new HoldoutNode());
-               out = graph->output();
-               graph->connect(closure->output("Holdout"), out->input("Surface"));
-               shader = new Shader();
-               shader->name = "default_holdout";
-               shader->graph = graph;
-               scene->shaders.push_back(shader);
-               scene->default_holdout = scene->shaders.size() - 1;
-       }
        /* default empty */
        {
                graph = new ShaderGraph();