Blender  V3.3
scene/camera.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __CAMERA_H__
5 #define __CAMERA_H__
6 
7 #include "kernel/types.h"
8 
9 #include "graph/node.h"
10 
11 #include "util/array.h"
12 #include "util/boundbox.h"
13 #include "util/projection.h"
14 #include "util/transform.h"
15 #include "util/types.h"
16 
18 
19 class Device;
20 class DeviceScene;
21 class Scene;
22 
23 /* Camera
24  *
25  * The camera parameters are quite standard, tested to be both compatible with
26  * Renderman, and Blender after remapping.
27  */
28 
29 class Camera : public Node {
30  public:
32 
33  /* Specifies rolling shutter effect. */
35  /* No rolling shutter effect. */
37  /* Sensor is being scanned vertically from top to bottom. */
39 
41  };
42 
43  /* Stereo Type */
44  enum StereoEye {
48  };
49 
50  /* motion blur */
51  NODE_SOCKET_API(float, shuttertime)
52  NODE_SOCKET_API(MotionPosition, motion_position)
53  NODE_SOCKET_API_ARRAY(array<float>, shutter_curve)
55 
56  /* ** Rolling shutter effect. ** */
57  /* Defines rolling shutter effect type. */
58  NODE_SOCKET_API(RollingShutterType, rolling_shutter_type)
59  /* Specifies exposure time of scan-lines when using
60  * rolling shutter effect.
61  */
62  NODE_SOCKET_API(float, rolling_shutter_duration)
63 
64  /* depth of field */
65  NODE_SOCKET_API(float, focaldistance)
66  NODE_SOCKET_API(float, aperturesize)
67  NODE_SOCKET_API(uint, blades)
68  NODE_SOCKET_API(float, bladesrotation)
69 
70  /* type */
71  NODE_SOCKET_API(CameraType, camera_type)
72  NODE_SOCKET_API(float, fov)
73 
74  /* panorama */
75  NODE_SOCKET_API(PanoramaType, panorama_type)
76  NODE_SOCKET_API(float, fisheye_fov)
77  NODE_SOCKET_API(float, fisheye_lens)
78  NODE_SOCKET_API(float, latitude_min)
79  NODE_SOCKET_API(float, latitude_max)
80  NODE_SOCKET_API(float, longitude_min)
81  NODE_SOCKET_API(float, longitude_max)
82 
83  NODE_SOCKET_API(float, fisheye_polynomial_k0)
84  NODE_SOCKET_API(float, fisheye_polynomial_k1)
85  NODE_SOCKET_API(float, fisheye_polynomial_k2)
86  NODE_SOCKET_API(float, fisheye_polynomial_k3)
87  NODE_SOCKET_API(float, fisheye_polynomial_k4)
88 
89  /* panorama stereo */
90  NODE_SOCKET_API(StereoEye, stereo_eye)
91  NODE_SOCKET_API(bool, use_spherical_stereo)
92  NODE_SOCKET_API(float, interocular_distance)
93  NODE_SOCKET_API(float, convergence_distance)
94  NODE_SOCKET_API(bool, use_pole_merge)
95  NODE_SOCKET_API(float, pole_merge_angle_from)
96  NODE_SOCKET_API(float, pole_merge_angle_to)
97 
98  /* anamorphic lens bokeh */
99  NODE_SOCKET_API(float, aperture_ratio)
100 
101  /* sensor */
102  NODE_SOCKET_API(float, sensorwidth)
103  NODE_SOCKET_API(float, sensorheight)
104 
105  /* clipping */
106  NODE_SOCKET_API(float, nearclip)
107  NODE_SOCKET_API(float, farclip)
108 
109  /* screen */
115 
116  /* width and height change during preview, so we need these for calculating dice rates. */
117  NODE_SOCKET_API(int, full_width)
118  NODE_SOCKET_API(int, full_height)
119  /* controls how fast the dicing rate falls off for geometry out side of view */
120  NODE_SOCKET_API(float, offscreen_dicing_scale)
121 
122  /* border */
128 
134 
135  /* transformation */
136  NODE_SOCKET_API(Transform, matrix)
137 
138  /* motion */
140  NODE_SOCKET_API(bool, use_perspective_motion)
141  NODE_SOCKET_API(float, fov_pre)
142  NODE_SOCKET_API(float, fov_post)
143 
144  /* computed camera parameters */
149 
154 
157 
159 
162 
165 
170 
171  /* update */
175 
176  /* Kernel camera data, copied here for dicing. */
179 
180  private:
181  int width;
182  int height;
183 
184  public:
185  /* functions */
186  Camera();
187  ~Camera();
188 
189  void compute_auto_viewplane();
190 
191  void update(Scene *scene);
192 
193  void device_update(Device *device, DeviceScene *dscene, Scene *scene);
194  void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene);
195  void device_free(Device *device, DeviceScene *dscene, Scene *scene);
196 
197  /* Public utility functions. */
199 
200  /* Calculates the width of a pixel at point in world space. */
202 
203  /* Motion blur. */
204  float motion_time(int step) const;
205  int motion_step(float time) const;
206  bool use_motion() const;
207 
208  void set_screen_size(int width_, int height_);
209 
210  private:
211  /* Private utility functions. */
212  float3 transform_raster_to_world(float raster_x, float raster_y);
213 };
214 
216 
217 #endif /* __CAMERA_H__ */
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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble right
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
double time
Scene scene
#define NODE_SOCKET_API_STRUCT_MEMBER(type_, name, member)
Definition: graph/node.h:75
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition: graph/node.h:62
#define NODE_SOCKET_API(type_, name)
Definition: graph/node.h:54
MotionPosition
Definition: kernel/types.h:481
PanoramaType
Definition: kernel/types.h:470
CameraType
Definition: kernel/types.h:466
static float P(float k)
Definition: math_interp.c:25
static int left
#define NODE_DECLARE
Definition: node_type.h:135
bool need_device_update
Definition: scene/camera.h:172
ProjectionTransform worldtoraster
Definition: scene/camera.h:150
RollingShutterType
Definition: scene/camera.h:34
@ ROLLING_SHUTTER_NUM_TYPES
Definition: scene/camera.h:40
@ ROLLING_SHUTTER_NONE
Definition: scene/camera.h:36
@ ROLLING_SHUTTER_TOP
Definition: scene/camera.h:38
float3 frustum_right_normal
Definition: scene/camera.h:166
BoundBox2D viewplane
Definition: scene/camera.h:110
void set_screen_size(int width_, int height_)
int previous_need_motion
Definition: scene/camera.h:174
float3 full_dy
Definition: scene/camera.h:164
bool need_flags_update
Definition: scene/camera.h:173
float3 full_dx
Definition: scene/camera.h:163
ProjectionTransform rastertoworld
Definition: scene/camera.h:146
BoundBox viewplane_bounds_get()
Transform worldtocamera
Definition: scene/camera.h:153
ProjectionTransform worldtoscreen
Definition: scene/camera.h:151
ProjectionTransform worldtondc
Definition: scene/camera.h:152
float motion_time(int step) const
void update(Scene *scene)
ProjectionTransform rastertocamera
Definition: scene/camera.h:155
BoundBox2D border
Definition: scene/camera.h:123
ProjectionTransform screentoworld
Definition: scene/camera.h:145
bool use_motion() const
size_t shutter_table_offset
Definition: scene/camera.h:54
void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene)
void device_free(Device *device, DeviceScene *dscene, Scene *scene)
ProjectionTransform ndctoworld
Definition: scene/camera.h:147
float3 dx
Definition: scene/camera.h:160
void device_update(Device *device, DeviceScene *dscene, Scene *scene)
float3 frustum_left_normal
Definition: scene/camera.h:168
float world_to_raster_size(float3 P)
Transform cameratoworld
Definition: scene/camera.h:148
int motion_step(float time) const
void compute_auto_viewplane()
float3 frustum_top_normal
Definition: scene/camera.h:167
ProjectionTransform full_rastertocamera
Definition: scene/camera.h:158
ProjectionTransform cameratoraster
Definition: scene/camera.h:156
float3 frustum_bottom_normal
Definition: scene/camera.h:169
float3 dy
Definition: scene/camera.h:161
@ STEREO_LEFT
Definition: scene/camera.h:46
@ STEREO_NONE
Definition: scene/camera.h:45
@ STEREO_RIGHT
Definition: scene/camera.h:47
BoundBox2D viewport_camera_border
Definition: scene/camera.h:129
KernelCamera kernel_camera
Definition: scene/camera.h:177
array< DecomposedTransform > kernel_camera_motion
Definition: scene/camera.h:178