Fix T54356: volume rendering bug using just color attribute.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 19 Mar 2018 19:18:24 +0000 (20:18 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 19 Mar 2018 20:22:15 +0000 (21:22 +0100)
intern/cycles/kernel/geom/geom_volume.h
intern/cycles/render/mesh_volume.cpp

index a4e4738..346f228 100644 (file)
@@ -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;
        }
index 3571beb..d1c49b4 100644 (file)
@@ -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;
-                                               }
-                                       }
                                }
                        }
                }