Blender V4.3
init_from_camera.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
8
11
14
16
18
20 const int sample,
21 const int x,
22 const int y,
23 const uint rng_pixel,
24 ccl_private Ray *ray)
25{
26 /* Filter sampling. */
27 const float2 rand_filter = (sample == 0) ? make_float2(0.5f, 0.5f) :
28 path_rng_2D(kg, rng_pixel, sample, PRNG_FILTER);
29
30 /* Motion blur (time) and depth of field (lens) sampling. (time, lens_x, lens_y) */
31 const float3 rand_time_lens = (kernel_data.cam.shuttertime != -1.0f ||
32 kernel_data.cam.aperturesize > 0.0f) ?
33 path_rng_3D(kg, rng_pixel, sample, PRNG_LENS_TIME) :
35
36 /* We use x for time and y,z for lens because in practice with Sobol
37 * sampling this seems to give better convergence when an object is
38 * both motion blurred and out of focus, without significantly harming
39 * convergence for focal blur alone. This is a little surprising,
40 * because one would expect using x,y for lens (the 2d part) would be
41 * best, since x,y are the best stratified. Since it's not entirely
42 * clear why this is, this is probably worth revisiting at some point
43 * to investigate further. */
44 const float rand_time = rand_time_lens.x;
45 const float2 rand_lens = make_float2(rand_time_lens.y, rand_time_lens.z);
46
47 /* Generate camera ray. */
48 camera_sample(kg, x, y, rand_filter, rand_time, rand_lens, ray);
49}
50
51/* Return false to indicate that this pixel is finished.
52 * Used by CPU implementation to not attempt to sample pixel for multiple samples once its known
53 * that the pixel did converge. */
58 const int x,
59 const int y,
60 const int scheduled_sample)
61{
63
64 /* Initialize path state to give basic buffer access and allow early outputs. */
66
67 /* Check whether the pixel has converged and should not be sampled anymore. */
69 return false;
70 }
71
72 /* Count the sample and get an effective sample for this pixel.
73 *
74 * This logic allows to both count actual number of samples per pixel, and to add samples to this
75 * pixel after it was converged and samples were added somewhere else (in which case the
76 * `scheduled_sample` will be different from actual number of samples in this pixel). */
77 const int sample = film_write_sample(
78 kg, state, render_buffer, scheduled_sample, tile->sample_offset);
79
80 /* Initialize random number seed for path. */
81 const uint rng_pixel = path_rng_pixel_init(kg, sample, x, y);
82
83 {
84 /* Generate camera ray. */
85 Ray ray;
86 integrate_camera_sample(kg, sample, x, y, rng_pixel, &ray);
87 if (ray.tmax == 0.0f) {
88 return true;
89 }
90
91 /* Write camera ray to state. */
93 }
94
95 /* Initialize path state for path integration. */
97
98 /* Continue with intersect_closest kernel, optionally initializing volume
99 * stack before that if the camera may be inside a volume. */
100 if (kernel_data.cam.is_inside_volume) {
102 }
103 else {
105 }
106
107 return true;
108}
109
unsigned int uint
#define kernel_data
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define ccl_restrict
#define ccl_device
#define ccl_private
#define ccl_device_inline
#define ccl_global
#define CCL_NAMESPACE_END
ccl_device_forceinline float2 make_float2(const float x, const float y)
CCL_NAMESPACE_BEGIN ccl_device_inline void integrate_camera_sample(KernelGlobals kg, const int sample, const int x, const int y, const uint rng_pixel, ccl_private Ray *ray)
ccl_device bool integrator_init_from_camera(KernelGlobals kg, IntegratorState state, ccl_global const KernelWorkTile *ccl_restrict tile, ccl_global float *render_buffer, const int x, const int y, const int scheduled_sample)
ccl_device_inline void camera_sample(KernelGlobals kg, int x, int y, const float2 filter_uv, const float time, const float2 lens_uv, ccl_private Ray *ray)
ccl_global const KernelWorkTile * tile
ccl_gpu_kernel_postfix ccl_global KernelWorkTile const int ccl_global float * render_buffer
CCL_NAMESPACE_BEGIN ccl_device_forceinline bool film_need_sample_pixel(KernelGlobals kg, ConstIntegratorState state, ccl_global float *render_buffer)
@ PRNG_LENS_TIME
@ PRNG_FILTER
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST
#define PROFILING_INIT(kg, event)
ccl_device_inline int film_write_sample(KernelGlobals kg, ConstIntegratorState state, ccl_global float *ccl_restrict render_buffer, int sample, int sample_offset)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:15
static ulong state[N]
ccl_device_inline void path_state_init(IntegratorState state, ccl_global const KernelWorkTile *ccl_restrict tile, const int x, const int y)
Definition path_state.h:25
ccl_device_inline void path_state_init_integrator(KernelGlobals kg, IntegratorState state, const int sample, const uint rng_pixel)
Definition path_state.h:38
ccl_device_inline uint path_rng_pixel_init(KernelGlobals kg, const int sample, const int x, const int y)
Definition pattern.h:133
ccl_device_forceinline float2 path_rng_2D(KernelGlobals kg, uint rng_pixel, int sample, int dimension)
Definition pattern.h:82
ccl_device_forceinline float3 path_rng_3D(KernelGlobals kg, uint rng_pixel, int sample, int dimension)
Definition pattern.h:99
IntegratorStateCPU *ccl_restrict IntegratorState
Definition state.h:228
ccl_device_forceinline void integrator_path_init(KernelGlobals kg, IntegratorState state, const DeviceKernel next_kernel)
Definition state_flow.h:153
CCL_NAMESPACE_BEGIN ccl_device_forceinline void integrator_state_write_ray(IntegratorState state, ccl_private const Ray *ccl_restrict ray)
Definition state_util.h:15
float z
Definition sky_float3.h:27
float y
Definition sky_float3.h:27
float x
Definition sky_float3.h:27
@ PROFILING_RAY_SETUP