[Bf-blender-cvs] [6ba7345ca53] blender2.8: Workbench: Volumes: Fix volumetrics step length calculation
Clément Foucault
noreply at git.blender.org
Mon Nov 12 21:18:44 CET 2018
Commit: 6ba7345ca5393077dddbfaa48651a209b23e9bd0
Author: Clément Foucault
Date: Mon Nov 12 21:14:51 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB6ba7345ca5393077dddbfaa48651a209b23e9bd0
Workbench: Volumes: Fix volumetrics step length calculation
Step size is now one voxel diagonal.
Fix T57678 Culling of smoke depending on view direction
===================================================================
M source/blender/draw/engines/workbench/workbench_volume.c
===================================================================
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
index 7b90076803e..fa6f740be1a 100644
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -26,6 +26,7 @@
#include "workbench_private.h"
#include "BKE_modifier.h"
+#include "BKE_object.h"
#include "BLI_rand.h"
#include "BLI_dynstr.h"
@@ -164,15 +165,19 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Objec
else {
double noise_ofs;
BLI_halton_1D(3, 0.0, effect_info->jitter_index, &noise_ofs);
- int max_slices = max_iii(sds->res[0], sds->res[1], sds->res[2]) * sds->slice_per_voxel;
+ float dim[3], step_length, max_slice;
+ float slice_ct[3] = {sds->res[0], sds->res[1], sds->res[2]};
+ mul_v3_fl(slice_ct, sds->slice_per_voxel);
+ max_slice = max_fff(slice_ct[0], slice_ct[1], slice_ct[2]);
+ BKE_object_dimensions_get(ob, dim);
+ invert_v3(slice_ct);
+ mul_v3_v3(dim, slice_ct);
+ step_length = len_v3(dim);
grp = DRW_shgroup_create(sh, vedata->psl->volume_pass);
DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
- DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slices);
- /* TODO FIXME : This step size is in object space but the ray itself
- * is NOT unit length in object space so the required number of subdivisions
- * is tricky to get. */
- DRW_shgroup_uniform_float_copy(grp, "stepLength", 8.0f / max_slices);
+ DRW_shgroup_uniform_int_copy(grp, "samplesLen", max_slice);
+ DRW_shgroup_uniform_float_copy(grp, "stepLength", step_length);
DRW_shgroup_uniform_float_copy(grp, "noiseOfs", noise_ofs);
}
More information about the Bf-blender-cvs
mailing list