Blender V5.3
scene/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
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
19class Device;
20class DeviceScene;
21class Scene;
22
24 public:
26 virtual ~OSLCameraParamQuery() = default;
27
28 virtual bool get_float(ustring name, vector<float> &data) = 0;
29 virtual bool get_int(ustring name, vector<int> &data) = 0;
30 virtual bool get_string(ustring name, std::string &data) = 0;
31};
32
33/* Camera
34 *
35 * The camera parameters are quite standard, tested to be both compatible with
36 * RenderMan, and Blender after remapping.
37 */
38
39class Camera : public Node {
40 public:
42
43 /* Specifies rolling shutter effect. */
45 /* No rolling shutter effect. */
47 /* Sensor is being scanned vertically from top to bottom. */
49
51 };
52
53 /* Stereo Type */
59
60 /* motion blur */
61 NODE_SOCKET_API(float, shuttertime)
62 NODE_SOCKET_API(MotionPosition, motion_position)
65
66 /* ** Rolling shutter effect. ** */
67 /* Defines rolling shutter effect type. */
68 NODE_SOCKET_API(RollingShutterType, rolling_shutter_type)
69 /* Specifies exposure time of scan-lines when using
70 * rolling shutter effect.
71 */
72 NODE_SOCKET_API(float, rolling_shutter_duration)
73
74 /* depth of field */
75 NODE_SOCKET_API(float, focaldistance)
76 NODE_SOCKET_API(float, aperturesize)
77 NODE_SOCKET_API(uint, blades)
78 NODE_SOCKET_API(float, bladesrotation)
79
80 /* type */
81 NODE_SOCKET_API(CameraType, camera_type)
82 NODE_SOCKET_API(float, fov)
83
84 /* panorama */
85 NODE_SOCKET_API(PanoramaType, panorama_type)
86 NODE_SOCKET_API(float, fisheye_fov)
87 NODE_SOCKET_API(float, fisheye_lens)
88 NODE_SOCKET_API(float, latitude_min)
89 NODE_SOCKET_API(float, latitude_max)
90 NODE_SOCKET_API(float, longitude_min)
91 NODE_SOCKET_API(float, longitude_max)
92
93 NODE_SOCKET_API(float, fisheye_polynomial_k0)
94 NODE_SOCKET_API(float, fisheye_polynomial_k1)
95 NODE_SOCKET_API(float, fisheye_polynomial_k2)
96 NODE_SOCKET_API(float, fisheye_polynomial_k3)
97 NODE_SOCKET_API(float, fisheye_polynomial_k4)
98
99 NODE_SOCKET_API(float, central_cylindrical_range_u_min)
100 NODE_SOCKET_API(float, central_cylindrical_range_u_max)
101 NODE_SOCKET_API(float, central_cylindrical_range_v_min)
102 NODE_SOCKET_API(float, central_cylindrical_range_v_max)
103
104 /* panorama stereo */
105 NODE_SOCKET_API(StereoEye, stereo_eye)
106 NODE_SOCKET_API(bool, use_spherical_stereo)
107 NODE_SOCKET_API(float, interocular_distance)
108 NODE_SOCKET_API(float, convergence_distance)
109 NODE_SOCKET_API(bool, use_pole_merge)
110 NODE_SOCKET_API(float, pole_merge_angle_from)
111 NODE_SOCKET_API(float, pole_merge_angle_to)
112
113 /* anamorphic lens bokeh */
114 NODE_SOCKET_API(float, aperture_ratio)
115
116 /* sensor */
117 NODE_SOCKET_API(float, sensorwidth)
118 NODE_SOCKET_API(float, sensorheight)
119
120 /* clipping */
121 NODE_SOCKET_API(float, nearclip)
122 NODE_SOCKET_API(float, farclip)
123
124 /* screen */
130
131 /* width and height change during preview, so we need these for calculating dice rates. */
132 NODE_SOCKET_API(int, full_width)
133 NODE_SOCKET_API(int, full_height)
134 /* controls how fast the dicing rate falls off for geometry out side of view */
135 NODE_SOCKET_API(float, offscreen_dicing_scale)
136
137 /* border */
143 NODE_SOCKET_API(float, border_pre_left)
144 NODE_SOCKET_API(float, border_pre_bottom)
145
151
152 /* transformation */
154
155 /* motion */
157 NODE_SOCKET_API(bool, use_perspective_motion)
158 NODE_SOCKET_API(float, fov_pre)
159 NODE_SOCKET_API(float, fov_post)
160
171
172 /* computed camera parameters */
177
182
184
186
189
192
197
198 /* update */
202
203 /* Kernel camera data, copied here for dicing. */
206
207 /* Custom camera script. */
208 std::string script_name;
209 map<ustring, pair<vector<uint8_t>, TypeDesc>> script_params;
210
211 private:
212 int width = 1024;
213 int height = 512;
214
215 public:
216 /* functions */
217 Camera();
218 ~Camera() override;
219
221
222 void update(Scene *scene);
223
225
226 void device_update(Device *device, DeviceScene *dscene, Scene *scene);
227 void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene);
228 void device_free(Device *device, DeviceScene *dscene, Scene *scene);
229
230 /* Public utility functions. */
232
233 /* Calculates the width of a pixel at point in world space. */
234 float world_to_raster_size(const float3 P);
235
236 /* Motion blur. */
237 float motion_time(const int step) const;
238 int motion_step(const float time) const;
239 bool use_motion() const;
240
242
243 bool set_screen_size(int width, int height);
244
245 void set_osl_camera(Scene *scene,
246 OSLCameraParamQuery &params,
247 const std::string &filepath,
248 const std::string &bytecode_hash = "",
249 const std::string &bytecode = "");
250 void clear_osl_camera(Scene *scene);
251
252 private:
253 /* Private utility functions. */
254 float3 transform_full_raster_to_world(const float raster_x, const float raster_y);
255};
256
unsigned long long int uint64_t
bool need_device_update
float world_to_raster_size(const float3 P)
ProjectionTransform worldtoraster
RollingShutterType
@ ROLLING_SHUTTER_NUM_TYPES
@ ROLLING_SHUTTER_NONE
@ ROLLING_SHUTTER_TOP
float3 frustum_right_normal
float motion_time(const int step) const
BoundBox2D viewplane
int previous_need_motion
float3 full_dy
BoundBox2D viewplane_pre
bool need_flags_update
float3 full_dx
ProjectionTransform rastertoworld
BoundBox viewplane_bounds_get()
void update_interactive_motion()
BoundBox2D viewplane_post
Transform worldtocamera
ProjectionTransform worldtoscreen
ProjectionTransform worldtondc
void update(Scene *scene)
ProjectionTransform rastertocamera
BoundBox2D border
ProjectionTransform screentoworld
bool use_motion() const
size_t shutter_table_offset
void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene)
bool set_screen_size(int width, int height)
void device_free(Device *device, DeviceScene *dscene, Scene *scene)
int motion_step(const float time) const
ProjectionTransform ndctoworld
float3 dx
std::string script_name
void device_update(Device *device, DeviceScene *dscene, Scene *scene)
float3 frustum_left_normal
void clear_osl_camera(Scene *scene)
Transform cameratoworld
uint64_t get_kernel_features() const
void compute_auto_viewplane()
float3 frustum_top_normal
ProjectionTransform full_rastertocamera
float3 frustum_bottom_normal
float3 dy
void set_osl_camera(Scene *scene, OSLCameraParamQuery &params, const std::string &filepath, const std::string &bytecode_hash="", const std::string &bytecode="")
@ STEREO_LEFT
@ STEREO_NONE
@ STEREO_RIGHT
BoundBox2D viewport_camera_border
KernelCamera kernel_camera
map< ustring, pair< vector< uint8_t >, TypeDesc > > script_params
array< DecomposedTransform > kernel_camera_motion
virtual bool get_string(ustring name, std::string &data)=0
virtual bool get_int(ustring name, vector< int > &data)=0
virtual ~OSLCameraParamQuery()=default
OSLCameraParamQuery()=default
virtual bool get_float(ustring name, vector< float > &data)=0
Definition scene.h:133
#define CCL_NAMESPACE_END
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define NODE_SOCKET_API_STRUCT_MEMBER(type_, name, member)
Definition graph/node.h:77
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition graph/node.h:64
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:56
MotionPosition
PanoramaType
CameraType
#define NODE_DECLARE
Definition node_type.h:150
Node(const NodeType *type, ustring name=ustring())