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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
/*************************************************************************/
/* environment.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include "core/resource.h"
#include "scene/resources/sky.h"
#include "scene/resources/texture.h"
#include "servers/rendering_server.h"
class Environment : public Resource {
GDCLASS(Environment, Resource);
public:
enum BGMode {
BG_CLEAR_COLOR,
BG_COLOR,
BG_SKY,
BG_CANVAS,
BG_KEEP,
BG_CAMERA_FEED,
BG_MAX
};
enum AmbientSource {
AMBIENT_SOURCE_BG,
AMBIENT_SOURCE_DISABLED,
AMBIENT_SOURCE_COLOR,
AMBIENT_SOURCE_SKY,
};
enum ReflectionSource {
REFLECTION_SOURCE_BG,
REFLECTION_SOURCE_DISABLED,
REFLECTION_SOURCE_SKY,
};
enum ToneMapper {
TONE_MAPPER_LINEAR,
TONE_MAPPER_REINHARDT,
TONE_MAPPER_FILMIC,
TONE_MAPPER_ACES
};
enum GlowBlendMode {
GLOW_BLEND_MODE_ADDITIVE,
GLOW_BLEND_MODE_SCREEN,
GLOW_BLEND_MODE_SOFTLIGHT,
GLOW_BLEND_MODE_REPLACE,
GLOW_BLEND_MODE_MIX,
};
enum SSAOBlur {
SSAO_BLUR_DISABLED,
SSAO_BLUR_1x1,
SSAO_BLUR_2x2,
SSAO_BLUR_3x3
};
private:
RID environment;
BGMode bg_mode;
Ref<Sky> bg_sky;
float bg_sky_custom_fov;
Vector3 sky_rotation;
Color bg_color;
float bg_energy;
int bg_canvas_max_layer;
Color ambient_color;
float ambient_energy;
Color ao_color;
float ambient_sky_contribution;
int camera_feed_id;
AmbientSource ambient_source;
ReflectionSource reflection_source;
ToneMapper tone_mapper;
float tonemap_exposure;
float tonemap_white;
bool tonemap_auto_exposure;
float tonemap_auto_exposure_max;
float tonemap_auto_exposure_min;
float tonemap_auto_exposure_speed;
float tonemap_auto_exposure_grey;
bool adjustment_enabled;
float adjustment_contrast;
float adjustment_saturation;
float adjustment_brightness;
Ref<Texture2D> adjustment_color_correction;
bool ssr_enabled;
int ssr_max_steps;
float ssr_fade_in;
float ssr_fade_out;
float ssr_depth_tolerance;
bool ssr_roughness;
bool ssao_enabled;
float ssao_radius;
float ssao_intensity;
float ssao_bias;
float ssao_direct_light_affect;
float ssao_ao_channel_affect;
SSAOBlur ssao_blur;
float ssao_edge_sharpness;
bool glow_enabled;
int glow_levels;
float glow_intensity;
float glow_strength;
float glow_mix;
float glow_bloom;
GlowBlendMode glow_blend_mode;
float glow_hdr_bleed_threshold;
float glow_hdr_bleed_scale;
float glow_hdr_luminance_cap;
bool fog_enabled;
Color fog_color;
Color fog_sun_color;
float fog_sun_amount;
bool fog_depth_enabled;
float fog_depth_begin;
float fog_depth_end;
float fog_depth_curve;
bool fog_transmit_enabled;
float fog_transmit_curve;
bool fog_height_enabled;
float fog_height_min;
float fog_height_max;
float fog_height_curve;
protected:
static void _bind_methods();
virtual void _validate_property(PropertyInfo &property) const;
#ifndef DISABLE_DEPRECATED
// Kept for compatibility from 3.x to 4.0.
bool _set(const StringName &p_name, const Variant &p_value);
#endif
public:
void set_background(BGMode p_bg);
void set_sky(const Ref<Sky> &p_sky);
void set_sky_custom_fov(float p_scale);
void set_sky_rotation(const Vector3 &p_rotation);
void set_bg_color(const Color &p_color);
void set_bg_energy(float p_energy);
void set_canvas_max_layer(int p_max_layer);
void set_ambient_light_color(const Color &p_color);
void set_ambient_light_energy(float p_energy);
void set_ambient_light_sky_contribution(float p_energy);
void set_camera_feed_id(int p_camera_feed_id);
void set_ambient_source(AmbientSource p_source);
AmbientSource get_ambient_source() const;
void set_reflection_source(ReflectionSource p_source);
ReflectionSource get_reflection_source() const;
BGMode get_background() const;
Ref<Sky> get_sky() const;
float get_sky_custom_fov() const;
Vector3 get_sky_rotation() const;
Color get_bg_color() const;
float get_bg_energy() const;
int get_canvas_max_layer() const;
Color get_ambient_light_color() const;
float get_ambient_light_energy() const;
float get_ambient_light_sky_contribution() const;
int get_camera_feed_id(void) const;
void set_tonemapper(ToneMapper p_tone_mapper);
ToneMapper get_tonemapper() const;
void set_tonemap_exposure(float p_exposure);
float get_tonemap_exposure() const;
void set_tonemap_white(float p_white);
float get_tonemap_white() const;
void set_tonemap_auto_exposure(bool p_enabled);
bool get_tonemap_auto_exposure() const;
void set_tonemap_auto_exposure_max(float p_auto_exposure_max);
float get_tonemap_auto_exposure_max() const;
void set_tonemap_auto_exposure_min(float p_auto_exposure_min);
float get_tonemap_auto_exposure_min() const;
void set_tonemap_auto_exposure_speed(float p_auto_exposure_speed);
float get_tonemap_auto_exposure_speed() const;
void set_tonemap_auto_exposure_grey(float p_auto_exposure_grey);
float get_tonemap_auto_exposure_grey() const;
void set_adjustment_enable(bool p_enable);
bool is_adjustment_enabled() const;
void set_adjustment_brightness(float p_brightness);
float get_adjustment_brightness() const;
void set_adjustment_contrast(float p_contrast);
float get_adjustment_contrast() const;
void set_adjustment_saturation(float p_saturation);
float get_adjustment_saturation() const;
void set_adjustment_color_correction(const Ref<Texture2D> &p_ramp);
Ref<Texture2D> get_adjustment_color_correction() const;
void set_ssr_enabled(bool p_enable);
bool is_ssr_enabled() const;
void set_ssr_max_steps(int p_steps);
int get_ssr_max_steps() const;
void set_ssr_fade_in(float p_fade_in);
float get_ssr_fade_in() const;
void set_ssr_fade_out(float p_fade_out);
float get_ssr_fade_out() const;
void set_ssr_depth_tolerance(float p_depth_tolerance);
float get_ssr_depth_tolerance() const;
void set_ssr_rough(bool p_enable);
bool is_ssr_rough() const;
void set_ssao_enabled(bool p_enable);
bool is_ssao_enabled() const;
void set_ssao_radius(float p_radius);
float get_ssao_radius() const;
void set_ssao_intensity(float p_intensity);
float get_ssao_intensity() const;
void set_ssao_bias(float p_bias);
float get_ssao_bias() const;
void set_ssao_direct_light_affect(float p_direct_light_affect);
float get_ssao_direct_light_affect() const;
void set_ssao_ao_channel_affect(float p_ao_channel_affect);
float get_ssao_ao_channel_affect() const;
void set_ao_color(const Color &p_color);
Color get_ao_color() const;
void set_ssao_blur(SSAOBlur p_blur);
SSAOBlur get_ssao_blur() const;
void set_ssao_edge_sharpness(float p_edge_sharpness);
float get_ssao_edge_sharpness() const;
void set_glow_enabled(bool p_enabled);
bool is_glow_enabled() const;
void set_glow_level(int p_level, bool p_enabled);
bool is_glow_level_enabled(int p_level) const;
void set_glow_intensity(float p_intensity);
float get_glow_intensity() const;
void set_glow_strength(float p_strength);
float get_glow_strength() const;
void set_glow_mix(float p_mix);
float get_glow_mix() const;
void set_glow_bloom(float p_threshold);
float get_glow_bloom() const;
void set_glow_blend_mode(GlowBlendMode p_mode);
GlowBlendMode get_glow_blend_mode() const;
void set_glow_hdr_bleed_threshold(float p_threshold);
float get_glow_hdr_bleed_threshold() const;
void set_glow_hdr_luminance_cap(float p_amount);
float get_glow_hdr_luminance_cap() const;
void set_glow_hdr_bleed_scale(float p_scale);
float get_glow_hdr_bleed_scale() const;
void set_fog_enabled(bool p_enabled);
bool is_fog_enabled() const;
void set_fog_color(const Color &p_color);
Color get_fog_color() const;
void set_fog_sun_color(const Color &p_color);
Color get_fog_sun_color() const;
void set_fog_sun_amount(float p_amount);
float get_fog_sun_amount() const;
void set_fog_depth_enabled(bool p_enabled);
bool is_fog_depth_enabled() const;
void set_fog_depth_begin(float p_distance);
float get_fog_depth_begin() const;
void set_fog_depth_end(float p_distance);
float get_fog_depth_end() const;
void set_fog_depth_curve(float p_curve);
float get_fog_depth_curve() const;
void set_fog_transmit_enabled(bool p_enabled);
bool is_fog_transmit_enabled() const;
void set_fog_transmit_curve(float p_curve);
float get_fog_transmit_curve() const;
void set_fog_height_enabled(bool p_enabled);
bool is_fog_height_enabled() const;
void set_fog_height_min(float p_distance);
float get_fog_height_min() const;
void set_fog_height_max(float p_distance);
float get_fog_height_max() const;
void set_fog_height_curve(float p_distance);
float get_fog_height_curve() const;
virtual RID get_rid() const;
Environment();
~Environment();
};
VARIANT_ENUM_CAST(Environment::BGMode)
VARIANT_ENUM_CAST(Environment::AmbientSource)
VARIANT_ENUM_CAST(Environment::ReflectionSource)
VARIANT_ENUM_CAST(Environment::ToneMapper)
VARIANT_ENUM_CAST(Environment::GlowBlendMode)
VARIANT_ENUM_CAST(Environment::SSAOBlur)
class CameraEffects : public Resource {
GDCLASS(CameraEffects, Resource);
private:
RID camera_effects;
bool dof_blur_far_enabled;
float dof_blur_far_distance;
float dof_blur_far_transition;
bool dof_blur_near_enabled;
float dof_blur_near_distance;
float dof_blur_near_transition;
float dof_blur_amount;
bool override_exposure_enabled;
float override_exposure;
protected:
static void _bind_methods();
public:
void set_dof_blur_far_enabled(bool p_enable);
bool is_dof_blur_far_enabled() const;
void set_dof_blur_far_distance(float p_distance);
float get_dof_blur_far_distance() const;
void set_dof_blur_far_transition(float p_distance);
float get_dof_blur_far_transition() const;
void set_dof_blur_near_enabled(bool p_enable);
bool is_dof_blur_near_enabled() const;
void set_dof_blur_near_distance(float p_distance);
float get_dof_blur_near_distance() const;
void set_dof_blur_near_transition(float p_distance);
float get_dof_blur_near_transition() const;
void set_dof_blur_amount(float p_amount);
float get_dof_blur_amount() const;
void set_override_exposure_enabled(bool p_enabled);
bool is_override_exposure_enabled() const;
void set_override_exposure(float p_exposure);
float get_override_exposure() const;
virtual RID get_rid() const;
CameraEffects();
~CameraEffects();
};
#endif // ENVIRONMENT_H
|