diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-03-20 06:13:37 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-03-20 06:13:37 +0300 |
commit | c8a7c4f245391717f10ed4d67e38d955b64a6f44 (patch) | |
tree | 4e64328a93ee3797fed5e3e34031a0be3885a22e /intern/cycles | |
parent | 84536d1d3ce217a44877acdc9845254249c040ce (diff) | |
parent | 8e5c407fc446b35042c626e7d60ff9a2336093f4 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/geom/geom_volume.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_branched.h | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_state.h | 17 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_surface.h | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/split/kernel_next_iteration_setup.h | 5 | ||||
-rw-r--r-- | intern/cycles/render/integrator.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/render/mesh_volume.cpp | 46 |
7 files changed, 27 insertions, 57 deletions
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h index a4e47384b25..346f228e961 100644 --- a/intern/cycles/kernel/geom/geom_volume.h +++ b/intern/cycles/kernel/geom/geom_volume.h @@ -68,7 +68,7 @@ ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *s if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f); if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f); - if(r.w > 1e-8f && r.w != 1.0f) { + if(r.w > 1e-6f && r.w != 1.0f) { /* For RGBA colors, unpremultiply after interpolation. */ return float4_to_float3(r) / r.w; } diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index d43d418db29..66f67c3e2c4 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -567,10 +567,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg, #ifdef __VOLUME__ } else { - /* For volume bounding meshes we pass through without counting transparent - * bounces, only sanity check in case self intersection gets us stuck. */ - state.volume_bounds_bounce++; - if (state.volume_bounds_bounce > VOLUME_BOUNDS_MAX) { + if(!path_state_volume_next(kg, &state)) { break; } } diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h index ff7d1307a6c..90937dbf86e 100644 --- a/intern/cycles/kernel/kernel_path_state.h +++ b/intern/cycles/kernel/kernel_path_state.h @@ -166,6 +166,23 @@ ccl_device_inline void path_state_next(KernelGlobals *kg, ccl_addr_space PathSta #endif } +ccl_device_inline bool path_state_volume_next(KernelGlobals *kg, ccl_addr_space PathState *state) +{ + /* For volume bounding meshes we pass through without counting transparent + * bounces, only sanity check in case self intersection gets us stuck. */ + state->volume_bounds_bounce++; + if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) { + return false; + } + + /* Random number generator next bounce. */ + if(state->volume_bounds_bounce > 1) { + state->rng_offset += PRNG_BOUNCE_NUM; + } + + return true; +} + ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, ccl_addr_space PathState *state) { uint flag = state->flag & PATH_RAY_ALL_VISIBILITY; diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h index bca346d5ee0..27be90d5059 100644 --- a/intern/cycles/kernel/kernel_path_surface.h +++ b/intern/cycles/kernel/kernel_path_surface.h @@ -329,10 +329,7 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg, } #ifdef __VOLUME__ else if(sd->flag & SD_HAS_ONLY_VOLUME) { - /* For volume bounding meshes we pass through without counting transparent - * bounces, only sanity check in case self intersection gets us stuck. */ - state->volume_bounds_bounce++; - if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) { + if(!path_state_volume_next(kg, state)) { return false; } diff --git a/intern/cycles/kernel/split/kernel_next_iteration_setup.h b/intern/cycles/kernel/split/kernel_next_iteration_setup.h index 8092419e796..e388955f1af 100644 --- a/intern/cycles/kernel/split/kernel_next_iteration_setup.h +++ b/intern/cycles/kernel/split/kernel_next_iteration_setup.h @@ -76,10 +76,7 @@ ccl_device void kernel_split_branched_transparent_bounce(KernelGlobals *kg, int # ifdef __VOLUME__ } else { - /* For volume bounding meshes we pass through without counting transparent - * bounces, only sanity check in case self intersection gets us stuck. */ - state->volume_bounds_bounce++; - if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) { + if(!path_state_volume_next(kg, state)) { kernel_split_path_end(kg, ray_index); return; } diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index c337c19ced1..9c276bcab31 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -187,7 +187,9 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene max_samples = max(max_samples, volume_samples); } - uint total_bounces = max_bounce + transparent_max_bounce + 3 + + uint total_bounces = max_bounce + + transparent_max_bounce + 3 + + VOLUME_BOUNDS_MAX + max(BSSRDF_MAX_HITS, BSSRDF_MAX_BOUNCES); max_samples *= total_bounces; diff --git a/intern/cycles/render/mesh_volume.cpp b/intern/cycles/render/mesh_volume.cpp index 3571beb40d6..d1c49b456ff 100644 --- a/intern/cycles/render/mesh_volume.cpp +++ b/intern/cycles/render/mesh_volume.cpp @@ -495,54 +495,14 @@ void MeshManager::create_volume_mesh(Scene *scene, for(size_t i = 0; i < voxel_grids.size(); ++i) { const VoxelAttributeGrid &voxel_grid = voxel_grids[i]; + const int channels = voxel_grid.channels; - if(voxel_grid.channels == 1) { - if(voxel_grid.data[voxel_index] >= isovalue) { + for(int c = 0; c < channels; c++) { + if(voxel_grid.data[voxel_index * channels + c] >= isovalue) { builder.add_node_with_padding(x, y, z); break; } } - else if(voxel_grid.channels == 3) { - voxel_index = compute_voxel_index(resolution, x*3, y, z); - - if(voxel_grid.data[voxel_index] >= isovalue) { - builder.add_node_with_padding(x, y, z); - break; - } - - if(voxel_grid.data[voxel_index + 1] >= isovalue) { - builder.add_node_with_padding(x, y, z); - break; - } - - if(voxel_grid.data[voxel_index + 2] >= isovalue) { - builder.add_node_with_padding(x, y, z); - break; - } - } - else if(voxel_grid.channels == 4) { - voxel_index = compute_voxel_index(resolution, x*4, y, z); - - /* check alpha first */ - if(voxel_grid.data[voxel_index + 3] < isovalue) { - continue; - } - - if(voxel_grid.data[voxel_index] >= isovalue) { - builder.add_node_with_padding(x, y, z); - continue; - } - - if(voxel_grid.data[voxel_index + 1] >= isovalue) { - builder.add_node_with_padding(x, y, z); - continue; - } - - if(voxel_grid.data[voxel_index + 2] >= isovalue) { - builder.add_node_with_padding(x, y, z); - continue; - } - } } } } |