Blender V5.0
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 */
92
98
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
149
150 /* transformation */
152
153 /* motion */
155 NODE_SOCKET_API(bool, use_perspective_motion)
156 NODE_SOCKET_API(float, fov_pre)
157 NODE_SOCKET_API(float, fov_post)
158
159 /* computed camera parameters */
164
169
171
173
176
179
184
185 /* update */
189
190 /* Kernel camera data, copied here for dicing. */
193
194 /* Custom camera script. */
195 std::string script_name;
196 map<ustring, pair<vector<uint8_t>, TypeDesc>> script_params;
197
198 private:
199 int width;
200 int height;
201
202 public:
203 /* functions */
204 Camera();
206
208
209 void update(Scene *scene);
210
211 void device_update(Device *device, DeviceScene *dscene, Scene *scene);
212 void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene);
213 void device_free(Device *device, DeviceScene *dscene, Scene *scene);
214
215 /* Public utility functions. */
217
218 /* Calculates the width of a pixel at point in world space. */
219 float world_to_raster_size(const float3 P);
220
221 /* Motion blur. */
222 float motion_time(const int step) const;
223 int motion_step(const float time) const;
224 bool use_motion() const;
225
227
228 bool set_screen_size(const int width_, int height_);
229
230 void set_osl_camera(Scene *scene,
232 const std::string &filepath,
233 const std::string &bytecode_hash = "",
234 const std::string &bytecode = "");
235 void clear_osl_camera(Scene *scene);
236
237 private:
238 /* Private utility functions. */
239 float3 transform_full_raster_to_world(const float raster_x, const float raster_y);
240};
241
unsigned int uint
BMesh const char void * data
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
#define CCL_NAMESPACE_END
uint top
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define NODE_SOCKET_API_STRUCT_MEMBER(type_, name, member)
Definition graph/node.h:76
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition graph/node.h:63
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:55
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
MotionPosition
PanoramaType
CameraType
static int left
#define NODE_DECLARE
Definition node_type.h:145
const char * name
bool need_device_update
float world_to_raster_size(const float3 P)
char panorama_type
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
bool need_flags_update
float latitude_max
float3 full_dx
ProjectionTransform rastertoworld
BoundBox viewplane_bounds_get()
float central_cylindrical_range_v_min
Transform worldtocamera
uint get_kernel_features() const
float fisheye_polynomial_k3
ProjectionTransform worldtoscreen
ProjectionTransform worldtondc
float longitude_max
float central_cylindrical_range_u_min
void update(Scene *scene)
ProjectionTransform rastertocamera
BoundBox2D border
float fisheye_polynomial_k1
float central_cylindrical_range_u_max
float latitude_min
ProjectionTransform screentoworld
float fisheye_polynomial_k2
bool use_motion() const
size_t shutter_table_offset
void device_update_volume(Device *device, DeviceScene *dscene, Scene *scene)
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)
bool set_screen_size(const int width_, int height_)
float3 frustum_left_normal
void clear_osl_camera(Scene *scene)
float fisheye_fov
Transform cameratoworld
float fisheye_polynomial_k0
void compute_auto_viewplane()
float3 frustum_top_normal
float fisheye_polynomial_k4
ProjectionTransform full_rastertocamera
float3 frustum_bottom_normal
float fisheye_lens
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
float central_cylindrical_range_v_max
map< ustring, pair< vector< uint8_t >, TypeDesc > > script_params
float longitude_min
array< DecomposedTransform > kernel_camera_motion
bool override
Definition wm_files.cc:1192