Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/workbench_volume.c
| Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | const int axis = (fds->slice_axis == SLICE_AXIS_AUTO) ? | ||||
| axis_dominant_v3_single(invviewmat[2]) : | axis_dominant_v3_single(invviewmat[2]) : | ||||
| fds->slice_axis - 1; | fds->slice_axis - 1; | ||||
| float dim[3]; | float dim[3]; | ||||
| BKE_object_dimensions_get(ob, dim); | BKE_object_dimensions_get(ob, dim); | ||||
| /* 0.05f to achieve somewhat the same opacity as the full view. */ | /* 0.05f to achieve somewhat the same opacity as the full view. */ | ||||
| float step_length = max_ff(1e-16f, dim[axis] * 0.05f); | float step_length = max_ff(1e-16f, dim[axis] * 0.05f); | ||||
| grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | ||||
| DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); | DRW_shgroup_uniform_block(grp, "world_data", wpd->world_ubo); | ||||
| DRW_shgroup_uniform_float_copy(grp, "slicePosition", fds->slice_depth); | DRW_shgroup_uniform_float_copy(grp, "slicePosition", fds->slice_depth); | ||||
| DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis); | DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis); | ||||
| DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | ||||
| DRW_shgroup_state_disable(grp, DRW_STATE_CULL_FRONT); | DRW_shgroup_state_disable(grp, DRW_STATE_CULL_FRONT); | ||||
| } | } | ||||
| else { | else { | ||||
| double noise_ofs; | double noise_ofs; | ||||
| BLI_halton_1d(3, 0.0, wpd->taa_sample, &noise_ofs); | BLI_halton_1d(3, 0.0, wpd->taa_sample, &noise_ofs); | ||||
| float dim[3], step_length, max_slice; | float dim[3], step_length, max_slice; | ||||
| float slice_ct[3] = {fds->res[0], fds->res[1], fds->res[2]}; | float slice_ct[3] = {fds->res[0], fds->res[1], fds->res[2]}; | ||||
| mul_v3_fl(slice_ct, max_ff(0.001f, fds->slice_per_voxel)); | mul_v3_fl(slice_ct, max_ff(0.001f, fds->slice_per_voxel)); | ||||
| max_slice = max_fff(slice_ct[0], slice_ct[1], slice_ct[2]); | max_slice = max_fff(slice_ct[0], slice_ct[1], slice_ct[2]); | ||||
| BKE_object_dimensions_get(ob, dim); | BKE_object_dimensions_get(ob, dim); | ||||
| invert_v3(slice_ct); | invert_v3(slice_ct); | ||||
| mul_v3_v3(dim, slice_ct); | mul_v3_v3(dim, slice_ct); | ||||
| step_length = len_v3(dim); | step_length = len_v3(dim); | ||||
| grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | ||||
| DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); | DRW_shgroup_uniform_block(grp, "world_data", wpd->world_ubo); | ||||
| DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slice); | DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slice); | ||||
| DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | ||||
| DRW_shgroup_uniform_float_copy(grp, "noiseOfs", noise_ofs); | DRW_shgroup_uniform_float_copy(grp, "noiseOfs", noise_ofs); | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_CULL_FRONT); | DRW_shgroup_state_enable(grp, DRW_STATE_CULL_FRONT); | ||||
| } | } | ||||
| if (fds->use_coba) { | if (fds->use_coba) { | ||||
| if (show_flags) { | if (show_flags) { | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | if (use_slice) { | ||||
| float dim[3]; | float dim[3]; | ||||
| BKE_object_dimensions_get(ob, dim); | BKE_object_dimensions_get(ob, dim); | ||||
| /* 0.05f to achieve somewhat the same opacity as the full view. */ | /* 0.05f to achieve somewhat the same opacity as the full view. */ | ||||
| float step_length = max_ff(1e-16f, dim[axis] * 0.05f); | float step_length = max_ff(1e-16f, dim[axis] * 0.05f); | ||||
| const float slice_position = volume->display.slice_depth; | const float slice_position = volume->display.slice_depth; | ||||
| grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | ||||
| DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); | DRW_shgroup_uniform_block(grp, "world_data", wpd->world_ubo); | ||||
| DRW_shgroup_uniform_float_copy(grp, "slicePosition", slice_position); | DRW_shgroup_uniform_float_copy(grp, "slicePosition", slice_position); | ||||
| DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis); | DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis); | ||||
| DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | ||||
| DRW_shgroup_state_disable(grp, DRW_STATE_CULL_FRONT); | DRW_shgroup_state_disable(grp, DRW_STATE_CULL_FRONT); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Compute world space dimensions for step size. */ | /* Compute world space dimensions for step size. */ | ||||
| float world_size[3]; | float world_size[3]; | ||||
| Show All 10 Lines | else { | ||||
| mul_v3_fl(slice_ct, max_ff(0.001f, 5.0f)); | mul_v3_fl(slice_ct, max_ff(0.001f, 5.0f)); | ||||
| max_slice = max_fff(slice_ct[0], slice_ct[1], slice_ct[2]); | max_slice = max_fff(slice_ct[0], slice_ct[1], slice_ct[2]); | ||||
| invert_v3(slice_ct); | invert_v3(slice_ct); | ||||
| mul_v3_v3(slice_ct, world_size); | mul_v3_v3(slice_ct, world_size); | ||||
| step_length = len_v3(slice_ct); | step_length = len_v3(slice_ct); | ||||
| /* Set uniforms. */ | /* Set uniforms. */ | ||||
| grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | grp = DRW_shgroup_create(sh, vedata->psl->volume_ps); | ||||
| DRW_shgroup_uniform_block(grp, "world_block", wpd->world_ubo); | DRW_shgroup_uniform_block(grp, "world_data", wpd->world_ubo); | ||||
| DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slice); | DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slice); | ||||
| DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length); | ||||
| DRW_shgroup_uniform_float_copy(grp, "noiseOfs", noise_ofs); | DRW_shgroup_uniform_float_copy(grp, "noiseOfs", noise_ofs); | ||||
| DRW_shgroup_state_enable(grp, DRW_STATE_CULL_FRONT); | DRW_shgroup_state_enable(grp, DRW_STATE_CULL_FRONT); | ||||
| } | } | ||||
| /* Compute density scale. */ | /* Compute density scale. */ | ||||
| const float density_scale = volume->display.density * | const float density_scale = volume->display.density * | ||||
| ▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines | |||||