Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/integrator_init_from_camera.h
| Show All 19 Lines | |||||
| #include "kernel/kernel_adaptive_sampling.h" | #include "kernel/kernel_adaptive_sampling.h" | ||||
| #include "kernel/kernel_camera.h" | #include "kernel/kernel_camera.h" | ||||
| #include "kernel/kernel_path_state.h" | #include "kernel/kernel_path_state.h" | ||||
| #include "kernel/kernel_random.h" | #include "kernel/kernel_random.h" | ||||
| #include "kernel/kernel_shadow_catcher.h" | #include "kernel/kernel_shadow_catcher.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| ccl_device_inline void integrate_camera_sample(ccl_global const KernelGlobals *ccl_restrict kg, | ccl_device_inline void integrate_camera_sample(KernelGlobals kg, | ||||
| const int sample, | const int sample, | ||||
| const int x, | const int x, | ||||
| const int y, | const int y, | ||||
| const uint rng_hash, | const uint rng_hash, | ||||
| ccl_private Ray *ray) | ccl_private Ray *ray) | ||||
| { | { | ||||
| /* Filter sampling. */ | /* Filter sampling. */ | ||||
| float filter_u, filter_v; | float filter_u, filter_v; | ||||
| Show All 21 Lines | #endif | ||||
| /* Generate camera ray. */ | /* Generate camera ray. */ | ||||
| camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray); | camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray); | ||||
| } | } | ||||
| /* Return false to indicate that this pixel is finished. | /* Return false to indicate that this pixel is finished. | ||||
| * Used by CPU implementation to not attempt to sample pixel for multiple samples once its known | * Used by CPU implementation to not attempt to sample pixel for multiple samples once its known | ||||
| * that the pixel did converge. */ | * that the pixel did converge. */ | ||||
| ccl_device bool integrator_init_from_camera(INTEGRATOR_STATE_ARGS, | ccl_device bool integrator_init_from_camera(KernelGlobals kg, | ||||
| IntegratorState state, | |||||
| ccl_global const KernelWorkTile *ccl_restrict tile, | ccl_global const KernelWorkTile *ccl_restrict tile, | ||||
| ccl_global float *render_buffer, | ccl_global float *render_buffer, | ||||
| const int x, | const int x, | ||||
| const int y, | const int y, | ||||
| const int scheduled_sample) | const int scheduled_sample) | ||||
| { | { | ||||
| PROFILING_INIT(kg, PROFILING_RAY_SETUP); | PROFILING_INIT(kg, PROFILING_RAY_SETUP); | ||||
| /* Initialize path state to give basic buffer access and allow early outputs. */ | /* Initialize path state to give basic buffer access and allow early outputs. */ | ||||
| path_state_init(INTEGRATOR_STATE_PASS, tile, x, y); | path_state_init(kg, state, tile, x, y); | ||||
| /* Check whether the pixel has converged and should not be sampled anymore. */ | /* Check whether the pixel has converged and should not be sampled anymore. */ | ||||
| if (!kernel_need_sample_pixel(INTEGRATOR_STATE_PASS, render_buffer)) { | if (!kernel_need_sample_pixel(kg, state, render_buffer)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* Count the sample and get an effective sample for this pixel. | /* Count the sample and get an effective sample for this pixel. | ||||
| * | * | ||||
| * This logic allows to both count actual number of samples per pixel, and to add samples to this | * This logic allows to both count actual number of samples per pixel, and to add samples to this | ||||
| * pixel after it was converged and samples were added somewhere else (in which case the | * pixel after it was converged and samples were added somewhere else (in which case the | ||||
| * `scheduled_sample` will be different from actual number of samples in this pixel). */ | * `scheduled_sample` will be different from actual number of samples in this pixel). */ | ||||
| const int sample = kernel_accum_sample(INTEGRATOR_STATE_PASS, render_buffer, scheduled_sample); | const int sample = kernel_accum_sample(kg, state, render_buffer, scheduled_sample); | ||||
| /* Initialize random number seed for path. */ | /* Initialize random number seed for path. */ | ||||
| const uint rng_hash = path_rng_hash_init(kg, sample, x, y); | const uint rng_hash = path_rng_hash_init(kg, sample, x, y); | ||||
| { | { | ||||
| /* Generate camera ray. */ | /* Generate camera ray. */ | ||||
| Ray ray; | Ray ray; | ||||
| integrate_camera_sample(kg, sample, x, y, rng_hash, &ray); | integrate_camera_sample(kg, sample, x, y, rng_hash, &ray); | ||||
| if (ray.t == 0.0f) { | if (ray.t == 0.0f) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* Write camera ray to state. */ | /* Write camera ray to state. */ | ||||
| integrator_state_write_ray(INTEGRATOR_STATE_PASS, &ray); | integrator_state_write_ray(kg, state, &ray); | ||||
| } | } | ||||
| /* Initialize path state for path integration. */ | /* Initialize path state for path integration. */ | ||||
| path_state_init_integrator(INTEGRATOR_STATE_PASS, sample, rng_hash); | path_state_init_integrator(kg, state, sample, rng_hash); | ||||
| /* Continue with intersect_closest kernel, optionally initializing volume | /* Continue with intersect_closest kernel, optionally initializing volume | ||||
| * stack before that if the camera may be inside a volume. */ | * stack before that if the camera may be inside a volume. */ | ||||
| if (kernel_data.cam.is_inside_volume) { | if (kernel_data.cam.is_inside_volume) { | ||||
| INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK); | INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK); | ||||
| } | } | ||||
| else { | else { | ||||
| INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST); | INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||