Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-12 23:14:51 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-12 23:15:58 +0300
commit6ba7345ca5393077dddbfaa48651a209b23e9bd0 (patch)
tree2e82aead96bd795e157e9104ff96bc5f7f41d8f4 /source/blender
parent3eb7928406853e10229a329ea7e28a3d5cf2043f (diff)
Workbench: Volumes: Fix volumetrics step length calculation
Step size is now one voxel diagonal. Fix T57678 Culling of smoke depending on view direction
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c17
1 files changed, 11 insertions, 6 deletions
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);
}