renderer_scene_environment_rd.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. /// Tonemap
  52. RS::EnvironmentToneMapper tone_mapper;
  53. float exposure = 1.0;
  54. float white = 1.0;
  55. bool auto_exposure = false;
  56. float min_luminance = 0.2;
  57. float max_luminance = 8.0;
  58. float auto_exp_speed = 0.2;
  59. float auto_exp_scale = 0.5;
  60. uint64_t auto_exposure_version = 0;
  61. // Fog
  62. bool fog_enabled = false;
  63. Color fog_light_color = Color(0.5, 0.6, 0.7);
  64. float fog_light_energy = 1.0;
  65. float fog_sun_scatter = 0.0;
  66. float fog_density = 0.001;
  67. float fog_height = 0.0;
  68. float fog_height_density = 0.0; //can be negative to invert effect
  69. float fog_aerial_perspective = 0.0;
  70. /// Volumetric Fog
  71. ///
  72. bool volumetric_fog_enabled = false;
  73. float volumetric_fog_density = 0.01;
  74. Color volumetric_fog_scattering = Color(1, 1, 1);
  75. Color volumetric_fog_emission = Color(0, 0, 0);
  76. float volumetric_fog_emission_energy = 0.0;
  77. float volumetric_fog_anisotropy = 0.2;
  78. float volumetric_fog_length = 64.0;
  79. float volumetric_fog_detail_spread = 2.0;
  80. float volumetric_fog_gi_inject = 0.0;
  81. bool volumetric_fog_temporal_reprojection = true;
  82. float volumetric_fog_temporal_reprojection_amount = 0.9;
  83. float volumetric_fog_ambient_inject = 0.0;
  84. /// Glow
  85. bool glow_enabled = false;
  86. Vector<float> glow_levels;
  87. float glow_intensity = 0.8;
  88. float glow_strength = 1.0;
  89. float glow_bloom = 0.0;
  90. float glow_mix = 0.01;
  91. RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT;
  92. float glow_hdr_bleed_threshold = 1.0;
  93. float glow_hdr_luminance_cap = 12.0;
  94. float glow_hdr_bleed_scale = 2.0;
  95. /// SSAO
  96. bool ssao_enabled = false;
  97. float ssao_radius = 1.0;
  98. float ssao_intensity = 2.0;
  99. float ssao_power = 1.5;
  100. float ssao_detail = 0.5;
  101. float ssao_horizon = 0.06;
  102. float ssao_sharpness = 0.98;
  103. float ssao_direct_light_affect = 0.0;
  104. float ssao_ao_channel_affect = 0.0;
  105. /// SSR
  106. ///
  107. bool ssr_enabled = false;
  108. int ssr_max_steps = 64;
  109. float ssr_fade_in = 0.15;
  110. float ssr_fade_out = 2.0;
  111. float ssr_depth_tolerance = 0.2;
  112. /// SDFGI
  113. bool sdfgi_enabled = false;
  114. RS::EnvironmentSDFGICascades sdfgi_cascades;
  115. float sdfgi_min_cell_size = 0.2;
  116. bool sdfgi_use_occlusion = false;
  117. float sdfgi_bounce_feedback = 0.0;
  118. bool sdfgi_read_sky_light = false;
  119. float sdfgi_energy = 1.0;
  120. float sdfgi_normal_bias = 1.1;
  121. float sdfgi_probe_bias = 1.1;
  122. RS::EnvironmentSDFGIYScale sdfgi_y_scale = RS::ENV_SDFGI_Y_SCALE_DISABLED;
  123. /// Adjustments
  124. bool adjustments_enabled = false;
  125. float adjustments_brightness = 1.0f;
  126. float adjustments_contrast = 1.0f;
  127. float adjustments_saturation = 1.0f;
  128. bool use_1d_color_correction = false;
  129. RID color_correction = RID();
  130. void set_ambient_light(const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source);
  131. 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);
  132. 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);
  133. 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);
  134. 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);
  135. void set_volumetric_fog(bool p_enable, float p_density, const Color &p_scatterin, const Color &p_emission, float p_emission_energy, float p_anisotropy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount, float p_ambient_inject);
  136. void set_ssr(bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance);
  137. 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);
  138. };
  139. #endif /* !RENDERING_SERVER_SCENE_ENVIRONMENT_RD_H */