Blender  V3.3
init_from_camera.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
6 #include "kernel/camera/camera.h"
7 
10 
13 
14 #include "kernel/sample/pattern.h"
15 
17 
19  const int sample,
20  const int x,
21  const int y,
22  const uint rng_hash,
23  ccl_private Ray *ray)
24 {
25  /* Filter sampling. */
26  float filter_u, filter_v;
27 
28  if (sample == 0) {
29  filter_u = 0.5f;
30  filter_v = 0.5f;
31  }
32  else {
33  path_rng_2D(kg, rng_hash, sample, PRNG_FILTER_U, &filter_u, &filter_v);
34  }
35 
36  /* Depth of field sampling. */
37  float lens_u = 0.0f, lens_v = 0.0f;
38  if (kernel_data.cam.aperturesize > 0.0f) {
39  path_rng_2D(kg, rng_hash, sample, PRNG_LENS_U, &lens_u, &lens_v);
40  }
41 
42  /* Motion blur time sampling. */
43  float time = 0.0f;
44 #ifdef __CAMERA_MOTION__
45  if (kernel_data.cam.shuttertime != -1.0f)
46  time = path_rng_1D(kg, rng_hash, sample, PRNG_TIME);
47 #endif
48 
49  /* Generate camera ray. */
50  camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray);
51 }
52 
53 /* Return false to indicate that this pixel is finished.
54  * Used by CPU implementation to not attempt to sample pixel for multiple samples once its known
55  * that the pixel did converge. */
60  const int x,
61  const int y,
62  const int scheduled_sample)
63 {
65 
66  /* Initialize path state to give basic buffer access and allow early outputs. */
68 
69  /* Check whether the pixel has converged and should not be sampled anymore. */
71  return false;
72  }
73 
74  /* Count the sample and get an effective sample for this pixel.
75  *
76  * This logic allows to both count actual number of samples per pixel, and to add samples to this
77  * pixel after it was converged and samples were added somewhere else (in which case the
78  * `scheduled_sample` will be different from actual number of samples in this pixel). */
79  const int sample = kernel_accum_sample(
80  kg, state, render_buffer, scheduled_sample, tile->sample_offset);
81 
82  /* Initialize random number seed for path. */
83  const uint rng_hash = path_rng_hash_init(kg, sample, x, y);
84 
85  {
86  /* Generate camera ray. */
87  Ray ray;
88  integrate_camera_sample(kg, sample, x, y, rng_hash, &ray);
89  if (ray.tmax == 0.0f) {
90  return true;
91  }
92 
93  /* Write camera ray to state. */
95  }
96 
97  /* Initialize path state for path integration. */
98  path_state_init_integrator(kg, state, sample, rng_hash);
99 
100  /* Continue with intersect_closest kernel, optionally initializing volume
101  * stack before that if the camera may be inside a volume. */
102  if (kernel_data.cam.is_inside_volume) {
104  }
105  else {
107  }
108 
109  return true;
110 }
111 
unsigned int uint
Definition: BLI_sys_types.h:67
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
ccl_device_inline int kernel_accum_sample(KernelGlobals kg, ConstIntegratorState state, ccl_global float *ccl_restrict render_buffer, int sample, int sample_offset)
Definition: accumulate.h:138
#define ccl_restrict
Definition: cuda/compat.h:50
#define ccl_device
Definition: cuda/compat.h:32
#define ccl_private
Definition: cuda/compat.h:48
#define ccl_device_inline
Definition: cuda/compat.h:34
#define ccl_global
Definition: cuda/compat.h:43
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
double time
#define kernel_data
const KernelGlobalsCPU *ccl_restrict KernelGlobals
CCL_NAMESPACE_BEGIN ccl_device_inline void integrate_camera_sample(KernelGlobals kg, const int sample, const int x, const int y, const uint rng_hash, 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, float filter_u, float filter_v, float lens_u, float lens_v, float time, ccl_private Ray *ray)
ccl_gpu_kernel_postfix ccl_global KernelWorkTile const int ccl_global float * render_buffer
ccl_global const KernelWorkTile * tile
const int state
CCL_NAMESPACE_BEGIN ccl_device_forceinline bool kernel_need_sample_pixel(KernelGlobals kg, ConstIntegratorState state, ccl_global float *render_buffer)
@ PRNG_FILTER_U
Definition: kernel/types.h:154
@ PRNG_LENS_U
Definition: kernel/types.h:156
@ PRNG_TIME
Definition: kernel/types.h:158
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST
#define PROFILING_INIT(kg, event)
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:24
ccl_device_inline void path_state_init_integrator(KernelGlobals kg, IntegratorState state, const int sample, const uint rng_hash)
Definition: path_state.h:37
CCL_NAMESPACE_BEGIN ccl_device_forceinline float path_rng_1D(KernelGlobals kg, uint rng_hash, int sample, int dimension)
Definition: pattern.h:42
ccl_device_forceinline void path_rng_2D(KernelGlobals kg, uint rng_hash, int sample, int dimension, ccl_private float *fx, ccl_private float *fy)
Definition: pattern.h:76
ccl_device_inline uint path_rng_hash_init(KernelGlobals kg, const int sample, const int x, const int y)
Definition: pattern.h:132
IntegratorStateCPU *ccl_restrict IntegratorState
Definition: state.h:147
ccl_device_forceinline void integrator_path_init(KernelGlobals kg, IntegratorState state, const DeviceKernel next_kernel)
Definition: state_flow.h:135
CCL_NAMESPACE_BEGIN ccl_device_forceinline void integrator_state_write_ray(KernelGlobals kg, IntegratorState state, ccl_private const Ray *ccl_restrict ray)
Definition: state_util.h:14
float tmax
Definition: kernel/types.h:527
@ PROFILING_RAY_SETUP