light_storage.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /**************************************************************************/
  2. /* light_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. #ifndef LIGHT_STORAGE_DUMMY_H
  31. #define LIGHT_STORAGE_DUMMY_H
  32. #include "servers/rendering/storage/light_storage.h"
  33. namespace RendererDummy {
  34. class LightStorage : public RendererLightStorage {
  35. private:
  36. static LightStorage *singleton;
  37. /* LIGHTMAP */
  38. struct Lightmap {
  39. // dummy lightmap, no data
  40. };
  41. mutable RID_Owner<Lightmap, true> lightmap_owner;
  42. /* LIGHTMAP INSTANCE */
  43. struct LightmapInstance {
  44. RID lightmap;
  45. };
  46. mutable RID_Owner<LightmapInstance> lightmap_instance_owner;
  47. public:
  48. static LightStorage *get_singleton();
  49. LightStorage();
  50. virtual ~LightStorage();
  51. bool free(RID p_rid);
  52. /* Light API */
  53. virtual RID directional_light_allocate() override { return RID(); }
  54. virtual void directional_light_initialize(RID p_rid) override {}
  55. virtual RID omni_light_allocate() override { return RID(); }
  56. virtual void omni_light_initialize(RID p_rid) override {}
  57. virtual RID spot_light_allocate() override { return RID(); }
  58. virtual void spot_light_initialize(RID p_rid) override {}
  59. virtual void light_free(RID p_rid) override {}
  60. virtual void light_set_color(RID p_light, const Color &p_color) override {}
  61. virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value) override {}
  62. virtual void light_set_shadow(RID p_light, bool p_enabled) override {}
  63. virtual void light_set_projector(RID p_light, RID p_texture) override {}
  64. virtual void light_set_negative(RID p_light, bool p_enable) override {}
  65. virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) override {}
  66. virtual void light_set_distance_fade(RID p_light, bool p_enabled, float p_begin, float p_shadow, float p_length) override {}
  67. virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) override {}
  68. virtual void light_set_shadow_caster_mask(RID p_light, uint32_t p_caster_mask) override {}
  69. virtual uint32_t light_get_shadow_caster_mask(RID p_light) const override { return 0xFFFFFFFF; }
  70. virtual void light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) override {}
  71. virtual void light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) override {}
  72. virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) override {}
  73. virtual void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) override {}
  74. virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) override {}
  75. virtual bool light_directional_get_blend_splits(RID p_light) const override { return false; }
  76. virtual void light_directional_set_sky_mode(RID p_light, RS::LightDirectionalSkyMode p_mode) override {}
  77. virtual RS::LightDirectionalSkyMode light_directional_get_sky_mode(RID p_light) const override { return RS::LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY; }
  78. virtual RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) override { return RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; }
  79. virtual RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) override { return RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; }
  80. virtual bool light_has_shadow(RID p_light) const override { return false; }
  81. virtual bool light_has_projector(RID p_light) const override { return false; }
  82. virtual RS::LightType light_get_type(RID p_light) const override { return RS::LIGHT_OMNI; }
  83. virtual AABB light_get_aabb(RID p_light) const override { return AABB(); }
  84. virtual float light_get_param(RID p_light, RS::LightParam p_param) override { return 0.0; }
  85. virtual Color light_get_color(RID p_light) override { return Color(); }
  86. virtual bool light_get_reverse_cull_face_mode(RID p_light) const override { return false; }
  87. virtual RS::LightBakeMode light_get_bake_mode(RID p_light) override { return RS::LIGHT_BAKE_DISABLED; }
  88. virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) override { return 0; }
  89. virtual uint64_t light_get_version(RID p_light) const override { return 0; }
  90. virtual uint32_t light_get_cull_mask(RID p_light) const override { return 0; }
  91. /* LIGHT INSTANCE API */
  92. RID light_instance_create(RID p_light) override { return RID(); }
  93. void light_instance_free(RID p_light) override {}
  94. void light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) override {}
  95. void light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) override {}
  96. void light_instance_set_shadow_transform(RID p_light_instance, const Projection &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale = 1.0, float p_range_begin = 0, const Vector2 &p_uv_scale = Vector2()) override {}
  97. void light_instance_mark_visible(RID p_light_instance) override {}
  98. virtual bool light_instance_is_shadow_visible_at_position(RID p_light_instance, const Vector3 &p_position) const override { return false; }
  99. /* PROBE API */
  100. virtual RID reflection_probe_allocate() override { return RID(); }
  101. virtual void reflection_probe_initialize(RID p_rid) override {}
  102. virtual void reflection_probe_free(RID p_rid) override {}
  103. virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) override {}
  104. virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) override {}
  105. virtual void reflection_probe_set_ambient_mode(RID p_probe, RS::ReflectionProbeAmbientMode p_mode) override {}
  106. virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) override {}
  107. virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) override {}
  108. virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) override {}
  109. virtual void reflection_probe_set_size(RID p_probe, const Vector3 &p_size) override {}
  110. virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) override {}
  111. virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) override {}
  112. virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) override {}
  113. virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) override {}
  114. virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) override {}
  115. virtual void reflection_probe_set_reflection_mask(RID p_probe, uint32_t p_layers) override {}
  116. virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) override {}
  117. virtual void reflection_probe_set_mesh_lod_threshold(RID p_probe, float p_ratio) override {}
  118. virtual float reflection_probe_get_mesh_lod_threshold(RID p_probe) const override { return 0.0; }
  119. virtual AABB reflection_probe_get_aabb(RID p_probe) const override { return AABB(); }
  120. virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const override { return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; }
  121. virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const override { return 0; }
  122. virtual uint32_t reflection_probe_get_reflection_mask(RID p_probe) const override { return 0; }
  123. virtual Vector3 reflection_probe_get_size(RID p_probe) const override { return Vector3(); }
  124. virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const override { return Vector3(); }
  125. virtual float reflection_probe_get_origin_max_distance(RID p_probe) const override { return 0.0; }
  126. virtual bool reflection_probe_renders_shadows(RID p_probe) const override { return false; }
  127. /* REFLECTION ATLAS */
  128. virtual RID reflection_atlas_create() override { return RID(); }
  129. virtual void reflection_atlas_free(RID p_ref_atlas) override {}
  130. virtual int reflection_atlas_get_size(RID p_ref_atlas) const override { return 0; }
  131. virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) override {}
  132. /* REFLECTION PROBE INSTANCE */
  133. virtual RID reflection_probe_instance_create(RID p_probe) override { return RID(); }
  134. virtual void reflection_probe_instance_free(RID p_instance) override {}
  135. virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) override {}
  136. virtual bool reflection_probe_has_atlas_index(RID p_instance) override { return false; }
  137. virtual void reflection_probe_release_atlas_index(RID p_instance) override {}
  138. virtual bool reflection_probe_instance_needs_redraw(RID p_instance) override { return false; }
  139. virtual bool reflection_probe_instance_has_reflection(RID p_instance) override { return false; }
  140. virtual bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) override { return false; }
  141. virtual Ref<RenderSceneBuffers> reflection_probe_atlas_get_render_buffers(RID p_reflection_atlas) override { return Ref<RenderSceneBuffers>(); }
  142. virtual bool reflection_probe_instance_postprocess_step(RID p_instance) override { return true; }
  143. /* LIGHTMAP CAPTURE */
  144. bool owns_lightmap(RID p_rid) { return lightmap_owner.owns(p_rid); }
  145. virtual RID lightmap_allocate() override;
  146. virtual void lightmap_initialize(RID p_rid) override;
  147. virtual void lightmap_free(RID p_rid) override;
  148. virtual void lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) override {}
  149. virtual void lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) override {}
  150. virtual void lightmap_set_probe_interior(RID p_lightmap, bool p_interior) override {}
  151. virtual void lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) override {}
  152. virtual void lightmap_set_baked_exposure_normalization(RID p_lightmap, float p_exposure) override {}
  153. virtual PackedVector3Array lightmap_get_probe_capture_points(RID p_lightmap) const override { return PackedVector3Array(); }
  154. virtual PackedColorArray lightmap_get_probe_capture_sh(RID p_lightmap) const override { return PackedColorArray(); }
  155. virtual PackedInt32Array lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const override { return PackedInt32Array(); }
  156. virtual PackedInt32Array lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const override { return PackedInt32Array(); }
  157. virtual AABB lightmap_get_aabb(RID p_lightmap) const override { return AABB(); }
  158. virtual void lightmap_tap_sh_light(RID p_lightmap, const Vector3 &p_point, Color *r_sh) override {}
  159. virtual bool lightmap_is_interior(RID p_lightmap) const override { return false; }
  160. virtual void lightmap_set_probe_capture_update_speed(float p_speed) override {}
  161. virtual float lightmap_get_probe_capture_update_speed() const override { return 0; }
  162. /* LIGHTMAP INSTANCE */
  163. bool owns_lightmap_instance(RID p_rid) { return lightmap_instance_owner.owns(p_rid); }
  164. RID lightmap_instance_create(RID p_lightmap) override;
  165. void lightmap_instance_free(RID p_lightmap) override;
  166. void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) override {}
  167. /* SHADOW ATLAS API */
  168. virtual RID shadow_atlas_create() override { return RID(); }
  169. virtual void shadow_atlas_free(RID p_atlas) override {}
  170. virtual void shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits = true) override {}
  171. virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) override {}
  172. virtual bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) override { return false; }
  173. virtual void shadow_atlas_update(RID p_atlas) override {}
  174. virtual void directional_shadow_atlas_set_size(int p_size, bool p_16_bits = true) override {}
  175. virtual int get_directional_light_shadow_size(RID p_light_intance) override { return 0; }
  176. virtual void set_directional_shadow_count(int p_count) override {}
  177. };
  178. } // namespace RendererDummy
  179. #endif // LIGHT_STORAGE_DUMMY_H