Blender  V2.93
camera.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __CAMERA_H__
18 #define __CAMERA_H__
19 
20 #include "kernel/kernel_types.h"
21 
22 #include "graph/node.h"
23 
24 #include "util/util_array.h"
25 #include "util/util_boundbox.h"
26 #include "util/util_projection.h"
27 #include "util/util_transform.h"
28 #include "util/util_types.h"
29 
31 
32 class Device;
33 class DeviceScene;
34 class Scene;
35 
36 /* Camera
37  *
38  * The camera parameters are quite standard, tested to be both compatible with
39  * Renderman, and Blender after remapping.
40  */
41 
42 class Camera : public Node {
43  public:
45 
46  /* Specifies an offset for the shutter's time interval. */
48  /* Shutter opens at the current frame. */
50  /* Shutter is fully open at the current frame. */
52  /* Shutter closes at the current frame. */
54 
56  };
57 
58  /* Specifies rolling shutter effect. */
60  /* No rolling shutter effect. */
62  /* Sensor is being scanned vertically from top to bottom. */
64 
66  };
67 
68  /* Stereo Type */
69  enum StereoEye {
73  };
74 
75  /* motion blur */
76  NODE_SOCKET_API(float, shuttertime)
77  NODE_SOCKET_API(MotionPosition, motion_position)
78  NODE_SOCKET_API_ARRAY(array<float>, shutter_curve)
80 
81  /* ** Rolling shutter effect. ** */
82  /* Defines rolling shutter effect type. */
83  NODE_SOCKET_API(RollingShutterType, rolling_shutter_type)
84  /* Specifies exposure time of scanlines when using
85  * rolling shutter effect.
86  */
87  NODE_SOCKET_API(float, rolling_shutter_duration)
88 
89  /* depth of field */
90  NODE_SOCKET_API(float, focaldistance)
91  NODE_SOCKET_API(float, aperturesize)
92  NODE_SOCKET_API(uint, blades)
93  NODE_SOCKET_API(float, bladesrotation)
94 
95  /* type */
96  NODE_SOCKET_API(CameraType, camera_type)
97  NODE_SOCKET_API(float, fov)
98 
99  /* panorama */
100  NODE_SOCKET_API(PanoramaType, panorama_type)
101  NODE_SOCKET_API(float, fisheye_fov)
102  NODE_SOCKET_API(float, fisheye_lens)
103  NODE_SOCKET_API(float, latitude_min)
104  NODE_SOCKET_API(float, latitude_max)
105  NODE_SOCKET_API(float, longitude_min)
106  NODE_SOCKET_API(float, longitude_max)
107 
108  /* panorama stereo */
109  NODE_SOCKET_API(StereoEye, stereo_eye)
110  NODE_SOCKET_API(bool, use_spherical_stereo)
111  NODE_SOCKET_API(float, interocular_distance)
112  NODE_SOCKET_API(float, convergence_distance)
113  NODE_SOCKET_API(bool, use_pole_merge)
114  NODE_SOCKET_API(float, pole_merge_angle_from)
115  NODE_SOCKET_API(float, pole_merge_angle_to)
116 
117  /* anamorphic lens bokeh */
118  NODE_SOCKET_API(float, aperture_ratio)
119 
120  /* sensor */
121  NODE_SOCKET_API(float, sensorwidth)
122  NODE_SOCKET_API(float, sensorheight)
123 
124  /* clipping */
125  NODE_SOCKET_API(float, nearclip)
126  NODE_SOCKET_API(float, farclip)
127 
128  /* screen */
134 
135  /* width and height change during preview, so we need these for calculating dice rates. */
136  NODE_SOCKET_API(int, full_width)
137  NODE_SOCKET_API(int, full_height)
138  /* controls how fast the dicing rate falls off for geometry out side of view */
139  NODE_SOCKET_API(float, offscreen_dicing_scale)
140 
141  /* border */
147 
153 
154  /* transformation */
155  NODE_SOCKET_API(Transform, matrix)
156 
157  /* motion */
159  NODE_SOCKET_API(bool, use_perspective_motion)
160  NODE_SOCKET_API(float, fov_pre)
161  NODE_SOCKET_API(float, fov_post)
162 
163  /* computed camera parameters */
168 
173 
176 
178 
181 
184 
189 
190  /* update */
194 
195  /* Kernel camera data, copied here for dicing. */
198 
199  private:
200  int width;
201  int height;
202  int resolution;
203 
204  public:
205  /* functions */
206  Camera();
207  ~Camera();
208 
209  void compute_auto_viewplane();
210 
211  void update(Scene *scene);
212 
213  void device_update(Device *device, DeviceScene *dscene, Scene *scene);
214  void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene);
215  void device_free(Device *device, DeviceScene *dscene, Scene *scene);
216 
217  /* Public utility functions. */
219 
220  /* Calculates the width of a pixel at point in world space. */
222 
223  /* Motion blur. */
224  float motion_time(int step) const;
225  int motion_step(float time) const;
226  bool use_motion() const;
227 
228  void set_screen_size_and_resolution(int width_, int height_, int resolution_);
229 
230  private:
231  /* Private utility functions. */
232  float3 transform_raster_to_world(float raster_x, float raster_y);
233 };
234 
236 
237 #endif /* __CAMERA_H__ */
unsigned int uint
Definition: BLI_sys_types.h:83
_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
Definition: device.h:293
double time
Scene scene
#define CCL_NAMESPACE_END
PanoramaType
Definition: kernel_types.h:614
CameraType
Definition: kernel_types.h:610
static float P(float k)
Definition: math_interp.c:41
static int left
#define NODE_SOCKET_API_STRUCT_MEMBER(type_, name, member)
Definition: node.h:84
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition: node.h:71
#define NODE_SOCKET_API(type_, name)
Definition: node.h:63
#define NODE_DECLARE
Definition: node_type.h:148
bool need_device_update
Definition: camera.h:191
ProjectionTransform worldtoraster
Definition: camera.h:169
RollingShutterType
Definition: camera.h:59
@ ROLLING_SHUTTER_NUM_TYPES
Definition: camera.h:65
@ ROLLING_SHUTTER_NONE
Definition: camera.h:61
@ ROLLING_SHUTTER_TOP
Definition: camera.h:63
float3 frustum_right_normal
Definition: camera.h:185
BoundBox2D viewplane
Definition: camera.h:129
int previous_need_motion
Definition: camera.h:193
float3 full_dy
Definition: camera.h:183
bool need_flags_update
Definition: camera.h:192
float3 full_dx
Definition: camera.h:182
MotionPosition
Definition: camera.h:47
@ MOTION_POSITION_START
Definition: camera.h:49
@ MOTION_NUM_POSITIONS
Definition: camera.h:55
@ MOTION_POSITION_CENTER
Definition: camera.h:51
@ MOTION_POSITION_END
Definition: camera.h:53
ProjectionTransform rastertoworld
Definition: camera.h:165
BoundBox viewplane_bounds_get()
Definition: camera.cpp:594
Transform worldtocamera
Definition: camera.h:172
ProjectionTransform worldtoscreen
Definition: camera.h:170
ProjectionTransform worldtondc
Definition: camera.h:171
float motion_time(int step) const
Definition: camera.cpp:802
void update(Scene *scene)
Definition: camera.cpp:231
ProjectionTransform rastertocamera
Definition: camera.h:174
BoundBox2D border
Definition: camera.h:142
void set_screen_size_and_resolution(int width_, int height_, int resolution_)
Definition: camera.cpp:792
ProjectionTransform screentoworld
Definition: camera.h:164
bool use_motion() const
Definition: camera.cpp:787
size_t shutter_table_offset
Definition: camera.h:79
void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene)
Definition: camera.cpp:521
void device_free(Device *device, DeviceScene *dscene, Scene *scene)
Definition: camera.cpp:559
ProjectionTransform ndctoworld
Definition: camera.h:166
float3 dx
Definition: camera.h:179
void device_update(Device *device, DeviceScene *dscene, Scene *scene)
Definition: camera.cpp:482
float3 frustum_left_normal
Definition: camera.h:187
float world_to_raster_size(float3 P)
Definition: camera.cpp:635
Transform cameratoworld
Definition: camera.h:167
int motion_step(float time) const
Definition: camera.cpp:807
void compute_auto_viewplane()
Definition: camera.cpp:206
float3 frustum_top_normal
Definition: camera.h:186
ProjectionTransform full_rastertocamera
Definition: camera.h:177
ProjectionTransform cameratoraster
Definition: camera.h:175
float3 frustum_bottom_normal
Definition: camera.h:188
float3 dy
Definition: camera.h:180
StereoEye
Definition: camera.h:69
@ STEREO_LEFT
Definition: camera.h:71
@ STEREO_NONE
Definition: camera.h:70
@ STEREO_RIGHT
Definition: camera.h:72
BoundBox2D viewport_camera_border
Definition: camera.h:148
KernelCamera kernel_camera
Definition: camera.h:196
array< DecomposedTransform > kernel_camera_motion
Definition: camera.h:197
Definition: node.h:98