Volume Absorption color tint
Closed, ResolvedPublic

Description

System Information
elementaryOS 0.4.1, GTX 1080

Blender Version
Broken: 2.79.1, r5492d2c

Short description of error
A glass material with volume absoprtion shader plugged in creates colored caustics (with filter glossy at 1), even though the volume shader color is almost entirely white.

Exact steps for others to reproduce the error
I have a glass table with a volume absoprtion shader plugged in. The color is just slightly green. I noticed that when a lamp is shining through the glass that the caustics turn out entirely greenish. The effect is very noticable due to the filter glossy setting of 1. I found that weird, so I set the volume color back to white, and then set the red channel to 0.9999999999, so that even the node UI would show the red channel color as 1.0. So the color should be pretty much white now. Still, the caustics are the same color as before. In fact, it doesn't make a difference if the red channel is set to 0.0 or 0.9999, the caustics always have the same color.
Here's the file:

Bastien Montagne (mont29) triaged this task as Normal priority.Aug 26 2017, 2:59 PM

This is caused by kernel_volume_shadow, which incorrectly uses the FLT_MAX ray distance from the sun sampling when applying the absorption in the glass volume - and for a distance of ~1e38, it makes sense that even the slightest absorption would cause the color to be saturated.

I guess the transparent shadow calculation should clip the distance somehow, I'll look into it.

We can probably clip distance by doing something like

1diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
2index 0ad3c8a7429..669214f85b2 100644
3--- a/intern/cycles/bvh/bvh.cpp
4+++ b/intern/cycles/bvh/bvh.cpp
5@@ -91,6 +91,8 @@ void BVH::build(Progress& progress)
6​ progress.set_substatus("Packing BVH nodes");
7​ pack_nodes(root);
8
9+ pack.root_bounds = root->bounds;
10+
11​ /* free build nodes */
12​ root->deleteSubtree();
13​ }
14diff --git a/intern/cycles/bvh/bvh.h b/intern/cycles/bvh/bvh.h
15index 7bac6112fd9..74b694f710c 100644
16--- a/intern/cycles/bvh/bvh.h
17+++ b/intern/cycles/bvh/bvh.h
18@@ -67,9 +67,12 @@ struct PackedBVH {
19​ /* index of the root node. */
20​ int root_index;
21
22+ BoundBox root_bounds;
23+
24​ PackedBVH()
25​ {
26​ root_index = 0;
27+ root_bounds = BoundBox::empty;
28​ }
29​ };
30
31diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
32index 8f65c00491c..8ed61471b0e 100644
33--- a/intern/cycles/kernel/kernel_types.h
34+++ b/intern/cycles/kernel/kernel_types.h
35@@ -1304,7 +1304,7 @@ typedef struct KernelBVH {
36​ int have_instancing;
37​ int use_qbvh;
38​ int use_bvh_steps;
39- int pad1;
40+ float max_distance;
41​ } KernelBVH;
42​ static_assert_align(KernelBVH, 16);
43
44diff --git a/intern/cycles/kernel/kernel_volume.h b/intern/cycles/kernel/kernel_volume.h
45index 42094a9c3f8..e7c11816c31 100644
46--- a/intern/cycles/kernel/kernel_volume.h
47+++ b/intern/cycles/kernel/kernel_volume.h
48@@ -169,8 +169,10 @@ ccl_device void kernel_volume_shadow_homogeneous(KernelGlobals *kg,
49​ {
50​ float3 sigma_t;
51
52- if(volume_shader_extinction_sample(kg, sd, state, ray->P, &sigma_t))
53- *throughput *= volume_color_transmittance(sigma_t, ray->t);
54+ if(volume_shader_extinction_sample(kg, sd, state, ray->P, &sigma_t)) {
55+ const float ray_t = min(ray->t, kernel_data.bvh.max_distance);
56+ *throughput *= volume_color_transmittance(sigma_t, ray_t);
57+ }
58​ }
59
60​ /* heterogeneous volume: integrate stepping through the volume until we
61@@ -183,6 +185,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg,
62​ {
63​ float3 tp = *throughput;
64​ const float tp_eps = 1e-6f; /* todo: this is likely not the right value */
65+ const float ray_t = min(ray->t, kernel_data.bvh.max_distance);
66
67​ /* prepare for stepping */
68​ int max_steps = kernel_data.integrator.volume_max_steps;
69@@ -196,11 +199,11 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg,
70
71​ for(int i = 0; i < max_steps; i++) {
72​ /* advance to new position */
73- float new_t = min(ray->t, (i+1) * step);
74+ float new_t = min(ray_t, (i+1) * step);
75​ float dt = new_t - t;
76
77​ /* use random position inside this segment to sample shader */
78- if(new_t == ray->t)
79+ if(new_t == ray_t)
80​ random_jitter_offset = lcg_step_float_addrspace(&state->rng_congruential) * dt;
81
82​ float3 new_P = ray->P + ray->D * (t + random_jitter_offset);
83@@ -223,7 +226,7 @@ ccl_device void kernel_volume_shadow_heterogeneous(KernelGlobals *kg,
84
85​ /* stop if at the end of the volume */
86​ t = new_t;
87- if(t == ray->t) {
88+ if(t == ray_t) {
89​ /* Update throughput in case we haven't done it above */
90​ tp = *throughput * make_float3(expf(sum.x), expf(sum.y), expf(sum.z));
91​ break;
92diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
93index 84537bf5993..3f0ebc759c3 100644
94--- a/intern/cycles/render/mesh.cpp
95+++ b/intern/cycles/render/mesh.cpp
96@@ -1881,6 +1881,9 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *
97​ dscene->data.bvh.root = pack.root_index;
98​ dscene->data.bvh.use_qbvh = scene->params.use_qbvh;
99​ dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0);
100+
101+ /* Twice so we don't have possible artifacts due to intersection precision. */
102+ dscene->data.bvh.max_distance = 2.0f * len(pack.root_bounds.max - pack.root_bounds.min);
103​ }
104
105​ void MeshManager::device_update_flags(Device * /*device*/,

However, that would be tricky to get real max distance for scene with procedural world volume. Maybe that case we can simply disable from clipping for the time being.

Why is clipping by the world bounds needed? If there are no precision issues and the mesh is closed, the ray distance used for computing the transmittance should already be short.

I think the issue is that we are missing a kernel_volume_stack_enter_exit in shadow_blocked for direct lighting with a transmission BSDF. We need to take into account that we are lighting from the other side of the surface and update the volume stack accordingly, same as we do for indirect light in kernel_path_surface_bounce.

Was just slapping code together, thought it was indeed clamping issue. Looking into actual cause now, and it's much deeper.

@Brecht Van Lommel (brecht), we should indeed discard element from volume stack for shadow_blocked, otherwise sampling is still considered to be happening inside of the volume which is wrong. Here is an updated patch

1diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
2index ec8c297fbd5..3319e2c2435 100644
3--- a/intern/cycles/kernel/kernel_path.h
4+++ b/intern/cycles/kernel/kernel_path.h
5@@ -84,7 +84,7 @@ ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
6​ light_ray.dP = sd->dP;
7​ light_ray.dD = differential3_zero();
8
9- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &ao_shadow)) {
10+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
11​ path_radiance_accum_ao(L, state, throughput, ao_alpha, ao_bsdf, ao_shadow);
12​ }
13​ else {
14diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h
15index c62c3a25405..dde40674ee6 100644
16--- a/intern/cycles/kernel/kernel_path_branched.h
17+++ b/intern/cycles/kernel/kernel_path_branched.h
18@@ -54,7 +54,7 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
19​ light_ray.dP = sd->dP;
20​ light_ray.dD = differential3_zero();
21
22- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &ao_shadow)) {
23+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
24​ path_radiance_accum_ao(L, state, throughput*num_samples_inv, ao_alpha, ao_bsdf, ao_shadow);
25​ }
26​ else {
27diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
28index 3d10736e90c..6c3a444e48a 100644
29--- a/intern/cycles/kernel/kernel_path_surface.h
30+++ b/intern/cycles/kernel/kernel_path_surface.h
31@@ -67,7 +67,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
32​ /* trace shadow ray */
33​ float3 shadow;
34
35- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
36+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
37​ /* accumulate */
38​ path_radiance_accum_light(L, state, throughput*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
39​ }
40@@ -104,7 +104,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
41​ /* trace shadow ray */
42​ float3 shadow;
43
44- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
45+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
46​ /* accumulate */
47​ path_radiance_accum_light(L, state, throughput*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
48​ }
49@@ -130,7 +130,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(
50​ /* trace shadow ray */
51​ float3 shadow;
52
53- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
54+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
55​ /* accumulate */
56​ path_radiance_accum_light(L, state, throughput*num_samples_adjust, &L_light, shadow, num_samples_adjust, is_lamp);
57​ }
58@@ -257,7 +257,7 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg,
59​ /* trace shadow ray */
60​ float3 shadow;
61
62- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
63+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
64​ /* accumulate */
65​ path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
66​ }
67diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h
68index 3661432f0b7..c9c7f447c42 100644
69--- a/intern/cycles/kernel/kernel_path_volume.h
70+++ b/intern/cycles/kernel/kernel_path_volume.h
71@@ -52,7 +52,7 @@ ccl_device_inline void kernel_path_volume_connect_light(
72​ /* trace shadow ray */
73​ float3 shadow;
74
75- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
76+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
77​ /* accumulate */
78​ path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
79​ }
80@@ -179,7 +179,7 @@ ccl_device void kernel_branched_path_volume_connect_light(
81​ /* trace shadow ray */
82​ float3 shadow;
83
84- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
85+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
86​ /* accumulate */
87​ path_radiance_accum_light(L, state, tp*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
88​ }
89@@ -228,7 +228,7 @@ ccl_device void kernel_branched_path_volume_connect_light(
90​ /* trace shadow ray */
91​ float3 shadow;
92
93- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
94+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
95​ /* accumulate */
96​ path_radiance_accum_light(L, state, tp*num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
97​ }
98@@ -266,7 +266,7 @@ ccl_device void kernel_branched_path_volume_connect_light(
99​ /* trace shadow ray */
100​ float3 shadow;
101
102- if(!shadow_blocked(kg, emission_sd, state, &light_ray, &shadow)) {
103+ if(!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &shadow)) {
104​ /* accumulate */
105​ path_radiance_accum_light(L, state, tp, &L_light, shadow, 1.0f, is_lamp);
106​ }
107diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h
108index bb6bdc7fbd0..c53ca6135f8 100644
109--- a/intern/cycles/kernel/kernel_shadow.h
110+++ b/intern/cycles/kernel/kernel_shadow.h
111@@ -119,12 +119,43 @@ ccl_device bool shadow_blocked_opaque(KernelGlobals *kg,
112
113​ # define SHADOW_STACK_MAX_HITS 64
114
115+# ifdef __VOLUME__
116+struct VolumeState {
117+# ifdef __SPLIT_KERNEL__
118+# else
119+ PathState ps;
120+# endif
121+};
122+
123+/* Get PathState ready for use for volume stack evaluation. */
124+ccl_device_inline PathState *shadow_blocked_volume_path_state(
125+ KernelGlobals *kg,
126+ VolumeState *volume_state,
127+ ccl_addr_space PathState *state,
128+ ShaderData *sd)
129+{
130+# ifdef __SPLIT_KERNEL__
131+ ccl_addr_space PathState *ps =
132+ &kernel_split_state.state_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
133+# else
134+ PathState *ps = &volume_state->ps;
135+# endif
136+ *ps = *state;
137+ /* We are checking for shadow on the "other" side of the surface, so need
138+ * to discard volume we are currently at.
139+ */
140+ kernel_volume_stack_enter_exit(kg, sd, ps->volume_stack);
141+ return ps;
142+}
143+#endif // __VOLUME__
144+
145​ /* Actual logic with traversal loop implementation which is free from device
146​ * specific tweaks.
147​ *
148​ * Note that hits array should be as big as max_hits+1.
149​ */
150​ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
151+ ShaderData *sd,
152​ ShaderData *shadow_sd,
153​ ccl_addr_space PathState *state,
154​ const uint visibility,
155@@ -143,6 +174,9 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
156​ visibility,
157​ max_hits,
158​ &num_hits);
159+# ifdef __VOLUME__
160+ VolumeState volume_state;
161+# endif
162​ /* If no opaque surface found but we did find transparent hits,
163​ * shade them.
164​ */
165@@ -153,13 +187,10 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
166​ int bounce = state->transparent_bounce;
167​ Intersection *isect = hits;
168​ # ifdef __VOLUME__
169-# ifdef __SPLIT_KERNEL__
170- ccl_addr_space PathState *ps = &kernel_split_state.state_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
171-# else
172- PathState ps_object;
173- PathState *ps = &ps_object;
174-# endif
175- *ps = *state;
176+ PathState *ps = shadow_blocked_volume_path_state(kg,
177+ &volume_state,
178+ state,
179+ sd);
180​ # endif
181​ sort_intersections(hits, num_hits);
182​ for(int hit = 0; hit < num_hits; hit++, isect++) {
183@@ -205,7 +236,11 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
184​ # ifdef __VOLUME__
185​ if(!blocked && state->volume_stack[0].shader != SHADER_NONE) {
186​ /* Apply attenuation from current volume shader. */
187- kernel_volume_shadow(kg, shadow_sd, state, ray, shadow);
188+ PathState *ps = shadow_blocked_volume_path_state(kg,
189+ &volume_state,
190+ state,
191+ sd);
192+ kernel_volume_shadow(kg, shadow_sd, ps, ray, shadow);
193​ }
194​ # endif
195​ return blocked;
196@@ -215,6 +250,7 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
197​ * loop to help readability of the actual logic.
198​ */
199​ ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg,
200+ ShaderData *sd,
201​ ShaderData *shadow_sd,
202​ ccl_addr_space PathState *state,
203​ const uint visibility,
204@@ -250,6 +286,7 @@ ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg,
205​ # endif /* __KERNEL_GPU__ */
206​ /* Invoke actual traversal. */
207​ return shadow_blocked_transparent_all_loop(kg,
208+ sd,
209​ shadow_sd,
210​ state,
211​ visibility,
212@@ -275,6 +312,7 @@ ccl_device bool shadow_blocked_transparent_all(KernelGlobals *kg,
213​ */
214​ ccl_device bool shadow_blocked_transparent_stepped_loop(
215​ KernelGlobals *kg,
216+ ShaderData *sd,
217​ ShaderData *shadow_sd,
218​ ccl_addr_space PathState *state,
219​ const uint visibility,
220@@ -284,18 +322,18 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(
221​ const bool is_transparent_isect,
222​ float3 *shadow)
223​ {
224+# ifdef __VOLUME__
225+ VolumeState volume_state;
226+# endif
227​ if(blocked && is_transparent_isect) {
228​ float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
229​ float3 Pend = ray->P + ray->D*ray->t;
230​ int bounce = state->transparent_bounce;
231​ # ifdef __VOLUME__
232-# ifdef __SPLIT_KERNEL__
233- ccl_addr_space PathState *ps = &kernel_split_state.state_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
234-# else
235- PathState ps_object;
236- PathState *ps = &ps_object;
237-# endif
238- *ps = *state;
239+ PathState *ps = shadow_blocked_volume_path_state(kg,
240+ &volume_state,
241+ state,
242+ sd);
243​ # endif
244​ for(;;) {
245​ if(bounce >= kernel_data.integrator.transparent_max_bounce) {
246@@ -345,7 +383,11 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(
247​ # ifdef __VOLUME__
248​ if(!blocked && state->volume_stack[0].shader != SHADER_NONE) {
249​ /* Apply attenuation from current volume shader. */
250- kernel_volume_shadow(kg, shadow_sd, state, ray, shadow);
251+ PathState *ps = shadow_blocked_volume_path_state(kg,
252+ &volume_state,
253+ state,
254+ sd);
255+ kernel_volume_shadow(kg, shadow_sd, ps, ray, shadow);
256​ }
257​ # endif
258​ return blocked;
259@@ -353,6 +395,7 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(
260
261​ ccl_device bool shadow_blocked_transparent_stepped(
262​ KernelGlobals *kg,
263+ ShaderData *sd,
264​ ShaderData *shadow_sd,
265​ ccl_addr_space PathState *state,
266​ const uint visibility,
267@@ -370,6 +413,7 @@ ccl_device bool shadow_blocked_transparent_stepped(
268​ ? shader_transparent_shadow(kg, isect)
269​ : false;
270​ return shadow_blocked_transparent_stepped_loop(kg,
271+ sd,
272​ shadow_sd,
273​ state,
274​ visibility,
275@@ -384,6 +428,7 @@ ccl_device bool shadow_blocked_transparent_stepped(
276​ #endif /* __TRANSPARENT_SHADOWS__ */
277
278​ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
279+ ShaderData *sd,
280​ ShaderData *shadow_sd,
281​ ccl_addr_space PathState *state,
282​ Ray *ray_input,
283@@ -452,6 +497,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
284​ max_hits + 1 >= SHADOW_STACK_MAX_HITS)
285​ {
286​ return shadow_blocked_transparent_stepped_loop(kg,
287+ sd,
288​ shadow_sd,
289​ state,
290​ visibility,
291@@ -463,6 +509,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
292​ }
293​ # endif /* __KERNEL_GPU__ */
294​ return shadow_blocked_transparent_all(kg,
295+ sd,
296​ shadow_sd,
297​ state,
298​ visibility,
299diff --git a/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h b/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h
300index 19bfee6d039..b52f9a5eb81 100644
301--- a/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h
302+++ b/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h
303@@ -89,6 +89,7 @@ ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg)
304​ float3 shadow;
305
306​ if(!shadow_blocked(kg,
307+ sd,
308​ emission_sd,
309​ state,
310​ &ray,

The confusing part was that 2.77a was rendering this file correct, so i thought we made a mistake in volume stack somewhere. But appears it was never a case. The issue here is that after rB9b6ed3a we are not ignoring volume closures which weight is less than
CLOSURE_WEIGHT_CUTOFF (before that refactor absorption was removed). So maybe we should do something like this:

1loc.h b/intern/cycles/kernel/closure/alloc.h
2index e799855a65e..f8a5e8d64d0 100644
3--- a/intern/cycles/kernel/closure/alloc.h
4+++ b/intern/cycles/kernel/closure/alloc.h
5@@ -24,6 +24,10 @@ ccl_device ShaderClosure *closure_alloc(ShaderData *sd, int size, ClosureType ty
6​ int num_closure_extra = sd->num_closure_extra;
7​ if(num_closure + num_closure_extra >= MAX_CLOSURE)
8​ return NULL;
9+ float sample_weight = fabsf(average(weight));
10+ if(sample_weight <= CLOSURE_WEIGHT_CUTOFF) {
11+ return NULL;
12+ }
13
14​ ShaderClosure *sc = &sd->closure[num_closure];
15

For P526, I think it should only do kernel_volume_stack_enter_exit for transmission rays? Otherwise looks good to me.

If we do P527 then we should remove the duplicate cutoff test in bsdf_alloc and bsdf_alloc_osl. I don't think we should be doing this cutoff for volume closures though, unless we also take into account the distance. The cutoff is 1e-5f currently which is actually not that low if multiply it by distance of 1e5f. For BSDFs these values are already scene scale independent so it's safer to have a cutoff.

Yeah, think explicit check for transmission rays would be good. Just initially thought enter_exit will not do anything if that wasn't a transmission ray because it wouldn't be reflected in the stack then. In any case, will add check and commit.

I will leave changes about closure cutoff for later, you've raised the valid point of cutoff not being small enough.maybe we can cutoff at FLT_EPS or so, but let's make it another story.

@Brecht Van Lommel (brecht), actually, either i'm doing something wrong, or there is something else going on here. What i did is, instead of enter_exit in original patch did it like this:

	if(state->flag & PATH_RAY_TRANSMIT) {
		kernel_volume_stack_enter_exit(kg, sd, ps->volume_stack);
	}

and this gives artifacts in this file:

Without check for transmission rays there are no artifacts. So still need to look into this..

I think the test should be for the direct lighting ray:

if(dot(sd->Ng, ray->D) < 0.0f) {
    kernel_volume_stack_enter_exit(kg, sd, ps->volume_stack);
}

@Brecht Van Lommel (brecht), indeed. it we need to check whether shadow ray is being transmitted or reflected back, not the previous bounce (previous bounce might have been reflection inside of the volume). Just hoped to save some multiplications.. Will run more tests now and commit.