2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "camera.h"
|
|
|
|
#include "device.h"
|
|
|
|
#include "film.h"
|
2012-02-28 19:43:33 +00:00
|
|
|
#include "integrator.h"
|
2012-06-20 14:24:52 +00:00
|
|
|
#include "mesh.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "scene.h"
|
2013-04-01 20:26:43 +00:00
|
|
|
#include "tables.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-01-27 13:58:32 +00:00
|
|
|
#include "util_algorithm.h"
|
2013-04-01 20:26:43 +00:00
|
|
|
#include "util_debug.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"
|
2013-04-01 20:26:43 +00:00
|
|
|
#include "util_math.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
|
|
|
|
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;
|
2013-06-07 12:45:26 +00:00
|
|
|
case PASS_MIST:
|
|
|
|
pass.components = 1;
|
|
|
|
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
|
|
|
case PASS_NORMAL:
|
|
|
|
pass.components = 4;
|
|
|
|
break;
|
|
|
|
case PASS_UV:
|
|
|
|
pass.components = 4;
|
|
|
|
break;
|
2012-04-30 12:49:26 +00:00
|
|
|
case PASS_MOTION:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.divide_type = PASS_MOTION_WEIGHT;
|
|
|
|
break;
|
|
|
|
case PASS_MOTION_WEIGHT:
|
|
|
|
pass.components = 1;
|
|
|
|
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
|
|
|
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;
|
2013-08-03 13:12:09 +00:00
|
|
|
case PASS_SUBSURFACE_COLOR:
|
|
|
|
pass.components = 4;
|
|
|
|
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
|
|
|
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;
|
2013-08-03 13:12:09 +00:00
|
|
|
case PASS_SUBSURFACE_INDIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
|
|
|
pass.divide_type = PASS_SUBSURFACE_COLOR;
|
|
|
|
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
|
|
|
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;
|
2013-08-03 13:12:09 +00:00
|
|
|
case PASS_SUBSURFACE_DIRECT:
|
|
|
|
pass.components = 4;
|
|
|
|
pass.exposure = true;
|
|
|
|
pass.divide_type = PASS_SUBSURFACE_COLOR;
|
|
|
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
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
|
2012-06-09 17:22:52 +00:00
|
|
|
* come first and then passes with size 1 */
|
2012-01-27 13:58:32 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
bool Pass::contains(const vector<Pass>& passes, PassType type)
|
|
|
|
{
|
|
|
|
foreach(const Pass& pass, passes)
|
|
|
|
if(pass.type == type)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-01 20:26:43 +00:00
|
|
|
/* Pixel Filter */
|
|
|
|
|
|
|
|
static float filter_func_box(float v, float width)
|
|
|
|
{
|
2013-05-09 14:37:32 +00:00
|
|
|
return 1.0f;
|
2013-04-01 20:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float filter_func_gaussian(float v, float width)
|
|
|
|
{
|
2013-05-09 14:37:32 +00:00
|
|
|
v *= 2.0f/width;
|
|
|
|
return expf(-2.0f*v*v);
|
2013-04-01 20:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static vector<float> filter_table(FilterType type, float width)
|
|
|
|
{
|
|
|
|
const int filter_table_size = FILTER_TABLE_SIZE-1;
|
|
|
|
vector<float> filter_table_cdf(filter_table_size+1);
|
|
|
|
vector<float> filter_table(filter_table_size+1);
|
|
|
|
float (*filter_func)(float, float) = NULL;
|
|
|
|
int i, half_size = filter_table_size/2;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case FILTER_BOX:
|
|
|
|
filter_func = filter_func_box;
|
|
|
|
break;
|
|
|
|
case FILTER_GAUSSIAN:
|
|
|
|
filter_func = filter_func_gaussian;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute cumulative distribution function */
|
|
|
|
filter_table_cdf[0] = 0.0f;
|
|
|
|
|
|
|
|
for(i = 0; i < filter_table_size; i++) {
|
|
|
|
float x = i*width*0.5f/(filter_table_size-1);
|
|
|
|
float y = filter_func(x, width);
|
|
|
|
filter_table_cdf[i+1] += filter_table_cdf[i] + fabsf(y);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i <= filter_table_size; i++)
|
|
|
|
filter_table_cdf[i] /= filter_table_cdf[filter_table_size];
|
|
|
|
|
|
|
|
/* create importance sampling table */
|
|
|
|
for(i = 0; i <= half_size; i++) {
|
|
|
|
float x = i/(float)half_size;
|
|
|
|
int index = upper_bound(filter_table_cdf.begin(), filter_table_cdf.end(), x) - filter_table_cdf.begin();
|
|
|
|
float t;
|
|
|
|
|
|
|
|
if(index < filter_table_size+1) {
|
|
|
|
t = (x - filter_table_cdf[index])/(filter_table_cdf[index+1] - filter_table_cdf[index]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
t = 0.0f;
|
|
|
|
index = filter_table_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
float y = ((index + t)/(filter_table_size))*width;
|
|
|
|
|
|
|
|
filter_table[half_size+i] = 0.5f*(1.0f + y);
|
|
|
|
filter_table[half_size-i] = 0.5f*(1.0f - y);
|
|
|
|
}
|
|
|
|
|
|
|
|
return filter_table;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* 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);
|
2014-02-06 14:18:34 +00:00
|
|
|
pass_alpha_threshold = 0.5f;
|
2013-04-01 20:26:43 +00:00
|
|
|
|
|
|
|
filter_type = FILTER_BOX;
|
|
|
|
filter_width = 1.0f;
|
2013-04-01 20:26:52 +00:00
|
|
|
filter_table_offset = TABLE_OFFSET_INVALID;
|
2013-04-01 20:26:43 +00:00
|
|
|
|
2013-06-07 12:45:26 +00:00
|
|
|
mist_start = 0.0f;
|
|
|
|
mist_depth = 100.0f;
|
|
|
|
mist_falloff = 1.0f;
|
|
|
|
|
2013-06-07 18:59:23 +00:00
|
|
|
use_light_visibility = false;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
need_update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Film::~Film()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-01 20:26:43 +00:00
|
|
|
void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
if(!need_update)
|
|
|
|
return;
|
2013-04-01 20:26:43 +00:00
|
|
|
|
|
|
|
device_free(device, dscene, scene);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
KernelFilm *kfilm = &dscene->data.film;
|
2014-02-10 20:44:49 +00:00
|
|
|
KernelIntegrator *kintegrator = &dscene->data.integrator;
|
|
|
|
|
|
|
|
bool use_clamping = (kintegrator->sample_clamp_direct != FLT_MAX) || (kintegrator->sample_clamp_indirect != FLT_MAX);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* 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;
|
2014-02-10 20:44:49 +00:00
|
|
|
kfilm->use_light_pass = use_light_visibility || use_clamping;
|
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
|
|
|
|
|
|
|
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;
|
2013-06-07 12:45:26 +00:00
|
|
|
case PASS_MIST:
|
|
|
|
kfilm->pass_mist = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
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
|
|
|
case PASS_NORMAL:
|
|
|
|
kfilm->pass_normal = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_UV:
|
|
|
|
kfilm->pass_uv = kfilm->pass_stride;
|
|
|
|
break;
|
2012-04-30 12:49:26 +00:00
|
|
|
case PASS_MOTION:
|
|
|
|
kfilm->pass_motion = kfilm->pass_stride;
|
|
|
|
break;
|
|
|
|
case PASS_MOTION_WEIGHT:
|
|
|
|
kfilm->pass_motion_weight = kfilm->pass_stride;
|
|
|
|
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
|
|
|
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;
|
2013-08-03 13:12:09 +00:00
|
|
|
case PASS_SUBSURFACE_COLOR:
|
|
|
|
kfilm->pass_subsurface_color = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
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
|
|
|
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;
|
2013-08-03 13:12:09 +00:00
|
|
|
case PASS_SUBSURFACE_INDIRECT:
|
|
|
|
kfilm->pass_subsurface_indirect = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
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
|
|
|
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;
|
2013-08-03 13:12:09 +00:00
|
|
|
case PASS_SUBSURFACE_DIRECT:
|
|
|
|
kfilm->pass_subsurface_direct = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
|
|
|
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
|
|
|
|
|
|
|
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;
|
2013-07-14 13:19:57 +00:00
|
|
|
break;
|
2012-02-28 16:45:08 +00:00
|
|
|
case PASS_AO:
|
|
|
|
kfilm->pass_ao = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
2013-07-14 13:19:57 +00:00
|
|
|
break;
|
2012-03-28 10:39:21 +00:00
|
|
|
case PASS_SHADOW:
|
|
|
|
kfilm->pass_shadow = kfilm->pass_stride;
|
|
|
|
kfilm->use_light_pass = 1;
|
2013-07-14 13:19:57 +00:00
|
|
|
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
|
|
|
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);
|
2014-02-06 14:18:34 +00:00
|
|
|
kfilm->pass_alpha_threshold = pass_alpha_threshold;
|
2012-01-27 13:58:32 +00:00
|
|
|
|
2013-04-01 20:26:43 +00:00
|
|
|
/* update filter table */
|
|
|
|
vector<float> table = filter_table(filter_type, filter_width);
|
|
|
|
filter_table_offset = scene->lookup_tables->add_table(dscene, table);
|
|
|
|
kfilm->filter_table_offset = (int)filter_table_offset;
|
|
|
|
|
2013-06-07 12:45:26 +00:00
|
|
|
/* mist pass parameters */
|
|
|
|
kfilm->mist_start = mist_start;
|
|
|
|
kfilm->mist_inv_depth = (mist_depth > 0.0f)? 1.0f/mist_depth: 0.0f;
|
|
|
|
kfilm->mist_falloff = mist_falloff;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
need_update = false;
|
|
|
|
}
|
|
|
|
|
2013-04-01 20:26:43 +00:00
|
|
|
void Film::device_free(Device *device, DeviceScene *dscene, Scene *scene)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2013-04-01 20:26:52 +00:00
|
|
|
if(filter_table_offset != TABLE_OFFSET_INVALID) {
|
2013-04-01 20:26:43 +00:00
|
|
|
scene->lookup_tables->remove_table(filter_table_offset);
|
2013-04-01 20:26:52 +00:00
|
|
|
filter_table_offset = TABLE_OFFSET_INVALID;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2013-04-01 20:26:43 +00:00
|
|
|
&& Pass::equals(passes, film.passes)
|
2014-02-06 14:18:34 +00:00
|
|
|
&& pass_alpha_threshold == film.pass_alpha_threshold
|
2013-04-01 20:26:43 +00:00
|
|
|
&& filter_type == film.filter_type
|
2014-02-06 14:18:34 +00:00
|
|
|
&& filter_width == film.filter_width
|
|
|
|
&& mist_start == film.mist_start
|
|
|
|
&& mist_depth == film.mist_depth
|
|
|
|
&& mist_falloff == film.mist_falloff);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-06-20 14:24:52 +00:00
|
|
|
void Film::tag_passes_update(Scene *scene, const vector<Pass>& passes_)
|
|
|
|
{
|
2013-09-13 14:31:28 +00:00
|
|
|
if(Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) {
|
2012-06-20 14:24:52 +00:00
|
|
|
scene->mesh_manager->tag_update(scene);
|
2013-09-13 14:31:28 +00:00
|
|
|
|
|
|
|
foreach(Shader *shader, scene->shaders)
|
|
|
|
shader->need_update_attributes = true;
|
|
|
|
}
|
2012-06-20 14:24:52 +00:00
|
|
|
else if(Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION))
|
|
|
|
scene->mesh_manager->tag_update(scene);
|
|
|
|
|
|
|
|
passes = passes_;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void Film::tag_update(Scene *scene)
|
|
|
|
{
|
|
|
|
need_update = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|