Debian Codegraph @

servers/rendering/storage/camera_attributes_storage.h

raw symbols SCIP
1 /**************************************************************************/
2 /* camera_attributes_storage.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/templates/rid_owner.h"
34 #include "servers/rendering/rendering_server.h"
35
36 class RendererCameraAttributes {
37 private:
38 static RendererCameraAttributes *singleton;
39
40 struct CameraAttributes {
41 float exposure_multiplier = 1.0;
42 float exposure_normalization = 1.0;
43 float exposure_sensitivity = 100.0; // In ISO.
44
45 bool use_auto_exposure = false;
46 float auto_exposure_min_sensitivity = 50.0;
47 float auto_exposure_max_sensitivity = 800.0;
48 float auto_exposure_adjust_speed = 1.0;
49 float auto_exposure_scale = 1.0;
50 uint64_t auto_exposure_version = 0;
51
52 bool dof_blur_far_enabled = false;
53 float dof_blur_far_distance = 10;
54 float dof_blur_far_transition = 5;
55 bool dof_blur_near_enabled = false;
56 float dof_blur_near_distance = 2;
57 float dof_blur_near_transition = 1;
58 float dof_blur_amount = 0.1;
59 };
60
61 RS::DOFBlurQuality dof_blur_quality = RS::DOF_BLUR_QUALITY_MEDIUM;
62 RS::DOFBokehShape dof_blur_bokeh_shape = RS::DOF_BOKEH_HEXAGON;
63 bool dof_blur_use_jitter = false;
64 static uint64_t auto_exposure_counter;
65
66 mutable RID_Owner<CameraAttributes, true> camera_attributes_owner;
67
68 public:
69 static RendererCameraAttributes *get_singleton() { return singleton; }
70
71 RendererCameraAttributes();
72 ~RendererCameraAttributes();
73
74 CameraAttributes *get_camera_attributes(RID p_rid) { return camera_attributes_owner.get_or_null(p_rid); }
75 bool owns_camera_attributes(RID p_rid) { return camera_attributes_owner.owns(p_rid); }
76
77 RID camera_attributes_allocate();
78 void camera_attributes_initialize(RID p_rid);
79 void camera_attributes_free(RID p_rid);
80
81 void camera_attributes_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter);
82 void camera_attributes_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape);
83
84 void camera_attributes_set_dof_blur(RID p_camera_attributes, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount);
85 bool camera_attributes_get_dof_far_enabled(RID p_camera_attributes);
86 float camera_attributes_get_dof_far_distance(RID p_camera_attributes);
87 float camera_attributes_get_dof_far_transition(RID p_camera_attributes);
88 bool camera_attributes_get_dof_near_enabled(RID p_camera_attributes);
89 float camera_attributes_get_dof_near_distance(RID p_camera_attributes);
90 float camera_attributes_get_dof_near_transition(RID p_camera_attributes);
91 float camera_attributes_get_dof_blur_amount(RID p_camera_attributes);
92
93 _FORCE_INLINE_ bool camera_attributes_uses_dof(RID p_camera_attributes) {
94 CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
95
96 return cam_attributes && (cam_attributes->dof_blur_near_enabled || cam_attributes->dof_blur_far_enabled) && cam_attributes->dof_blur_amount > 0.0;
97 }
98
99 void camera_attributes_set_exposure(RID p_camera_attributes, float p_multiplier, float p_exposure_normalization);
100 float camera_attributes_get_exposure_normalization_factor(RID p_camera_attributes);
101
102 void camera_attributes_set_auto_exposure(RID p_camera_attributes, bool p_enable, float p_min_sensitivity, float p_max_sensitivity, float p_speed, float p_scale);
103 float camera_attributes_get_auto_exposure_min_sensitivity(RID p_camera_attributes);
104 float camera_attributes_get_auto_exposure_max_sensitivity(RID p_camera_attributes);
105 float camera_attributes_get_auto_exposure_adjust_speed(RID p_camera_attributes);
106 float camera_attributes_get_auto_exposure_scale(RID p_camera_attributes);
107 uint64_t camera_attributes_get_auto_exposure_version(RID p_camera_attributes);
108
109 _FORCE_INLINE_ bool camera_attributes_uses_auto_exposure(RID p_camera_attributes) {
110 CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes);
111
112 return cam_attributes && cam_attributes->use_auto_exposure;
113 }
114
115 _FORCE_INLINE_ RS::DOFBlurQuality camera_attributes_get_dof_blur_quality() {
116 return dof_blur_quality;
117 }
118
119 _FORCE_INLINE_ RS::DOFBokehShape camera_attributes_get_dof_blur_bokeh_shape() {
120 return dof_blur_bokeh_shape;
121 }
122
123 _FORCE_INLINE_ bool camera_attributes_get_dof_blur_use_jitter() {
124 return dof_blur_use_jitter;
125 }
126 };