Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_volume.h
| Show All 11 Lines | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Events for probalistic scattering */ | /* Events for probalistic scattering */ | ||||
brecht: This needs `ccl_device` to work on the GPU I think? | |||||
| typedef enum VolumeIntegrateResult { | typedef enum VolumeIntegrateResult { | ||||
| VOLUME_PATH_SCATTERED = 0, | VOLUME_PATH_SCATTERED = 0, | ||||
| VOLUME_PATH_ATTENUATED = 1, | VOLUME_PATH_ATTENUATED = 1, | ||||
| VOLUME_PATH_MISSED = 2 | VOLUME_PATH_MISSED = 2 | ||||
| } VolumeIntegrateResult; | } VolumeIntegrateResult; | ||||
| /* Volume shader properties | /* Volume shader properties | ||||
| * | * | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | else { | ||||
| method = 0; | method = 0; | ||||
| } | } | ||||
| } | } | ||||
| return method; | return method; | ||||
| } | } | ||||
| ccl_device_inline bool kernel_volume_stack_is_visible(KernelGlobals *kg, | |||||
| ccl_addr_space VolumeStack *volume_stack, | |||||
| uint flags) | |||||
| { | |||||
| /* Check visiblity. */ | |||||
| bool stack_visible = false; | |||||
| uint ray_visibility = flags; /* path_state_ray_visibility(kg, flags); */ | |||||
| for (int i = 0; i < VOLUME_STACK_SIZE - 1; ++i) { | |||||
| if (volume_stack[i].shader == SHADER_NONE) { | |||||
| break; | |||||
| } | |||||
| if (volume_stack[i].object == OBJECT_NONE) { | |||||
| volume_stack[i].visible == true; | |||||
| } | |||||
| else { | |||||
| uint visibility = kernel_tex_fetch(__object_flag, volume_stack[i].object) >> 16; | |||||
| volume_stack[i].visible = ray_visibility & visibility; | |||||
| } | |||||
| stack_visible |= volume_stack[i].visible; | |||||
| } | |||||
| return stack_visible; | |||||
| } | |||||
| ccl_device_inline void kernel_volume_step_init(KernelGlobals *kg, | ccl_device_inline void kernel_volume_step_init(KernelGlobals *kg, | ||||
| ccl_addr_space PathState *state, | ccl_addr_space PathState *state, | ||||
| const float object_step_size, | const float object_step_size, | ||||
| float t, | float t, | ||||
| float *step_size, | float *step_size, | ||||
| float *step_offset) | float *step_offset) | ||||
| { | { | ||||
| const int max_steps = kernel_data.integrator.volume_max_steps; | const int max_steps = kernel_data.integrator.volume_max_steps; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| /* get the volume attenuation over line segment defined by ray, with the | /* get the volume attenuation over line segment defined by ray, with the | ||||
| * assumption that there are no surfaces blocking light between the endpoints */ | * assumption that there are no surfaces blocking light between the endpoints */ | ||||
| ccl_device_noinline void kernel_volume_shadow(KernelGlobals *kg, | ccl_device_noinline void kernel_volume_shadow(KernelGlobals *kg, | ||||
| ShaderData *shadow_sd, | ShaderData *shadow_sd, | ||||
| ccl_addr_space PathState *state, | ccl_addr_space PathState *state, | ||||
| Ray *ray, | Ray *ray, | ||||
| float3 *throughput) | float3 *throughput) | ||||
| { | { | ||||
| # ifdef __SHADOW_TRICKS__ | |||||
| const uint flags = (state->flag & PATH_RAY_SHADOW_CATCHER) ? PATH_RAY_SHADOW_NON_CATCHER : | |||||
| PATH_RAY_SHADOW; | |||||
| # else | |||||
| const uint flags = PATH_RAY_SHADOW; | |||||
| # endif | |||||
| if (!kernel_volume_stack_is_visible(kg, state->volume_stack, flags)) { | |||||
| return; | |||||
| } | |||||
| shader_setup_from_volume(kg, shadow_sd, ray); | shader_setup_from_volume(kg, shadow_sd, ray); | ||||
| float step_size = volume_stack_step_size(kg, state->volume_stack); | float step_size = volume_stack_step_size(kg, state->volume_stack); | ||||
| if (step_size != FLT_MAX) | if (step_size != FLT_MAX) | ||||
| kernel_volume_shadow_heterogeneous(kg, state, ray, shadow_sd, throughput, step_size); | kernel_volume_shadow_heterogeneous(kg, state, ray, shadow_sd, throughput, step_size); | ||||
| else | else | ||||
| kernel_volume_shadow_homogeneous(kg, state, ray, shadow_sd, throughput); | kernel_volume_shadow_homogeneous(kg, state, ray, shadow_sd, throughput); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,136 Lines • Show Last 20 Lines | |||||
This needs ccl_device to work on the GPU I think?