Page MenuHome

Cycles: Camera clipping causes artifacs if it was set into a smoke domain.
Closed, ArchivedPublic

Description

System Information
Tested on Windows 7 and 10

Blender Version
2.76b

Short description of error
If the camera clipping is set into a smoke domain, Cycles ignores the clipping range and render the whole smoke.
The empty space in the smoke domain is rendered in black instead of transparent.

Exact steps for others to reproduce the error

  1. Load the file:
  2. Play the simulation until the smoke cache is generated
  3. Go to frame 70 and render it

Related Objects

Event Timeline

Corbin (caddock) raised the priority of this task from to 90.
Corbin (caddock) updated the task description. (Show Details)
Corbin (caddock) edited a custom field.
Corbin (caddock) added a subscriber: Corbin (caddock).

Not sure this is a bug at all… Sergey should know. :)

Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.Jan 15 2016, 10:26 AM

Just a quick update. Here's a partial fix, which fixes far clipping issue:

1diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
2index 650e3b0..93f29a7 100644
3--- a/intern/cycles/kernel/kernel_path.h
4+++ b/intern/cycles/kernel/kernel_path.h
5@@ -612,6 +612,10 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
6 debug_data_init(&debug_data);
7 #endif
8
9+#ifdef __VOLUME__
10+ float3 P_end = ray.P + ray.D*ray.t;
11+#endif
12+
13 #ifdef __SUBSURFACE__
14 SubsurfaceIndirectRays ss_indirect;
15 kernel_path_subsurface_init_indirect(&ss_indirect);
16@@ -678,7 +682,15 @@ ccl_device_inline float4 kernel_path_integrate(KernelGlobals *kg,
17 /* volume attenuation, emission, scatter */
18 if(state.volume_stack[0].shader != SHADER_NONE) {
19 Ray volume_ray = ray;
20- volume_ray.t = (hit)? isect.t: FLT_MAX;
21+ if(hit) {
22+ volume_ray.t = isect.t;
23+ }
24+ else if((state.flag & PATH_RAY_CAMERA) && ray.t != FLT_MAX) {
25+ volume_ray.t = len(P_end - ray.P);
26+ }
27+ else {
28+ volume_ray.t = FLT_MAX;
29+ }
30
31 bool heterogeneous = volume_stack_is_heterogeneous(kg, state.volume_stack);
32
33diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h
34index 7c685e3..4170c2d 100644
35--- a/intern/cycles/kernel/kernel_path_branched.h
36+++ b/intern/cycles/kernel/kernel_path_branched.h
37@@ -239,6 +239,10 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
38 debug_data_init(&debug_data);
39 #endif
40
41+#ifdef __VOLUME__
42+ float3 P_end = ray.P + ray.D*ray.t;
43+#endif
44+
45 /* Main Loop
46 * Here we only handle transparency intersections from the camera ray.
47 * Indirect bounces are handled in kernel_branched_path_surface_indirect_light().
48@@ -278,8 +282,16 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
49 /* volume attenuation, emission, scatter */
50 if(state.volume_stack[0].shader != SHADER_NONE) {
51 Ray volume_ray = ray;
52- volume_ray.t = (hit)? isect.t: FLT_MAX;
53-
54+ if(hit) {
55+ volume_ray.t = isect.t;
56+ }
57+ else if(ray.t != FLT_MAX) {
58+ volume_ray.t = len(P_end - ray.P);
59+ }
60+ else {
61+ volume_ray.t = FLT_MAX;
62+ }
63+
64 bool heterogeneous = volume_stack_is_heterogeneous(kg, state.volume_stack);
65
66 #ifdef __VOLUME_DECOUPLED__

Fixing near clipping issue still needs some work.

Sergey Sharybin (sergey) changed the task status from Unknown Status to Unknown Status.Jan 19 2016, 5:50 PM

On the second thought, near clipping actually has a correct behavior because otherwise you wouldn't be able to do a proper shading of an objects when camera is in the volume. Basically, because OpenGL does not support indirect light and so, it can simply cut the stuff which is behind clipping plane, but doing the same in a GI renderer will only cause shading artifacts.

As for far clipping -- while the patch here solves problem when there's a huge domain present, it introduces issues when using volumes for the world shader. Solution like ignoring far clipping for the world volume and using it for other volumes might behave correct-ish in some setups, but is still quite arbitrary and doesn't solve much issues.

So thanks for the report, but will consider it a TODO for now.