Debian Codegraph @

scene/resources/camera_attributes.h

raw symbols SCIP
1 /**************************************************************************/
2 /* camera_attributes.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/io/resource.h"
34 #include "core/templates/rid.h"
35
36 class CameraAttributes : public Resource {
37 GDCLASS(CameraAttributes, Resource);
38
39 private:
40 RID camera_attributes;
41
42 protected:
43 static void _bind_methods();
44 void _validate_property(PropertyInfo &p_property) const;
45
46 float exposure_multiplier = 1.0;
47 float exposure_sensitivity = 100.0; // In ISO.
48 void _update_exposure();
49
50 bool auto_exposure_enabled = false;
51 float auto_exposure_min = 0.01;
52 float auto_exposure_max = 64.0;
53 float auto_exposure_speed = 0.5;
54 float auto_exposure_scale = 0.4;
55 virtual void _update_auto_exposure() {}
56
57 public:
58 virtual RID get_rid() const override;
59 virtual float calculate_exposure_normalization() const { return 1.0; }
60
61 void set_exposure_multiplier(float p_multiplier);
62 float get_exposure_multiplier() const;
63 void set_exposure_sensitivity(float p_sensitivity);
64 float get_exposure_sensitivity() const;
65
66 void set_auto_exposure_enabled(bool p_enabled);
67 bool is_auto_exposure_enabled() const;
68 void set_auto_exposure_speed(float p_auto_exposure_speed);
69 float get_auto_exposure_speed() const;
70 void set_auto_exposure_scale(float p_auto_exposure_scale);
71 float get_auto_exposure_scale() const;
72
73 CameraAttributes();
74 ~CameraAttributes();
75 };
76
77 class CameraAttributesPractical : public CameraAttributes {
78 GDCLASS(CameraAttributesPractical, CameraAttributes);
79
80 private:
81 // DOF blur
82 bool dof_blur_far_enabled = false;
83 float dof_blur_far_distance = 10.0;
84 float dof_blur_far_transition = 5.0;
85
86 bool dof_blur_near_enabled = false;
87 float dof_blur_near_distance = 2.0;
88 float dof_blur_near_transition = 1.0;
89
90 float dof_blur_amount = 0.1;
91 void _update_dof_blur();
92
93 virtual void _update_auto_exposure() override;
94
95 protected:
96 static void _bind_methods();
97 void _validate_property(PropertyInfo &p_property) const;
98
99 public:
100 // DOF blur
101 void set_dof_blur_far_enabled(bool p_enabled);
102 bool is_dof_blur_far_enabled() const;
103 void set_dof_blur_far_distance(float p_distance);
104 float get_dof_blur_far_distance() const;
105 void set_dof_blur_far_transition(float p_distance);
106 float get_dof_blur_far_transition() const;
107
108 void set_dof_blur_near_enabled(bool p_enabled);
109 bool is_dof_blur_near_enabled() const;
110 void set_dof_blur_near_distance(float p_distance);
111 float get_dof_blur_near_distance() const;
112 void set_dof_blur_near_transition(float p_distance);
113 float get_dof_blur_near_transition() const;
114 void set_dof_blur_amount(float p_amount);
115 float get_dof_blur_amount() const;
116
117 void set_auto_exposure_min_sensitivity(float p_min);
118 float get_auto_exposure_min_sensitivity() const;
119 void set_auto_exposure_max_sensitivity(float p_max);
120 float get_auto_exposure_max_sensitivity() const;
121
122 virtual float calculate_exposure_normalization() const override;
123
124 CameraAttributesPractical();
125 ~CameraAttributesPractical();
126 };
127
128 class CameraAttributesPhysical : public CameraAttributes {
129 GDCLASS(CameraAttributesPhysical, CameraAttributes);
130
131 private:
132 // Exposure
133 float exposure_aperture = 16.0; // In f-stops;
134 float exposure_shutter_speed = 100.0; // In 1 / seconds;
135
136 // Camera properties.
137 float frustum_focal_length = 35.0; // In millimeters.
138 float frustum_focus_distance = 10.0; // In Meters.
139 real_t frustum_near = 0.05;
140 real_t frustum_far = 4000.0;
141 real_t frustum_fov = 75.0;
142 void _update_frustum();
143
144 virtual void _update_auto_exposure() override;
145
146 protected:
147 static void _bind_methods();
148 void _validate_property(PropertyInfo &property) const;
149
150 public:
151 void set_aperture(float p_aperture);
152 float get_aperture() const;
153
154 void set_shutter_speed(float p_shutter_speed);
155 float get_shutter_speed() const;
156
157 void set_focal_length(float p_focal_length);
158 float get_focal_length() const;
159
160 void set_focus_distance(float p_focus_distance);
161 float get_focus_distance() const;
162
163 void set_near(real_t p_near);
164 real_t get_near() const;
165
166 void set_far(real_t p_far);
167 real_t get_far() const;
168
169 real_t get_fov() const;
170
171 void set_auto_exposure_min_exposure_value(float p_min);
172 float get_auto_exposure_min_exposure_value() const;
173 void set_auto_exposure_max_exposure_value(float p_max);
174 float get_auto_exposure_max_exposure_value() const;
175
176 virtual float calculate_exposure_normalization() const override;
177
178 CameraAttributesPhysical();
179 ~CameraAttributesPhysical();
180 };