| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 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; |
| 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 |
|
| 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 |
|
| 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 |
|
| 133 |
float exposure_aperture = 16.0; |
| 134 |
float exposure_shutter_speed = 100.0; |
| 135 |
|
| 136 |
|
| 137 |
float frustum_focal_length = 35.0; |
| 138 |
float frustum_focus_distance = 10.0; |
| 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 |
}; |