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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2013-12-28 23:02:40 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2013-12-28 23:12:11 +0400
commit2b39214c4d8811b06545b83c4e42a7578266e2b1 (patch)
tree5cbddb26f8031ff94035f5aff2dc516a2d0359d9 /intern/cycles/kernel/kernel_shadow.h
parente369a5c48529864118d49222dde3d530d58ebeae (diff)
Cycles Volume Render: add support for overlapping volume objects.
This works pretty much as you would expect, overlapping volume objects gives a more dense volume. What did change is that world volume shaders are now active everywhere, they are no longer excluded inside objects. This may not be desirable and we need to think of better control over this. In some cases you clearly want it to happen, for example if you are rendering a fire in a foggy environment. In other cases like the inside of a house you may not want any fog, but it doesn't seem possible in general for the renderer to automatically determine what is inside or outside of the house. This is implemented using a simple fixed size array of shader/object ID pairs, limited to max 15 overlapping objects. The closures from all shaders are put into a single closure array, exactly the same as if an add shader was used to combine them.
Diffstat (limited to 'intern/cycles/kernel/kernel_shadow.h')
-rw-r--r--intern/cycles/kernel/kernel_shadow.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h
index aaf6ce10fef..80c9da8eab8 100644
--- a/intern/cycles/kernel/kernel_shadow.h
+++ b/intern/cycles/kernel/kernel_shadow.h
@@ -44,9 +44,8 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
float3 Pend = ray->P + ray->D*ray->t;
int bounce = state->transparent_bounce;
-
#ifdef __VOLUME__
- int volume_shader = state->volume_shader;
+ PathState ps = *state;
#endif
for(;;) {
@@ -74,8 +73,8 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
#ifdef __VOLUME__
/* attenuation for last line segment towards light */
- if(volume_shader != SHADER_NO_ID)
- throughput *= kernel_volume_get_shadow_attenuation(kg, state, ray, volume_shader);
+ if(ps.volume_stack[0].shader != SHADER_NO_ID)
+ throughput *= kernel_volume_get_shadow_attenuation(kg, &ps, ray);
#endif
*shadow *= throughput;
@@ -87,10 +86,10 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
#ifdef __VOLUME__
/* attenuation between last surface and next surface */
- if(volume_shader != SHADER_NO_ID) {
+ if(ps.volume_stack[0].shader != SHADER_NO_ID) {
Ray segment_ray = *ray;
segment_ray.t = isect.t;
- throughput *= kernel_volume_get_shadow_attenuation(kg, state, &segment_ray, volume_shader);
+ throughput *= kernel_volume_get_shadow_attenuation(kg, &ps, &segment_ray);
}
#endif
@@ -111,10 +110,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
#ifdef __VOLUME__
/* exit/enter volume */
- if(sd.flag & SD_BACKFACING)
- volume_shader = kernel_data.background.volume_shader;
- else
- volume_shader = (sd.flag & SD_HAS_VOLUME)? sd.shader: SHADER_NO_ID;
+ kernel_volume_stack_enter_exit(kg, &sd, ps.volume_stack);
#endif
bounce++;
@@ -122,9 +118,9 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
}
}
#ifdef __VOLUME__
- else if(!result && state->volume_shader != SHADER_NO_ID) {
+ else if(!result && state->volume_stack[0].shader != SHADER_NO_ID) {
/* apply attenuation from current volume shader */
- *shadow *= kernel_volume_get_shadow_attenuation(kg, state, ray, state->volume_shader);
+ *shadow *= kernel_volume_get_shadow_attenuation(kg, state, ray);
}
#endif
#endif