2011-04-27 11:58:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011, Blender Foundation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "camera.h"
|
|
|
|
#include "device.h"
|
|
|
|
#include "film.h"
|
2012-02-28 19:43:33 +00:00
|
|
|
#include "integrator.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "scene.h"
|
|
|
|
|
2012-01-27 13:58:32 +00:00
|
|
|
#include "util_algorithm.h"
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
#include "util_foreach.h"
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
/* Pass */
|
|
|
|
|
2012-01-27 13:58:32 +00:00
|
|
|
static bool compare_pass_order(const Pass& a, const Pass& b)
|
|
|
|
{
|
|
|
|
if(a.components == b.components)
|
|
|
|
return (a.type < b.type);
|
|
|
|
return (a.components > b.components);
|
|
|
|
}
|
|
|
|
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
void Pass::add(PassType type, vector<Pass>& passes)
|
|
|
|
{
|
2012-03-28 12:18:12 +00:00
|
|
|
foreach(Pass& existing_pass, passes)
|
|
|
|
if(existing_pass.type == type)
|
|
|
|
return;
|
|
|
|
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
Pass pass;
|
|
|
|
|
|
|
|
pass.type = type;
|
|
|
|
pass.filter = true;
|
|
|
|
pass.exposure = false;
|
2012-03-28 12:18:12 +00:00
|
|
|
pass.divide_type = PASS_NONE;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case PASS_NONE:
|
|
|
|
pass.components = 0;
|
|
|
|
break;
|
|
|
|
case PASS_COMBINED:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
|
|
|
break;
|
|
|
|
case PASS_DEPTH:
|
|
|
|
pass.components = 1;
|
|
|
|
pass.filter = false;
|
|
|
|
break;
|
|
|
|
case PASS_NORMAL:
|
|
|
|
pass.components = 4;
|
|
|
|
break;
|
|
|
|
case PASS_UV:
|
|
|
|
pass.components = 4;
|
|
|
|
break;
|
|
|
|
case PASS_OBJECT_ID:
|
|
|
|
pass.components = 1;
|
|
|
|
pass.filter = false;
|
|
|
|
break;
|
|
|
|
case PASS_MATERIAL_ID:
|
|
|
|
pass.components = 1;
|
|
|
|
pass.filter = false;
|
|
|
|
break;
|
|
|
|
case PASS_DIFFUSE_COLOR:
|
|
|
|
pass.components = 4;
|
|
|
|
break;
|
|
|
|
case PASS_GLOSSY_COLOR:
|
|
|
|
pass.components = 4;
|
|
|
|
break;
|
|
|
|
case PASS_TRANSMISSION_COLOR:
|
|
|
|
pass.components = 4;
|
|
|
|
break;
|
|
|
|
case PASS_DIFFUSE_INDIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
2012-03-28 12:18:12 +00:00
|
|
|
pass.divide_type = PASS_DIFFUSE_COLOR;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
break;
|
|
|
|
case PASS_GLOSSY_INDIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
2012-03-28 12:18:12 +00:00
|
|
|
pass.divide_type = PASS_GLOSSY_COLOR;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
break;
|
|
|
|
case PASS_TRANSMISSION_INDIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
2012-03-28 12:18:12 +00:00
|
|
|
pass.divide_type = PASS_TRANSMISSION_COLOR;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
break;
|
|
|
|
case PASS_DIFFUSE_DIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
2012-03-28 12:18:12 +00:00
|
|
|
pass.divide_type = PASS_DIFFUSE_COLOR;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
break;
|
|
|
|
case PASS_GLOSSY_DIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
2012-03-28 12:18:12 +00:00
|
|
|
pass.divide_type = PASS_GLOSSY_COLOR;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
break;
|
|
|
|
case PASS_TRANSMISSION_DIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
2012-03-28 12:18:12 +00:00
|
|
|
pass.divide_type = PASS_TRANSMISSION_COLOR;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PASS_EMISSION:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
|
|
|
break;
|
|
|
|
case PASS_BACKGROUND:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
|
|
|
break;
|
2012-02-28 16:45:08 +00:00
|
|
|
case PASS_AO:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
|
|
|
break;
|
2012-03-28 10:39:21 +00:00
|
|
|
case PASS_SHADOW:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = false;
|
|
|
|
break;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
passes.push_back(pass);
|
2012-01-27 13:58:32 +00:00
|
|
|
|
|
|
|
/* order from by components, to ensure alignment so passes with size 4
|
|
|
|
come first and then passes with size 1 */
|
|
|
|
sort(passes.begin(), passes.end(), compare_pass_order);
|
2012-03-28 12:18:12 +00:00
|
|
|
|
|
|
|
if(pass.divide_type != PASS_NONE)
|
|
|
|
Pass::add(pass.divide_type, passes);
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Pass::equals(const vector<Pass>& A, const vector<Pass>& B)
|
|
|
|
{
|
|
|
|
if(A.size() != B.size())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for(int i = 0; i < A.size(); i++)
|
|
|
|
if(A[i].type != B[i].type)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Film */
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Film::Film()
|
|
|
|
{
|
|
|
|
exposure = 0.8f;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
Pass::add(PASS_COMBINED, passes);
|
2011-04-27 11:58:34 +00:00
|
|
|
need_update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Film::~Film()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Film::device_update(Device *device, DeviceScene *dscene)
|
|
|
|
{
|
|
|
|
if(!need_update)
|
|
|
|
return;
|
|
|
|
|
|
|
|
KernelFilm *kfilm = &dscene->data.film;
|
|
|
|
|
|
|
|
/* update __data */
|
|
|
|
kfilm->exposure = exposure;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
kfilm->pass_flag = 0;
|
|
|
|
kfilm->pass_stride = 0;
|
|
|
|
kfilm->use_light_pass = 0;
|
|
|
|
|
|
|
|
foreach(Pass& pass, passes) {
|
|
|
|
kfilm->pass_flag |= pass.type;
|
|
|
|
|
|
|
|
switch(pass.type) {
|
|
|
|
case PASS_COMBINED:
|
|
|
|
kfilm->pass_combined = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_DEPTH:
|
|
|
|
kfilm->pass_depth = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_NORMAL:
|
|
|
|
kfilm->pass_normal = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_UV:
|
|
|
|
kfilm->pass_uv = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_OBJECT_ID:
|
|
|
|
kfilm->pass_object_id = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_MATERIAL_ID:
|
|
|
|
kfilm->pass_material_id = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_DIFFUSE_COLOR:
|
|
|
|
kfilm->pass_diffuse_color = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_GLOSSY_COLOR:
|
|
|
|
kfilm->pass_glossy_color = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_TRANSMISSION_COLOR:
|
|
|
|
kfilm->pass_transmission_color = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_DIFFUSE_INDIRECT:
|
|
|
|
kfilm->pass_diffuse_indirect = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_GLOSSY_INDIRECT:
|
|
|
|
kfilm->pass_glossy_indirect = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_TRANSMISSION_INDIRECT:
|
|
|
|
kfilm->pass_transmission_indirect = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_DIFFUSE_DIRECT:
|
|
|
|
kfilm->pass_diffuse_direct = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_GLOSSY_DIRECT:
|
|
|
|
kfilm->pass_glossy_direct = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_TRANSMISSION_DIRECT:
|
|
|
|
kfilm->pass_transmission_direct = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PASS_EMISSION:
|
|
|
|
kfilm->pass_emission = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
break;
|
|
|
|
case PASS_BACKGROUND:
|
|
|
|
kfilm->pass_background = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
2012-02-28 16:45:08 +00:00
|
|
|
case PASS_AO:
|
|
|
|
kfilm->pass_ao = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
2012-03-28 10:39:21 +00:00
|
|
|
case PASS_SHADOW:
|
|
|
|
kfilm->pass_shadow = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
case PASS_NONE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
kfilm->pass_stride += pass.components;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-01-27 13:58:32 +00:00
|
|
|
kfilm->pass_stride = align_up(kfilm->pass_stride, 4);
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
need_update = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Film::device_free(Device *device, DeviceScene *dscene)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Film::modified(const Film& film)
|
|
|
|
{
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
return !(exposure == film.exposure
|
|
|
|
&& Pass::equals(passes, film.passes));
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Film::tag_update(Scene *scene)
|
|
|
|
{
|
2012-02-28 19:43:33 +00:00
|
|
|
scene->integrator->tag_update(scene);
|
2011-04-27 11:58:34 +00:00
|
|
|
need_update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|