renderer_scene_environment_rd.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*************************************************************************/
  2. /* renderer_scene_environment_rd.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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. #ifndef RENDERING_SERVER_SCENE_ENVIRONMENT_RD_H
  31. #define RENDERING_SERVER_SCENE_ENVIRONMENT_RD_H
  32. #include "servers/rendering/renderer_scene_render.h"
  33. #include "servers/rendering/rendering_device.h"
  34. class RendererSceneEnvironmentRD {
  35. private:
  36. static uint64_t auto_exposure_counter;
  37. public:
  38. // BG
  39. RS::EnvironmentBG background = RS::ENV_BG_CLEAR_COLOR;
  40. RID sky;
  41. float sky_custom_fov = 0.0;
  42. Basis sky_orientation;
  43. Color bg_color;
  44. float bg_energy = 1.0;
  45. int canvas_max_layer = 0;
  46. RS::EnvironmentAmbientSource ambient_source = RS::ENV_AMBIENT_SOURCE_BG;
  47. Color ambient_light;
  48. float ambient_light_energy = 1.0;
  49. float ambient_sky_contribution = 1.0;
  50. RS::EnvironmentReflectionSource reflection_source = RS::ENV_REFLECTION_SOURCE_BG;
  51. Color ao_color;
  52. /// Tonemap
  53. RS::EnvironmentToneMapper tone_mapper;
  54. float exposure = 1.0;
  55. float white = 1.0;
  56. bool auto_exposure = false;
  57. float min_luminance = 0.2;
  58. float max_luminance = 8.0;
  59. float auto_exp_speed = 0.2;
  60. float auto_exp_scale = 0.5;
  61. uint64_t auto_exposure_version = 0;
  62. // Fog
  63. bool fog_enabled = false;
  64. Color fog_light_color = Color(0.5, 0.6, 0.7);
  65. float fog_light_energy = 1.0;
  66. float fog_sun_scatter = 0.0;
  67. float fog_density = 0.001;
  68. float fog_height = 0.0;
  69. float fog_height_density = 0.0; //can be negative to invert effect
  70. float fog_aerial_perspective = 0.0;
  71. /// Volumetric Fog
  72. ///
  73. bool volumetric_fog_enabled = false;
  74. float volumetric_fog_density = 0.01;
  75. Color volumetric_fog_light = Color(0, 0, 0);
  76. float volumetric_fog_light_energy = 0.0;
  77. float volumetric_fog_length = 64.0;
  78. float volumetric_fog_detail_spread = 2.0;
  79. float volumetric_fog_gi_inject = 0.0;
  80. bool volumetric_fog_temporal_reprojection = true;
  81. float volumetric_fog_temporal_reprojection_amount = 0.9;
  82. /// Glow
  83. bool glow_enabled = false;
  84. Vector<float> glow_levels;
  85. float glow_intensity = 0.8;
  86. float glow_strength = 1.0;
  87. float glow_bloom = 0.0;
  88. float glow_mix = 0.01;
  89. RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT;
  90. float glow_hdr_bleed_threshold = 1.0;
  91. float glow_hdr_luminance_cap = 12.0;
  92. float glow_hdr_bleed_scale = 2.0;
  93. /// SSAO
  94. bool ssao_enabled = false;
  95. float ssao_radius = 1.0;
  96. float ssao_intensity = 2.0;
  97. float ssao_power = 1.5;
  98. float ssao_detail = 0.5;
  99. float ssao_horizon = 0.06;
  100. float ssao_sharpness = 0.98;
  101. float ssao_direct_light_affect = 0.0;
  102. float ssao_ao_channel_affect = 0.0;
  103. /// SSR
  104. ///
  105. bool ssr_enabled = false;
  106. int ssr_max_steps = 64;
  107. float ssr_fade_in = 0.15;
  108. float ssr_fade_out = 2.0;
  109. float ssr_depth_tolerance = 0.2;
  110. /// SDFGI
  111. bool sdfgi_enabled = false;
  112. RS::EnvironmentSDFGICascades sdfgi_cascades;
  113. float sdfgi_min_cell_size = 0.2;
  114. bool sdfgi_use_occlusion = false;
  115. float sdfgi_bounce_feedback = 0.0;
  116. bool sdfgi_read_sky_light = false;
  117. float sdfgi_energy = 1.0;
  118. float sdfgi_normal_bias = 1.1;
  119. float sdfgi_probe_bias = 1.1;
  120. RS::EnvironmentSDFGIYScale sdfgi_y_scale = RS::ENV_SDFGI_Y_SCALE_DISABLED;
  121. /// Adjustments
  122. bool adjustments_enabled = false;
  123. float adjustments_brightness = 1.0f;
  124. float adjustments_contrast = 1.0f;
  125. float adjustments_saturation = 1.0f;
  126. bool use_1d_color_correction = false;
  127. RID color_correction = RID();
  128. void set_ambient_light(const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color);
  129. void set_tonemap(RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale);
  130. void set_glow(bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap);
  131. void set_sdfgi(bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias);
  132. void set_fog(bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_fog_aerial_perspective);
  133. void set_volumetric_fog(bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount);
  134. void set_ssr(bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance);
  135. void set_ssao(bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect);
  136. };
  137. #endif /* !RENDERING_SERVER_SCENE_ENVIRONMENT_RD_H */