Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-07-18 12:25:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-07-18 12:25:44 +0300
commit9186b9ae4806f4bbc1a14417c408e844f8e8cc1a (patch)
tree117bbd4ace75825e3a65f0ba2a447509bde0df85 /intern
parentcfbd605567f48229a923df382baf6db98fbafc61 (diff)
parent9946cca14676bf07b3c7c103e99033fe1e4e423e (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/addon/properties.py5
-rw-r--r--intern/cycles/blender/addon/ui.py1
-rw-r--r--intern/cycles/blender/blender_sync.cpp1
-rw-r--r--intern/cycles/bvh/bvh.cpp10
-rw-r--r--intern/cycles/device/device_opencl.cpp79
-rw-r--r--intern/cycles/kernel/bvh/bvh_shadow_all.h2
-rw-r--r--intern/cycles/kernel/bvh/bvh_volume_all.h4
-rw-r--r--intern/cycles/kernel/bvh/qbvh_shadow_all.h2
-rw-r--r--intern/cycles/kernel/bvh/qbvh_volume_all.h4
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet.h79
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet_multi.h6
-rw-r--r--intern/cycles/kernel/closure/bsdf_util.h2
-rw-r--r--intern/cycles/kernel/geom/geom_triangle_intersect.h9
-rw-r--r--intern/cycles/kernel/kernel_shadow.h7
-rw-r--r--intern/cycles/kernel/svm/svm_tex_coord.h10
-rw-r--r--intern/cycles/render/integrator.cpp2
-rw-r--r--intern/cycles/render/mesh.cpp6
-rw-r--r--intern/cycles/render/nodes.cpp84
-rw-r--r--intern/cycles/render/object.cpp2
-rw-r--r--intern/cycles/render/scene.h3
-rw-r--r--intern/cycles/util/util_math_fast.h3
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp3
-rw-r--r--intern/guardedalloc/test/simpletest/memtest.c1
-rw-r--r--intern/libmv/libmv/multiview/projection.h2
-rw-r--r--intern/libmv/libmv/numeric/numeric.h2
-rw-r--r--intern/opensubdiv/opensubdiv_converter.cc5
26 files changed, 205 insertions, 129 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index bf84517a082..04feb979165 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -503,6 +503,11 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
description="Use BVH spatial splits: longer builder time, faster render",
default=False,
)
+ cls.debug_use_hair_bvh = BoolProperty(
+ name="Use Hair BVH",
+ description="Use special type BVH optimized for hair. Uses more ram but renders faster",
+ default=True,
+ )
cls.tile_order = EnumProperty(
name="Tile Order",
description="Tile order for rendering",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 3c9c83fec42..6faec5e013b 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -401,6 +401,7 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
col.label(text="Acceleration structure:")
col.prop(cscene, "debug_use_spatial_splits")
+ col.prop(cscene, "debug_use_hair_bvh")
class CyclesRender_PT_layer_options(CyclesButtonsPanel, Panel):
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index a7ede3094ac..be395b9f253 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -484,6 +484,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
SceneParams::BVH_STATIC);
params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
+ params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
if(background && params.shadingsystem != SHADINGSYSTEM_OSL)
params.persistent_data = r.use_persistent_data();
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index e92526ac1c4..1bb3e95c810 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -463,8 +463,7 @@ void RegularBVH::pack_aligned_inner(const BVHStackEntry& e,
pack_aligned_node(e.idx,
e0.node->m_bounds, e1.node->m_bounds,
e0.encodeIdx(), e1.encodeIdx(),
- e0.node->m_visibility & ~PATH_RAY_NODE_UNALIGNED,
- e1.node->m_visibility & ~PATH_RAY_NODE_UNALIGNED);
+ e0.node->m_visibility, e1.node->m_visibility);
}
void RegularBVH::pack_aligned_node(int idx,
@@ -475,7 +474,8 @@ void RegularBVH::pack_aligned_node(int idx,
{
int4 data[BVH_NODE_SIZE] =
{
- make_int4(visibility0, visibility1, c0, c1),
+ make_int4(visibility0 & ~PATH_RAY_NODE_UNALIGNED,
+ visibility1 & ~PATH_RAY_NODE_UNALIGNED, c0, c1),
make_int4(__float_as_int(b0.min.x), __float_as_int(b1.min.x), __float_as_int(b0.max.x), __float_as_int(b1.max.x)),
make_int4(__float_as_int(b0.min.y), __float_as_int(b1.min.y), __float_as_int(b0.max.y), __float_as_int(b1.max.y)),
make_int4(__float_as_int(b0.min.z), __float_as_int(b1.min.z), __float_as_int(b0.max.z), __float_as_int(b1.max.z)),
@@ -688,9 +688,7 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
leaf_data[0].y = __int_as_float(c1);
leaf_data[0].z = __uint_as_float(visibility);
leaf_data[0].w = __uint_as_float(data[0].w);
- memcpy(&pack.leaf_nodes[idx * BVH_NODE_LEAF_SIZE],
- leaf_data,
- sizeof(float4)*BVH_NODE_LEAF_SIZE);
+ memcpy(&pack.leaf_nodes[idx], leaf_data, sizeof(float4)*BVH_NODE_LEAF_SIZE);
}
else {
int4 *data = &pack.nodes[idx];
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index afe21c49730..50490f3a20e 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -795,7 +795,7 @@ public:
bool load_binary(const string& /*kernel_path*/,
const string& clbin,
- string custom_kernel_build_options,
+ const string& custom_kernel_build_options,
cl_program *program,
const string *debug_src = NULL)
{
@@ -848,7 +848,7 @@ public:
}
bool build_kernel(cl_program *kernel_program,
- string custom_kernel_build_options,
+ const string& custom_kernel_build_options,
const string *debug_src = NULL)
{
string build_options;
@@ -881,30 +881,39 @@ public:
return true;
}
- bool compile_kernel(const string& kernel_path,
- string source,
- string custom_kernel_build_options,
+ bool compile_kernel(const string& kernel_name,
+ const string& kernel_path,
+ const string& source,
+ const string& custom_kernel_build_options,
cl_program *kernel_program,
const string *debug_src = NULL)
{
- /* we compile kernels consisting of many files. unfortunately opencl
+ /* We compile kernels consisting of many files. unfortunately OpenCL
* kernel caches do not seem to recognize changes in included files.
- * so we force recompile on changes by adding the md5 hash of all files */
- source = path_source_replace_includes(source, kernel_path);
+ * so we force recompile on changes by adding the md5 hash of all files.
+ */
+ string inlined_source = path_source_replace_includes(source,
+ kernel_path);
- if(debug_src)
- path_write_text(*debug_src, source);
+ if(debug_src) {
+ path_write_text(*debug_src, inlined_source);
+ }
- size_t source_len = source.size();
- const char *source_str = source.c_str();
+ size_t source_len = inlined_source.size();
+ const char *source_str = inlined_source.c_str();
- *kernel_program = clCreateProgramWithSource(cxContext, 1, &source_str, &source_len, &ciErr);
+ *kernel_program = clCreateProgramWithSource(cxContext,
+ 1,
+ &source_str,
+ &source_len,
+ &ciErr);
- if(opencl_error(ciErr))
+ if(opencl_error(ciErr)) {
return false;
+ }
double starttime = time_dt();
- printf("Compiling OpenCL kernel ...\n");
+ printf("Compiling %s OpenCL kernel ...\n", kernel_name.c_str());
/* TODO(sergey): Report which kernel is being compiled
* as well (megakernel or which of split kernels etc..).
*/
@@ -1004,7 +1013,8 @@ public:
string init_kernel_source = "#include \"kernels/opencl/kernel.cl\" // " + kernel_md5 + "\n";
/* If does not exist or loading binary failed, compile kernel. */
- if(!compile_kernel(kernel_path,
+ if(!compile_kernel("base_kernel",
+ kernel_path,
init_kernel_source,
build_flags,
&cpProgram,
@@ -1694,7 +1704,8 @@ public:
string init_kernel_source = "#include \"kernels/opencl/kernel.cl\" // " +
kernel_md5 + "\n";
/* If does not exist or loading binary failed, compile kernel. */
- if(!compile_kernel(kernel_path,
+ if(!compile_kernel("mega_kernel",
+ kernel_path,
init_kernel_source,
custom_kernel_build_options,
&path_trace_program,
@@ -2078,30 +2089,33 @@ public:
/* TODO(sergey): Seems really close to load_kernel(),
* could it be de-duplicated?
*/
- bool load_split_kernel(string kernel_path,
- string kernel_init_source,
- string clbin,
- string custom_kernel_build_options,
+ bool load_split_kernel(const string& kernel_name,
+ const string& kernel_path,
+ const string& kernel_init_source,
+ const string& clbin,
+ const string& custom_kernel_build_options,
cl_program *program,
const string *debug_src = NULL)
{
- if(!opencl_version_check())
+ if(!opencl_version_check()) {
return false;
+ }
- clbin = path_user_get(path_join("cache", clbin));
+ string cache_clbin = path_user_get(path_join("cache", clbin));
/* If exists already, try use it. */
- if(path_exists(clbin) && load_binary(kernel_path,
- clbin,
- custom_kernel_build_options,
- program,
- debug_src))
+ if(path_exists(cache_clbin) && load_binary(kernel_path,
+ cache_clbin,
+ custom_kernel_build_options,
+ program,
+ debug_src))
{
/* Kernel loaded from binary. */
}
else {
/* If does not exist or loading binary failed, compile kernel. */
- if(!compile_kernel(kernel_path,
+ if(!compile_kernel(kernel_name,
+ kernel_path,
kernel_init_source,
custom_kernel_build_options,
program,
@@ -2110,7 +2124,7 @@ public:
return false;
}
/* Save binary for reuse. */
- if(!save_binary(program, clbin)) {
+ if(!save_binary(program, cache_clbin)) {
return false;
}
}
@@ -2208,7 +2222,10 @@ public:
clsrc = path_user_get(path_join("cache", clsrc)); \
debug_src = &clsrc; \
} \
- if(!load_split_kernel(kernel_path, kernel_init_source, clbin, \
+ if(!load_split_kernel(#name, \
+ kernel_path, \
+ kernel_init_source, \
+ clbin, \
build_options, \
&GLUE(name, _program), \
debug_src)) \
diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h
index 1869457f0c3..b27afaa9869 100644
--- a/intern/cycles/kernel/bvh/bvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h
@@ -283,7 +283,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
return true;
}
/* if maximum number of hits reached, block all light */
- else if(*num_hits == max_hits) {
+ else if(*num_hits >= max_hits) {
return true;
}
diff --git a/intern/cycles/kernel/bvh/bvh_volume_all.h b/intern/cycles/kernel/bvh/bvh_volume_all.h
index b5405e8e57b..d7f6bf86c71 100644
--- a/intern/cycles/kernel/bvh/bvh_volume_all.h
+++ b/intern/cycles/kernel/bvh/bvh_volume_all.h
@@ -206,7 +206,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
#if BVH_FEATURE(BVH_INSTANCING)
num_hits_in_instance++;
#endif
- if(num_hits == max_hits) {
+ if(num_hits >= max_hits) {
#if BVH_FEATURE(BVH_INSTANCING)
# if BVH_FEATURE(BVH_MOTION)
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
@@ -252,7 +252,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
# if BVH_FEATURE(BVH_INSTANCING)
num_hits_in_instance++;
# endif
- if(num_hits == max_hits) {
+ if(num_hits >= max_hits) {
# if BVH_FEATURE(BVH_INSTANCING)
# if BVH_FEATURE(BVH_MOTION)
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
diff --git a/intern/cycles/kernel/bvh/qbvh_shadow_all.h b/intern/cycles/kernel/bvh/qbvh_shadow_all.h
index 34753ff067d..eb98eaf7455 100644
--- a/intern/cycles/kernel/bvh/qbvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/qbvh_shadow_all.h
@@ -366,7 +366,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
return true;
}
/* if maximum number of hits reached, block all light */
- else if(*num_hits == max_hits) {
+ else if(*num_hits >= max_hits) {
return true;
}
diff --git a/intern/cycles/kernel/bvh/qbvh_volume_all.h b/intern/cycles/kernel/bvh/qbvh_volume_all.h
index a877e5bb341..90cad9d91c0 100644
--- a/intern/cycles/kernel/bvh/qbvh_volume_all.h
+++ b/intern/cycles/kernel/bvh/qbvh_volume_all.h
@@ -273,7 +273,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
#if BVH_FEATURE(BVH_INSTANCING)
num_hits_in_instance++;
#endif
- if(num_hits == max_hits) {
+ if(num_hits >= max_hits) {
#if BVH_FEATURE(BVH_INSTANCING)
# if BVH_FEATURE(BVH_MOTION)
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
@@ -312,7 +312,7 @@ ccl_device uint BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
# if BVH_FEATURE(BVH_INSTANCING)
num_hits_in_instance++;
# endif
- if(num_hits == max_hits) {
+ if(num_hits >= max_hits) {
# if BVH_FEATURE(BVH_INSTANCING)
# if BVH_FEATURE(BVH_MOTION)
float t_fac = 1.0f / len(transform_direction(&ob_itfm, dir));
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index aa21633070a..7bf7c2806d4 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -615,6 +615,36 @@ ccl_device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness
sc->data1 = fmaxf(roughness, sc->data1); /* alpha_y */
}
+ccl_device_inline float bsdf_beckmann_G1(float alpha, float cos_n)
+{
+ cos_n *= cos_n;
+ float invA = alpha * safe_sqrtf((1.0f - cos_n) / cos_n);
+ if(invA < 0.625f) {
+ return 1.0f;
+ }
+
+ float a = 1.0f / invA;
+ return ((2.181f*a + 3.535f)*a) / ((2.577f*a + 2.276f)*a + 1.0f);
+}
+
+ccl_device_inline float bsdf_beckmann_aniso_G1(float alpha_x, float alpha_y, float cos_n, float cos_phi, float sin_phi)
+{
+ cos_n *= cos_n;
+ sin_phi *= sin_phi;
+ cos_phi *= cos_phi;
+ alpha_x *= alpha_x;
+ alpha_y *= alpha_y;
+
+ float alphaO2 = (cos_phi*alpha_x + sin_phi*alpha_y) / (cos_phi + sin_phi);
+ float invA = safe_sqrtf(alphaO2 * (1 - cos_n) / cos_n);
+ if(invA < 0.625f) {
+ return 1.0f;
+ }
+
+ float a = 1.0f / invA;
+ return ((2.181f*a + 3.535f)*a) / ((2.577f*a + 2.276f)*a + 1.0f);
+}
+
ccl_device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
float alpha_x = sc->data0;
@@ -646,10 +676,8 @@ ccl_device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc,
D = expf(-tanThetaM2 / alpha2) / (M_PI_F * alpha2 * cosThetaM4);
/* eq. 26, 27: now calculate G1(i,m) and G1(o,m) */
- float ao = 1 / (alpha_x * safe_sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (alpha_x * safe_sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
- G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
- G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
+ G1o = bsdf_beckmann_G1(alpha_x, cosNO);
+ G1i = bsdf_beckmann_G1(alpha_x, cosNI);
}
else {
/* anisotropic */
@@ -668,24 +696,8 @@ ccl_device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc,
D = expf(-slope_x*slope_x - slope_y*slope_y) / (M_PI_F * alpha2 * cosThetaM4);
/* G1(i,m) and G1(o,m) */
- float tanThetaO2 = (1 - cosNO * cosNO) / (cosNO * cosNO);
- float cosPhiO = dot(I, X);
- float sinPhiO = dot(I, Y);
-
- float alphaO2 = (cosPhiO*cosPhiO)*(alpha_x*alpha_x) + (sinPhiO*sinPhiO)*(alpha_y*alpha_y);
- alphaO2 /= cosPhiO*cosPhiO + sinPhiO*sinPhiO;
-
- float tanThetaI2 = (1 - cosNI * cosNI) / (cosNI * cosNI);
- float cosPhiI = dot(omega_in, X);
- float sinPhiI = dot(omega_in, Y);
-
- float alphaI2 = (cosPhiI*cosPhiI)*(alpha_x*alpha_x) + (sinPhiI*sinPhiI)*(alpha_y*alpha_y);
- alphaI2 /= cosPhiI*cosPhiI + sinPhiI*sinPhiI;
-
- float ao = 1 / (safe_sqrtf(alphaO2 * tanThetaO2));
- float ai = 1 / (safe_sqrtf(alphaI2 * tanThetaI2));
- G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
- G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
+ G1o = bsdf_beckmann_aniso_G1(alpha_x, alpha_y, cosNO, dot(I, X), dot(I, Y));
+ G1i = bsdf_beckmann_aniso_G1(alpha_x, alpha_y, cosNI, dot(omega_in, X), dot(omega_in, Y));
}
float G = G1o * G1i;
@@ -740,10 +752,8 @@ ccl_device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc
float D = expf(-tanThetaM2 / alpha2) / (M_PI_F * alpha2 * cosThetaM4);
/* eq. 26, 27: now calculate G1(i,m) and G1(o,m) */
- float ao = 1 / (alpha_x * safe_sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (alpha_x * safe_sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
- float G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
- float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
+ float G1o = bsdf_beckmann_G1(alpha_x, cosNO);
+ float G1i = bsdf_beckmann_G1(alpha_x, cosNI);
float G = G1o * G1i;
/* probability */
@@ -820,8 +830,7 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg, const ShaderCl
float cosNI = dot(N, *omega_in);
/* eq. 26, 27: now calculate G1(i,m) */
- float ai = 1 / (alpha_x * safe_sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
- G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
+ G1i = bsdf_beckmann_G1(alpha_x, cosNI);
}
else {
/* anisotropic distribution */
@@ -836,16 +845,7 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg, const ShaderCl
D = expf(-slope_x*slope_x - slope_y*slope_y) / (M_PI_F * alpha2 * cosThetaM4);
/* G1(i,m) */
- float cosNI = dot(N, *omega_in);
- float tanThetaI2 = (1 - cosNI * cosNI) / (cosNI * cosNI);
- float cosPhiI = dot(*omega_in, X);
- float sinPhiI = dot(*omega_in, Y);
-
- float alphaI2 = (cosPhiI*cosPhiI)*(alpha_x*alpha_x) + (sinPhiI*sinPhiI)*(alpha_y*alpha_y);
- alphaI2 /= cosPhiI*cosPhiI + sinPhiI*sinPhiI;
-
- float ai = 1 / (safe_sqrtf(alphaI2 * tanThetaI2));
- G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
+ G1i = bsdf_beckmann_aniso_G1(alpha_x, alpha_y, dot(*omega_in, N), dot(*omega_in, X), dot(*omega_in, Y));
}
float G = G1o * G1i;
@@ -906,8 +906,7 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg, const ShaderCl
float cosNI = dot(N, *omega_in);
/* eq. 26, 27: now calculate G1(i,m) */
- float ai = 1 / (alpha_x * safe_sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
- float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
+ float G1i = bsdf_beckmann_G1(alpha_x, cosNI);
float G = G1o * G1i;
/* eq. 21 */
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
index 6060d7d8ccb..51b12fe4e45 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
@@ -348,11 +348,7 @@ ccl_device int bsdf_microfacet_multi_ggx_common_setup(ShaderClosure *sc)
ccl_device int bsdf_microfacet_multi_ggx_aniso_setup(ShaderClosure *sc)
{
-#ifdef __KERNEL_OPENCL__
- if(all(sc->T == 0.0f))
-#else
- if(sc->T == make_float3(0.0f, 0.0f, 0.0f))
-#endif
+ if(is_zero(sc->T))
sc->T = make_float3(1.0f, 0.0f, 0.0f);
return bsdf_microfacet_multi_ggx_common_setup(sc);
diff --git a/intern/cycles/kernel/closure/bsdf_util.h b/intern/cycles/kernel/closure/bsdf_util.h
index 89b1998d1ce..b0c5280b6cb 100644
--- a/intern/cycles/kernel/closure/bsdf_util.h
+++ b/intern/cycles/kernel/closure/bsdf_util.h
@@ -80,7 +80,7 @@ ccl_device float fresnel_dielectric(
return 1; // total internal reflection
}
else {
- float dnp = sqrtf(arg);
+ float dnp = max(sqrtf(arg), 1e-7f);
float nK = (neta * cos)- dnp;
*T = -(neta * I)+(nK * Nn);
#ifdef __RAY_DIFFERENTIALS__
diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index fc081bda525..720ee6a1f5c 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -255,6 +255,13 @@ ccl_device_inline void triangle_intersect_subsurface(
/* Normalize U, V, W, and T. */
const float inv_det = 1.0f / det;
+ const float t = T * inv_det;
+ for(int i = min(max_hits, ss_isect->num_hits); i >= 0; --i) {
+ if(ss_isect->hits[i].t == t) {
+ return;
+ }
+ }
+
ss_isect->num_hits++;
int hit;
@@ -277,7 +284,7 @@ ccl_device_inline void triangle_intersect_subsurface(
isect->type = PRIMITIVE_TRIANGLE;
isect->u = U * inv_det;
isect->v = V * inv_det;
- isect->t = T * inv_det;
+ isect->t = t;
/* Record geometric normal. */
/* TODO(sergey): Use float4_to_float3() on just an edges. */
diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h
index db2fc84834a..d1576754d2e 100644
--- a/intern/cycles/kernel/kernel_shadow.h
+++ b/intern/cycles/kernel/kernel_shadow.h
@@ -75,7 +75,12 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ShaderData *shadow_sd,
}
uint num_hits;
- blocked = scene_intersect_shadow_all(kg, ray, hits, max_hits, &num_hits);
+ if(max_hits == 0) {
+ blocked = true;
+ num_hits = 0;
+ } else {
+ blocked = scene_intersect_shadow_all(kg, ray, hits, max_hits, &num_hits);
+ }
/* if no opaque surface found but we did find transparent hits, shade them */
if(!blocked && num_hits > 0) {
diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h
index 27fed89fdf7..276b6f26f5e 100644
--- a/intern/cycles/kernel/svm/svm_tex_coord.h
+++ b/intern/cycles/kernel/svm/svm_tex_coord.h
@@ -312,7 +312,7 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
/* apply normal map */
float3 B = sign * cross(normal, tangent);
- N = normalize(color.x * tangent + color.y * B + color.z * normal);
+ N = safe_normalize(color.x * tangent + color.y * B + color.z * normal);
/* transform to world space */
object_normal_transform(kg, sd, &N);
@@ -330,14 +330,18 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
if(space == NODE_NORMAL_MAP_OBJECT || space == NODE_NORMAL_MAP_BLENDER_OBJECT)
object_normal_transform(kg, sd, &N);
else
- N = normalize(N);
+ N = safe_normalize(N);
}
float strength = stack_load_float(stack, strength_offset);
if(strength != 1.0f) {
strength = max(strength, 0.0f);
- N = normalize(ccl_fetch(sd, N) + (N - ccl_fetch(sd, N))*strength);
+ N = safe_normalize(ccl_fetch(sd, N) + (N - ccl_fetch(sd, N))*strength);
+ }
+
+ if(is_zero(N)) {
+ N = ccl_fetch(sd, N);
}
stack_store_float3(stack, normal_offset, N);
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index 2a10eb474a4..63914e57319 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -176,7 +176,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
max_samples = max(max_samples, volume_samples);
}
- max_samples *= (max_bounce + transparent_max_bounce + 3);
+ max_samples *= (max_bounce + transparent_max_bounce + 3 + BSSRDF_MAX_HITS);
int dimensions = PRNG_BASE_NUM + max_samples*PRNG_BOUNCE_NUM;
dimensions = min(dimensions, SOBOL_MAX_DIMENSIONS);
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 661719ed545..8b0ed9f77b2 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -588,7 +588,8 @@ void Mesh::compute_bvh(DeviceScene *dscene,
BVHParams bparams;
bparams.use_spatial_split = params->use_bvh_spatial_split;
bparams.use_qbvh = params->use_qbvh;
- bparams.use_unaligned_nodes = dscene->data.bvh.have_curves;
+ bparams.use_unaligned_nodes = dscene->data.bvh.have_curves &&
+ params->use_bvh_unaligned_nodes;
delete bvh;
bvh = BVH::create(bparams, objects);
@@ -1222,7 +1223,8 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *
bparams.top_level = true;
bparams.use_qbvh = scene->params.use_qbvh;
bparams.use_spatial_split = scene->params.use_bvh_spatial_split;
- bparams.use_unaligned_nodes = dscene->data.bvh.have_curves;
+ bparams.use_unaligned_nodes = dscene->data.bvh.have_curves &&
+ scene->params.use_bvh_unaligned_nodes;
delete bvh;
bvh = BVH::create(bparams, scene->objects);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 15b55d17301..a8fd9da9ced 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1576,7 +1576,9 @@ RGBToBWNode::RGBToBWNode()
{
}
-bool RGBToBWNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool RGBToBWNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
optimized->set(linear_rgb_to_gray(color));
@@ -1661,7 +1663,9 @@ ConvertNode::ConvertNode(SocketType::Type from_, SocketType::Type to_, bool auto
special_type = SHADER_SPECIAL_TYPE_AUTOCONVERT;
}
-bool ConvertNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool ConvertNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
/* proxy nodes should have been removed at this point */
assert(special_type != SHADER_SPECIAL_TYPE_PROXY);
@@ -2362,7 +2366,9 @@ void EmissionNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_emission");
}
-bool EmissionNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *)
+bool EmissionNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput * /*optimized*/)
{
ShaderInput *color_in = input("Color");
ShaderInput *strength_in = input("Strength");
@@ -2412,7 +2418,9 @@ void BackgroundNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_background");
}
-bool BackgroundNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *)
+bool BackgroundNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput * /*optimized*/)
{
ShaderInput *color_in = input("Color");
ShaderInput *strength_in = input("Strength");
@@ -3380,7 +3388,9 @@ ValueNode::ValueNode()
{
}
-bool ValueNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool ValueNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
optimized->set(value);
return true;
@@ -3416,7 +3426,9 @@ ColorNode::ColorNode()
{
}
-bool ColorNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool ColorNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
optimized->set(value);
return true;
@@ -3499,7 +3511,9 @@ void MixClosureNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_mix_closure");
}
-bool MixClosureNode::constant_fold(ShaderGraph *graph, ShaderOutput *, ShaderInput *)
+bool MixClosureNode::constant_fold(ShaderGraph *graph,
+ ShaderOutput * /*socket*/,
+ ShaderInput * /*optimized*/)
{
ShaderInput *fac_in = input("Fac");
ShaderInput *closure1_in = input("Closure1");
@@ -3589,7 +3603,9 @@ InvertNode::InvertNode()
{
}
-bool InvertNode::constant_fold(ShaderGraph *graph, ShaderOutput *, ShaderInput *optimized)
+bool InvertNode::constant_fold(ShaderGraph *graph,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
ShaderInput *fac_in = input("Fac");
ShaderInput *color_in = input("Color");
@@ -3697,7 +3713,9 @@ void MixNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_mix");
}
-bool MixNode::constant_fold(ShaderGraph *graph, ShaderOutput *, ShaderInput *optimized)
+bool MixNode::constant_fold(ShaderGraph *graph,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
ShaderInput *fac_in = input("Fac");
ShaderInput *color1_in = input("Color1");
@@ -3774,7 +3792,9 @@ CombineRGBNode::CombineRGBNode()
{
}
-bool CombineRGBNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool CombineRGBNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
optimized->set(make_float3(r, g, b));
@@ -3829,7 +3849,9 @@ CombineXYZNode::CombineXYZNode()
{
}
-bool CombineXYZNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool CombineXYZNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
optimized->set(make_float3(x, y, z));
@@ -3884,7 +3906,9 @@ CombineHSVNode::CombineHSVNode()
{
}
-bool CombineHSVNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool CombineHSVNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
optimized->set(hsv_to_rgb(make_float3(h, s, v)));
@@ -3932,7 +3956,9 @@ GammaNode::GammaNode()
{
}
-bool GammaNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool GammaNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
optimized->set(svm_math_gamma_color(color, gamma));
@@ -3979,7 +4005,9 @@ BrightContrastNode::BrightContrastNode()
{
}
-bool BrightContrastNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool BrightContrastNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
optimized->set(svm_brightness_contrast(color, bright, contrast));
@@ -4029,7 +4057,9 @@ SeparateRGBNode::SeparateRGBNode()
{
}
-bool SeparateRGBNode::constant_fold(ShaderGraph *, ShaderOutput *socket, ShaderInput *optimized)
+bool SeparateRGBNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput *socket,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
for(int channel = 0; channel < 3; channel++) {
@@ -4088,7 +4118,9 @@ SeparateXYZNode::SeparateXYZNode()
{
}
-bool SeparateXYZNode::constant_fold(ShaderGraph *, ShaderOutput *socket, ShaderInput *optimized)
+bool SeparateXYZNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput *socket,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
for(int channel = 0; channel < 3; channel++) {
@@ -4147,7 +4179,9 @@ SeparateHSVNode::SeparateHSVNode()
{
}
-bool SeparateHSVNode::constant_fold(ShaderGraph *, ShaderOutput *socket, ShaderInput *optimized)
+bool SeparateHSVNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput *socket,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
float3 hsv = rgb_to_hsv(color);
@@ -4546,7 +4580,9 @@ BlackbodyNode::BlackbodyNode()
{
}
-bool BlackbodyNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool BlackbodyNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
optimized->set(svm_math_blackbody_color(temperature));
@@ -4655,7 +4691,9 @@ MathNode::MathNode()
{
}
-bool MathNode::constant_fold(ShaderGraph *, ShaderOutput *, ShaderInput *optimized)
+bool MathNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput * /*socket*/,
+ ShaderInput *optimized)
{
if(all_inputs_constant()) {
float value = svm_math(type, value1, value2);
@@ -4717,7 +4755,9 @@ VectorMathNode::VectorMathNode()
{
}
-bool VectorMathNode::constant_fold(ShaderGraph *, ShaderOutput *socket, ShaderInput *optimized)
+bool VectorMathNode::constant_fold(ShaderGraph * /*graph*/,
+ ShaderOutput *socket,
+ ShaderInput *optimized)
{
float value;
float3 vector;
@@ -4873,7 +4913,9 @@ void BumpNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_bump");
}
-bool BumpNode::constant_fold(ShaderGraph *graph, ShaderOutput *, ShaderInput *)
+bool BumpNode::constant_fold(ShaderGraph *graph,
+ ShaderOutput * /*socket*/,
+ ShaderInput * /*optimized*/)
{
ShaderInput *height_in = input("Height");
ShaderInput *normal_in = input("Normal");
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp
index ff1f678c2d2..662d87e8b6b 100644
--- a/intern/cycles/render/object.cpp
+++ b/intern/cycles/render/object.cpp
@@ -184,7 +184,7 @@ void Object::apply_transform(bool apply_to_motion)
}
/* tfm is not reset to identity, all code that uses it needs to check the
- transform_applied boolean */
+ * transform_applied boolean */
}
void Object::tag_update(Scene *scene)
diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h
index 925e84ad96d..5abcbfcdaad 100644
--- a/intern/cycles/render/scene.h
+++ b/intern/cycles/render/scene.h
@@ -136,6 +136,7 @@ public:
BVH_NUM_TYPES,
} bvh_type;
bool use_bvh_spatial_split;
+ bool use_bvh_unaligned_nodes;
bool use_qbvh;
bool persistent_data;
@@ -144,6 +145,7 @@ public:
shadingsystem = SHADINGSYSTEM_SVM;
bvh_type = BVH_DYNAMIC;
use_bvh_spatial_split = false;
+ use_bvh_unaligned_nodes = true;
use_qbvh = false;
persistent_data = false;
}
@@ -152,6 +154,7 @@ public:
{ return !(shadingsystem == params.shadingsystem
&& bvh_type == params.bvh_type
&& use_bvh_spatial_split == params.use_bvh_spatial_split
+ && use_bvh_unaligned_nodes == params.use_bvh_unaligned_nodes
&& use_qbvh == params.use_qbvh
&& persistent_data == params.persistent_data); }
};
diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h
index deb2013daae..d3960deb3b4 100644
--- a/intern/cycles/util/util_math_fast.h
+++ b/intern/cycles/util/util_math_fast.h
@@ -547,6 +547,9 @@ ccl_device_inline float fast_erff(float x)
const float a5 = 0.0002765672f;
const float a6 = 0.0000430638f;
const float a = fabsf(x);
+ if(a >= 12.3f) {
+ return copysignf(1.0f, x);
+ }
const float b = 1.0f - (1.0f - a); /* Crush denormals. */
const float r = madd(madd(madd(madd(madd(madd(a6, b, a5), b, a4), b, a3), b, a2), b, a1), b, 1.0f);
const float s = r * r; /* ^2 */
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 55d013f6e5f..6f349543eed 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1985,9 +1985,8 @@ GHOST_TSuccess GHOST_SystemX11::pushDragDropEvent(GHOST_TEventType eventType,
);
}
#endif
-/*
+/**
* These callbacks can be used for debugging, so we can breakpoint on an X11 error.
-
*
* Dummy function to get around IO Handler exiting if device invalid
* Basically it will not crash blender now if you have a X device that
diff --git a/intern/guardedalloc/test/simpletest/memtest.c b/intern/guardedalloc/test/simpletest/memtest.c
index 841b47bd4f1..79d55dd02cc 100644
--- a/intern/guardedalloc/test/simpletest/memtest.c
+++ b/intern/guardedalloc/test/simpletest/memtest.c
@@ -26,7 +26,6 @@
*/
/**
-
* Copyright (C) 2001 NaN Technologies B.V.
* Simple test of memory.
*/
diff --git a/intern/libmv/libmv/multiview/projection.h b/intern/libmv/libmv/multiview/projection.h
index 3220bc2dbbc..8f304f31ec6 100644
--- a/intern/libmv/libmv/multiview/projection.h
+++ b/intern/libmv/libmv/multiview/projection.h
@@ -122,7 +122,7 @@ inline void Project(const Mat34 &P, const Vec3 &X, Vec3 *x) {
inline void Project(const Mat34 &P, const Vec3 &X, Vec2 *x) {
Vec3 hx;
- Project(P, X, x);
+ Project(P, X, &hx);
*x = hx.head<2>() / hx(2);
}
diff --git a/intern/libmv/libmv/numeric/numeric.h b/intern/libmv/libmv/numeric/numeric.h
index 20a4a29e5ba..a42dab8c7a2 100644
--- a/intern/libmv/libmv/numeric/numeric.h
+++ b/intern/libmv/libmv/numeric/numeric.h
@@ -148,7 +148,7 @@ using Eigen::Matrix;
// A = U * diag(s) * VT
//
template <typename TMat, typename TVec>
-inline void SVD(TMat *A, Vec *s, Mat *U, Mat *VT) {
+inline void SVD(TMat * /*A*/, Vec * /*s*/, Mat * /*U*/, Mat * /*VT*/) {
assert(0);
}
diff --git a/intern/opensubdiv/opensubdiv_converter.cc b/intern/opensubdiv/opensubdiv_converter.cc
index 3fadde68d32..0ad72c88a12 100644
--- a/intern/opensubdiv/opensubdiv_converter.cc
+++ b/intern/opensubdiv/opensubdiv_converter.cc
@@ -332,7 +332,6 @@ inline bool TopologyRefinerFactory<OpenSubdiv_Converter>::assignComponentTopolog
else {
/* Special handle of non-manifold vertex. */
for (int i = 0; i < num_vert_edges; ++i) {
- bool start_found = false;
edge_start = vert_edges[i];
IndexArray edge_faces = getBaseEdgeFaces(refiner, edge_start);
if (edge_faces.size() == 1) {
@@ -343,14 +342,10 @@ inline bool TopologyRefinerFactory<OpenSubdiv_Converter>::assignComponentTopolog
face_edges = getBaseFaceEdges(refiner, face_start);
face_vert_start = findInArray(face_verts, vert);
if (edge_start == face_edges[face_vert_start]) {
- start_found = true;
break;
}
}
}
- if (start_found) {
- break;
- }
/* Reset indices for sanity check below. */
face_start = edge_start = face_vert_start = -1;
}