Fix T54356: volume rendering bug using just color attribute.

This commit is contained in:
Brecht Van Lommel 2018-03-19 20:18:24 +01:00
parent b8eca8e07d
commit fddb4dee8a
Notes: blender-bot 2023-02-14 10:37:49 +01:00
Referenced by issue #54356, Cycles renders color attribute of volume wrong
2 changed files with 4 additions and 44 deletions

View 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;
}

View 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;
}
}
}
}
}