visual_server_raster.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. /**************************************************************************/
  2. /* visual_server_raster.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 VISUAL_SERVER_RASTER_H
  31. #define VISUAL_SERVER_RASTER_H
  32. #include "core/math/octree.h"
  33. #include "servers/visual/rasterizer.h"
  34. #include "servers/visual_server.h"
  35. #include "visual_server_canvas.h"
  36. #include "visual_server_globals.h"
  37. #include "visual_server_scene.h"
  38. #include "visual_server_viewport.h"
  39. class VisualServerRaster : public VisualServer {
  40. enum {
  41. MAX_INSTANCE_CULL = 8192,
  42. MAX_INSTANCE_LIGHTS = 4,
  43. LIGHT_CACHE_DIRTY = -1,
  44. MAX_LIGHTS_CULLED = 256,
  45. MAX_ROOM_CULL = 32,
  46. MAX_EXTERIOR_PORTALS = 128,
  47. MAX_LIGHT_SAMPLERS = 256,
  48. INSTANCE_ROOMLESS_MASK = (1 << 20)
  49. };
  50. // low and high priority
  51. static int changes[2];
  52. RID test_cube;
  53. int black_margin[4];
  54. RID black_image[4];
  55. struct FrameDrawnCallbacks {
  56. ObjectID object;
  57. StringName method;
  58. Variant param;
  59. };
  60. List<FrameDrawnCallbacks> frame_drawn_callbacks;
  61. void _draw_margins();
  62. // This function is NOT dead code.
  63. // It is specifically for debugging redraws to help identify problems with
  64. // undesired constant editor updating.
  65. // The function will be called in DEV builds (and thus does not require a recompile),
  66. // allowing you to place a breakpoint either at the first line or the semicolon.
  67. // You can then look at the callstack to find the cause of the redraw.
  68. static void _changes_changed(int p_priority) {
  69. if (p_priority) {
  70. ;
  71. }
  72. }
  73. public:
  74. // if editor is redrawing when it shouldn't, use a DEV build and put a breakpoint in _changes_changed()
  75. _FORCE_INLINE_ static void redraw_request(bool p_high_priority = true) {
  76. int priority = p_high_priority ? 1 : 0;
  77. changes[priority] += 1;
  78. #ifdef DEV_ENABLED
  79. _changes_changed(priority);
  80. #endif
  81. }
  82. #ifdef DEV_ENABLED
  83. #define DISPLAY_CHANGED \
  84. changes[1] += 1; \
  85. _changes_changed(1);
  86. #else
  87. #define DISPLAY_CHANGED \
  88. changes[1] += 1;
  89. #endif
  90. #define BIND0R(m_r, m_name) \
  91. m_r m_name() { return BINDBASE->m_name(); }
  92. #define BIND1R(m_r, m_name, m_type1) \
  93. m_r m_name(m_type1 arg1) { return BINDBASE->m_name(arg1); }
  94. #define BIND1RC(m_r, m_name, m_type1) \
  95. m_r m_name(m_type1 arg1) const { return BINDBASE->m_name(arg1); }
  96. #define BIND2R(m_r, m_name, m_type1, m_type2) \
  97. m_r m_name(m_type1 arg1, m_type2 arg2) { return BINDBASE->m_name(arg1, arg2); }
  98. #define BIND2RC(m_r, m_name, m_type1, m_type2) \
  99. m_r m_name(m_type1 arg1, m_type2 arg2) const { return BINDBASE->m_name(arg1, arg2); }
  100. #define BIND3RC(m_r, m_name, m_type1, m_type2, m_type3) \
  101. m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) const { return BINDBASE->m_name(arg1, arg2, arg3); }
  102. #define BIND4RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \
  103. m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) const { return BINDBASE->m_name(arg1, arg2, arg3, arg4); }
  104. #define BIND0N(m_name) \
  105. void m_name() { BINDBASE->m_name(); }
  106. #define BIND1(m_name, m_type1) \
  107. void m_name(m_type1 arg1) { DISPLAY_CHANGED BINDBASE->m_name(arg1); }
  108. #define BIND1N(m_name, m_type1) \
  109. void m_name(m_type1 arg1) { BINDBASE->m_name(arg1); }
  110. #define BIND2(m_name, m_type1, m_type2) \
  111. void m_name(m_type1 arg1, m_type2 arg2) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2); }
  112. #define BIND2C(m_name, m_type1, m_type2) \
  113. void m_name(m_type1 arg1, m_type2 arg2) const { BINDBASE->m_name(arg1, arg2); }
  114. #define BIND3(m_name, m_type1, m_type2, m_type3) \
  115. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3); }
  116. #define BIND4(m_name, m_type1, m_type2, m_type3, m_type4) \
  117. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4); }
  118. #define BIND5(m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \
  119. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5); }
  120. #define BIND6(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \
  121. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); }
  122. #define BIND7(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7) \
  123. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7); }
  124. #define BIND8(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8) \
  125. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); }
  126. #define BIND9(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9) \
  127. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); }
  128. #define BIND10(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10) \
  129. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); }
  130. #define BIND11(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11) \
  131. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); }
  132. #define BIND12(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12) \
  133. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); }
  134. #define BIND13(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13) \
  135. void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); }
  136. //from now on, calls forwarded to this singleton
  137. #define BINDBASE VSG::storage
  138. /* TEXTURE API */
  139. BIND0R(RID, texture_create)
  140. BIND7(texture_allocate, RID, int, int, int, Image::Format, TextureType, uint32_t)
  141. BIND3(texture_set_data, RID, const Ref<Image> &, int)
  142. BIND10(texture_set_data_partial, RID, const Ref<Image> &, int, int, int, int, int, int, int, int)
  143. BIND2RC(Ref<Image>, texture_get_data, RID, int)
  144. BIND2(texture_set_flags, RID, uint32_t)
  145. BIND1RC(uint32_t, texture_get_flags, RID)
  146. BIND1RC(Image::Format, texture_get_format, RID)
  147. BIND1RC(TextureType, texture_get_type, RID)
  148. BIND1RC(uint32_t, texture_get_texid, RID)
  149. BIND1RC(uint32_t, texture_get_width, RID)
  150. BIND1RC(uint32_t, texture_get_height, RID)
  151. BIND1RC(uint32_t, texture_get_depth, RID)
  152. BIND4(texture_set_size_override, RID, int, int, int)
  153. BIND2(texture_bind, RID, uint32_t)
  154. BIND3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *)
  155. BIND3(texture_set_detect_srgb_callback, RID, TextureDetectCallback, void *)
  156. BIND3(texture_set_detect_normal_callback, RID, TextureDetectCallback, void *)
  157. BIND2(texture_set_path, RID, const String &)
  158. BIND1RC(String, texture_get_path, RID)
  159. BIND1(texture_set_shrink_all_x2_on_set_data, bool)
  160. BIND1(texture_debug_usage, List<TextureInfo> *)
  161. BIND1(textures_keep_original, bool)
  162. BIND2(texture_set_proxy, RID, RID)
  163. BIND2(texture_set_force_redraw_if_visible, RID, bool)
  164. /* SKY API */
  165. BIND0R(RID, sky_create)
  166. BIND3(sky_set_texture, RID, RID, int)
  167. /* SHADER API */
  168. BIND0R(RID, shader_create)
  169. BIND2(shader_set_code, RID, const String &)
  170. BIND1RC(String, shader_get_code, RID)
  171. BIND2C(shader_get_param_list, RID, List<PropertyInfo> *)
  172. BIND3(shader_set_default_texture_param, RID, const StringName &, RID)
  173. BIND2RC(RID, shader_get_default_texture_param, RID, const StringName &)
  174. BIND2(shader_add_custom_define, RID, const String &)
  175. BIND2C(shader_get_custom_defines, RID, Vector<String> *)
  176. BIND2(shader_remove_custom_define, RID, const String &)
  177. BIND1(set_shader_async_hidden_forbidden, bool)
  178. /* COMMON MATERIAL API */
  179. BIND0R(RID, material_create)
  180. BIND2(material_set_shader, RID, RID)
  181. BIND1RC(RID, material_get_shader, RID)
  182. BIND3(material_set_param, RID, const StringName &, const Variant &)
  183. BIND2RC(Variant, material_get_param, RID, const StringName &)
  184. BIND2RC(Variant, material_get_param_default, RID, const StringName &)
  185. BIND2(material_set_render_priority, RID, int)
  186. BIND2(material_set_line_width, RID, float)
  187. BIND2(material_set_next_pass, RID, RID)
  188. /* MESH API */
  189. BIND0R(RID, mesh_create)
  190. BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const AABB &, const Vector<PoolVector<uint8_t>> &, const Vector<AABB> &)
  191. BIND2(mesh_set_blend_shape_count, RID, int)
  192. BIND1RC(int, mesh_get_blend_shape_count, RID)
  193. BIND2(mesh_set_blend_shape_mode, RID, BlendShapeMode)
  194. BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID)
  195. BIND4(mesh_surface_update_region, RID, int, int, const PoolVector<uint8_t> &)
  196. BIND3(mesh_surface_set_material, RID, int, RID)
  197. BIND2RC(RID, mesh_surface_get_material, RID, int)
  198. BIND2RC(int, mesh_surface_get_array_len, RID, int)
  199. BIND2RC(int, mesh_surface_get_array_index_len, RID, int)
  200. BIND2RC(PoolVector<uint8_t>, mesh_surface_get_array, RID, int)
  201. BIND2RC(PoolVector<uint8_t>, mesh_surface_get_index_array, RID, int)
  202. BIND2RC(uint32_t, mesh_surface_get_format, RID, int)
  203. BIND2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int)
  204. BIND2RC(AABB, mesh_surface_get_aabb, RID, int)
  205. BIND2RC(Vector<PoolVector<uint8_t>>, mesh_surface_get_blend_shapes, RID, int)
  206. BIND2RC(Vector<AABB>, mesh_surface_get_skeleton_aabb, RID, int)
  207. BIND2(mesh_remove_surface, RID, int)
  208. BIND1RC(int, mesh_get_surface_count, RID)
  209. BIND2(mesh_set_custom_aabb, RID, const AABB &)
  210. BIND1RC(AABB, mesh_get_custom_aabb, RID)
  211. BIND1(mesh_clear, RID)
  212. /* MULTIMESH API */
  213. BIND0R(RID, multimesh_create)
  214. BIND5(multimesh_allocate, RID, int, MultimeshTransformFormat, MultimeshColorFormat, MultimeshCustomDataFormat)
  215. BIND1RC(int, multimesh_get_instance_count, RID)
  216. BIND2(multimesh_set_mesh, RID, RID)
  217. BIND3(multimesh_instance_set_transform, RID, int, const Transform &)
  218. BIND3(multimesh_instance_set_transform_2d, RID, int, const Transform2D &)
  219. BIND3(multimesh_instance_set_color, RID, int, const Color &)
  220. BIND3(multimesh_instance_set_custom_data, RID, int, const Color &)
  221. BIND1RC(RID, multimesh_get_mesh, RID)
  222. BIND1RC(AABB, multimesh_get_aabb, RID)
  223. BIND2RC(Transform, multimesh_instance_get_transform, RID, int)
  224. BIND2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int)
  225. BIND2RC(Color, multimesh_instance_get_color, RID, int)
  226. BIND2RC(Color, multimesh_instance_get_custom_data, RID, int)
  227. BIND2(multimesh_set_as_bulk_array, RID, const PoolVector<float> &)
  228. BIND3(multimesh_set_as_bulk_array_interpolated, RID, const PoolVector<float> &, const PoolVector<float> &)
  229. BIND2(multimesh_set_physics_interpolated, RID, bool)
  230. BIND2(multimesh_set_physics_interpolation_quality, RID, int)
  231. BIND2(multimesh_instance_reset_physics_interpolation, RID, int)
  232. BIND2(multimesh_set_visible_instances, RID, int)
  233. BIND1RC(int, multimesh_get_visible_instances, RID)
  234. /* IMMEDIATE API */
  235. BIND0R(RID, immediate_create)
  236. BIND3(immediate_begin, RID, PrimitiveType, RID)
  237. BIND2(immediate_vertex, RID, const Vector3 &)
  238. BIND2(immediate_normal, RID, const Vector3 &)
  239. BIND2(immediate_tangent, RID, const Plane &)
  240. BIND2(immediate_color, RID, const Color &)
  241. BIND2(immediate_uv, RID, const Vector2 &)
  242. BIND2(immediate_uv2, RID, const Vector2 &)
  243. BIND1(immediate_end, RID)
  244. BIND1(immediate_clear, RID)
  245. BIND2(immediate_set_material, RID, RID)
  246. BIND1RC(RID, immediate_get_material, RID)
  247. /* SKELETON API */
  248. BIND0R(RID, skeleton_create)
  249. BIND3(skeleton_allocate, RID, int, bool)
  250. BIND1RC(int, skeleton_get_bone_count, RID)
  251. BIND3(skeleton_bone_set_transform, RID, int, const Transform &)
  252. BIND2RC(Transform, skeleton_bone_get_transform, RID, int)
  253. BIND3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &)
  254. BIND2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int)
  255. BIND2(skeleton_set_base_transform_2d, RID, const Transform2D &)
  256. /* Light API */
  257. BIND0R(RID, directional_light_create)
  258. BIND0R(RID, omni_light_create)
  259. BIND0R(RID, spot_light_create)
  260. BIND2(light_set_color, RID, const Color &)
  261. BIND3(light_set_param, RID, LightParam, float)
  262. BIND2(light_set_shadow, RID, bool)
  263. BIND2(light_set_shadow_color, RID, const Color &)
  264. BIND2(light_set_projector, RID, RID)
  265. BIND2(light_set_negative, RID, bool)
  266. BIND2(light_set_cull_mask, RID, uint32_t)
  267. BIND2(light_set_reverse_cull_face_mode, RID, bool)
  268. BIND2(light_set_use_gi, RID, bool)
  269. BIND2(light_set_bake_mode, RID, LightBakeMode)
  270. BIND2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
  271. BIND2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail)
  272. BIND2(light_directional_set_shadow_mode, RID, LightDirectionalShadowMode)
  273. BIND2(light_directional_set_blend_splits, RID, bool)
  274. BIND2(light_directional_set_shadow_depth_range_mode, RID, LightDirectionalShadowDepthRangeMode)
  275. /* PROBE API */
  276. BIND0R(RID, reflection_probe_create)
  277. BIND2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode)
  278. BIND2(reflection_probe_set_intensity, RID, float)
  279. BIND2(reflection_probe_set_interior_ambient, RID, const Color &)
  280. BIND2(reflection_probe_set_interior_ambient_energy, RID, float)
  281. BIND2(reflection_probe_set_interior_ambient_probe_contribution, RID, float)
  282. BIND2(reflection_probe_set_max_distance, RID, float)
  283. BIND2(reflection_probe_set_extents, RID, const Vector3 &)
  284. BIND2(reflection_probe_set_origin_offset, RID, const Vector3 &)
  285. BIND2(reflection_probe_set_as_interior, RID, bool)
  286. BIND2(reflection_probe_set_enable_box_projection, RID, bool)
  287. BIND2(reflection_probe_set_enable_shadows, RID, bool)
  288. BIND2(reflection_probe_set_cull_mask, RID, uint32_t)
  289. BIND2(reflection_probe_set_resolution, RID, int)
  290. /* BAKED LIGHT API */
  291. BIND0R(RID, gi_probe_create)
  292. BIND2(gi_probe_set_bounds, RID, const AABB &)
  293. BIND1RC(AABB, gi_probe_get_bounds, RID)
  294. BIND2(gi_probe_set_cell_size, RID, float)
  295. BIND1RC(float, gi_probe_get_cell_size, RID)
  296. BIND2(gi_probe_set_to_cell_xform, RID, const Transform &)
  297. BIND1RC(Transform, gi_probe_get_to_cell_xform, RID)
  298. BIND2(gi_probe_set_dynamic_range, RID, int)
  299. BIND1RC(int, gi_probe_get_dynamic_range, RID)
  300. BIND2(gi_probe_set_energy, RID, float)
  301. BIND1RC(float, gi_probe_get_energy, RID)
  302. BIND2(gi_probe_set_bias, RID, float)
  303. BIND1RC(float, gi_probe_get_bias, RID)
  304. BIND2(gi_probe_set_normal_bias, RID, float)
  305. BIND1RC(float, gi_probe_get_normal_bias, RID)
  306. BIND2(gi_probe_set_propagation, RID, float)
  307. BIND1RC(float, gi_probe_get_propagation, RID)
  308. BIND2(gi_probe_set_interior, RID, bool)
  309. BIND1RC(bool, gi_probe_is_interior, RID)
  310. BIND2(gi_probe_set_compress, RID, bool)
  311. BIND1RC(bool, gi_probe_is_compressed, RID)
  312. BIND2(gi_probe_set_dynamic_data, RID, const PoolVector<int> &)
  313. BIND1RC(PoolVector<int>, gi_probe_get_dynamic_data, RID)
  314. /* LIGHTMAP CAPTURE */
  315. BIND0R(RID, lightmap_capture_create)
  316. BIND2(lightmap_capture_set_bounds, RID, const AABB &)
  317. BIND1RC(AABB, lightmap_capture_get_bounds, RID)
  318. BIND2(lightmap_capture_set_octree, RID, const PoolVector<uint8_t> &)
  319. BIND1RC(PoolVector<uint8_t>, lightmap_capture_get_octree, RID)
  320. BIND2(lightmap_capture_set_octree_cell_transform, RID, const Transform &)
  321. BIND1RC(Transform, lightmap_capture_get_octree_cell_transform, RID)
  322. BIND2(lightmap_capture_set_octree_cell_subdiv, RID, int)
  323. BIND1RC(int, lightmap_capture_get_octree_cell_subdiv, RID)
  324. BIND2(lightmap_capture_set_energy, RID, float)
  325. BIND1RC(float, lightmap_capture_get_energy, RID)
  326. BIND2(lightmap_capture_set_interior, RID, bool)
  327. BIND1RC(bool, lightmap_capture_is_interior, RID)
  328. /* PARTICLES */
  329. BIND0R(RID, particles_create)
  330. BIND2(particles_set_emitting, RID, bool)
  331. BIND1R(bool, particles_get_emitting, RID)
  332. BIND2(particles_set_amount, RID, int)
  333. BIND2(particles_set_lifetime, RID, float)
  334. BIND2(particles_set_one_shot, RID, bool)
  335. BIND2(particles_set_pre_process_time, RID, float)
  336. BIND2(particles_set_explosiveness_ratio, RID, float)
  337. BIND2(particles_set_randomness_ratio, RID, float)
  338. BIND2(particles_set_custom_aabb, RID, const AABB &)
  339. BIND2(particles_set_speed_scale, RID, float)
  340. BIND2(particles_set_use_local_coordinates, RID, bool)
  341. BIND2(particles_set_process_material, RID, RID)
  342. BIND2(particles_set_fixed_fps, RID, int)
  343. BIND2(particles_set_fractional_delta, RID, bool)
  344. BIND1R(bool, particles_is_inactive, RID)
  345. BIND1(particles_request_process, RID)
  346. BIND1(particles_restart, RID)
  347. BIND2(particles_set_draw_order, RID, VS::ParticlesDrawOrder)
  348. BIND2(particles_set_draw_passes, RID, int)
  349. BIND3(particles_set_draw_pass_mesh, RID, int, RID)
  350. BIND1R(AABB, particles_get_current_aabb, RID)
  351. BIND2(particles_set_emission_transform, RID, const Transform &)
  352. #undef BINDBASE
  353. //from now on, calls forwarded to this singleton
  354. #define BINDBASE VSG::scene
  355. /* EVENT QUEUING */
  356. BIND0N(tick)
  357. BIND1N(pre_draw, bool)
  358. /* CAMERA API */
  359. BIND0R(RID, camera_create)
  360. BIND4(camera_set_perspective, RID, float, float, float)
  361. BIND4(camera_set_orthogonal, RID, float, float, float)
  362. BIND5(camera_set_frustum, RID, float, Vector2, float, float)
  363. BIND2(camera_set_transform, RID, const Transform &)
  364. BIND2(camera_set_interpolated, RID, bool)
  365. BIND1(camera_reset_physics_interpolation, RID)
  366. BIND2(camera_set_cull_mask, RID, uint32_t)
  367. BIND2(camera_set_environment, RID, RID)
  368. BIND2(camera_set_use_vertical_aspect, RID, bool)
  369. #undef BINDBASE
  370. //from now on, calls forwarded to this singleton
  371. #define BINDBASE VSG::viewport
  372. /* VIEWPORT TARGET API */
  373. BIND0R(RID, viewport_create)
  374. BIND2(viewport_set_use_arvr, RID, bool)
  375. BIND3(viewport_set_size, RID, int, int)
  376. BIND2(viewport_set_active, RID, bool)
  377. BIND2(viewport_set_parent_viewport, RID, RID)
  378. BIND2(viewport_set_clear_mode, RID, ViewportClearMode)
  379. BIND3(viewport_attach_to_screen, RID, const Rect2 &, int)
  380. BIND2(viewport_set_render_direct_to_screen, RID, bool)
  381. BIND1(viewport_detach, RID)
  382. BIND2(viewport_set_update_mode, RID, ViewportUpdateMode)
  383. BIND2(viewport_set_vflip, RID, bool)
  384. BIND1RC(RID, viewport_get_texture, RID)
  385. BIND2(viewport_set_hide_scenario, RID, bool)
  386. BIND2(viewport_set_hide_canvas, RID, bool)
  387. BIND2(viewport_set_disable_environment, RID, bool)
  388. BIND2(viewport_set_disable_3d, RID, bool)
  389. BIND2(viewport_set_keep_3d_linear, RID, bool)
  390. BIND2(viewport_attach_camera, RID, RID)
  391. BIND2(viewport_set_scenario, RID, RID)
  392. BIND2(viewport_attach_canvas, RID, RID)
  393. BIND2(viewport_remove_canvas, RID, RID)
  394. BIND3(viewport_set_canvas_transform, RID, RID, const Transform2D &)
  395. BIND2(viewport_set_transparent_background, RID, bool)
  396. BIND2(viewport_set_global_canvas_transform, RID, const Transform2D &)
  397. BIND4(viewport_set_canvas_stacking, RID, RID, int, int)
  398. BIND2(viewport_set_shadow_atlas_size, RID, int)
  399. BIND3(viewport_set_shadow_atlas_quadrant_subdivision, RID, int, int)
  400. BIND2(viewport_set_msaa, RID, ViewportMSAA)
  401. BIND2(viewport_set_use_fxaa, RID, bool)
  402. BIND2(viewport_set_use_debanding, RID, bool)
  403. BIND2(viewport_set_sharpen_intensity, RID, float)
  404. BIND2(viewport_set_hdr, RID, bool)
  405. BIND2(viewport_set_use_32_bpc_depth, RID, bool)
  406. BIND2(viewport_set_usage, RID, ViewportUsage)
  407. BIND2R(int, viewport_get_render_info, RID, ViewportRenderInfo)
  408. BIND2(viewport_set_debug_draw, RID, ViewportDebugDraw)
  409. /* ENVIRONMENT API */
  410. #undef BINDBASE
  411. //from now on, calls forwarded to this singleton
  412. #define BINDBASE VSG::scene_render
  413. BIND0R(RID, environment_create)
  414. BIND2(environment_set_background, RID, EnvironmentBG)
  415. BIND2(environment_set_sky, RID, RID)
  416. BIND2(environment_set_sky_custom_fov, RID, float)
  417. BIND2(environment_set_sky_orientation, RID, const Basis &)
  418. BIND2(environment_set_bg_color, RID, const Color &)
  419. BIND2(environment_set_bg_energy, RID, float)
  420. BIND2(environment_set_canvas_max_layer, RID, int)
  421. BIND4(environment_set_ambient_light, RID, const Color &, float, float)
  422. BIND2(environment_set_camera_feed_id, RID, int)
  423. BIND7(environment_set_ssr, RID, bool, int, float, float, float, bool)
  424. BIND13(environment_set_ssao, RID, bool, float, float, float, float, float, float, float, const Color &, EnvironmentSSAOQuality, EnvironmentSSAOBlur, float)
  425. BIND6(environment_set_dof_blur_near, RID, bool, float, float, float, EnvironmentDOFBlurQuality)
  426. BIND6(environment_set_dof_blur_far, RID, bool, float, float, float, EnvironmentDOFBlurQuality)
  427. BIND12(environment_set_glow, RID, bool, int, float, float, float, EnvironmentGlowBlendMode, float, float, float, bool, bool)
  428. BIND9(environment_set_tonemap, RID, EnvironmentToneMapper, float, float, bool, float, float, float, float)
  429. BIND6(environment_set_adjustment, RID, bool, float, float, float, RID)
  430. BIND5(environment_set_fog, RID, bool, const Color &, const Color &, float)
  431. BIND7(environment_set_fog_depth, RID, bool, float, float, float, bool, float)
  432. BIND5(environment_set_fog_height, RID, bool, float, float, float)
  433. #undef BINDBASE
  434. #define BINDBASE VSG::scene
  435. /* INTERPOLATION */
  436. BIND1(set_physics_interpolation_enabled, bool)
  437. /* SCENARIO API */
  438. BIND0R(RID, scenario_create)
  439. BIND2(scenario_set_debug, RID, ScenarioDebugMode)
  440. BIND2(scenario_set_environment, RID, RID)
  441. BIND3(scenario_set_reflection_atlas_size, RID, int, int)
  442. BIND2(scenario_set_fallback_environment, RID, RID)
  443. /* INSTANCING API */
  444. BIND0R(RID, instance_create)
  445. BIND2(instance_set_base, RID, RID)
  446. BIND2(instance_set_scenario, RID, RID)
  447. BIND2(instance_set_layer_mask, RID, uint32_t)
  448. BIND3(instance_set_pivot_data, RID, float, bool)
  449. BIND2(instance_set_transform, RID, const Transform &)
  450. BIND2(instance_set_interpolated, RID, bool)
  451. BIND1(instance_reset_physics_interpolation, RID)
  452. BIND2(instance_attach_object_instance_id, RID, ObjectID)
  453. BIND3(instance_set_blend_shape_weight, RID, int, float)
  454. BIND3(instance_set_surface_material, RID, int, RID)
  455. BIND2(instance_set_visible, RID, bool)
  456. BIND5(instance_set_use_lightmap, RID, RID, RID, int, const Rect2 &)
  457. BIND2(instance_set_custom_aabb, RID, AABB)
  458. BIND2(instance_attach_skeleton, RID, RID)
  459. BIND2(instance_set_exterior, RID, bool)
  460. BIND2(instance_set_extra_visibility_margin, RID, real_t)
  461. /* PORTALS */
  462. BIND2(instance_set_portal_mode, RID, InstancePortalMode)
  463. BIND0R(RID, ghost_create)
  464. BIND4(ghost_set_scenario, RID, RID, ObjectID, const AABB &)
  465. BIND2(ghost_update, RID, const AABB &)
  466. BIND0R(RID, portal_create)
  467. BIND2(portal_set_scenario, RID, RID)
  468. BIND3(portal_set_geometry, RID, const Vector<Vector3> &, real_t)
  469. BIND4(portal_link, RID, RID, RID, bool)
  470. BIND2(portal_set_active, RID, bool)
  471. /* ROOMGROUPS */
  472. BIND0R(RID, roomgroup_create)
  473. BIND2(roomgroup_prepare, RID, ObjectID)
  474. BIND2(roomgroup_set_scenario, RID, RID)
  475. BIND2(roomgroup_add_room, RID, RID)
  476. /* OCCLUDERS */
  477. BIND0R(RID, occluder_instance_create)
  478. BIND2(occluder_instance_set_scenario, RID, RID)
  479. BIND2(occluder_instance_link_resource, RID, RID)
  480. BIND2(occluder_instance_set_transform, RID, const Transform &)
  481. BIND2(occluder_instance_set_active, RID, bool)
  482. BIND0R(RID, occluder_resource_create)
  483. BIND2(occluder_resource_prepare, RID, OccluderType)
  484. BIND2(occluder_resource_spheres_update, RID, const Vector<Plane> &)
  485. BIND2(occluder_resource_mesh_update, RID, const Geometry::OccluderMeshData &)
  486. BIND1(set_use_occlusion_culling, bool)
  487. BIND1RC(Geometry::MeshData, occlusion_debug_get_current_polys, RID)
  488. /* ROOMS */
  489. BIND0R(RID, room_create)
  490. BIND2(room_set_scenario, RID, RID)
  491. BIND4(room_add_instance, RID, RID, const AABB &, const Vector<Vector3> &)
  492. BIND3(room_add_ghost, RID, ObjectID, const AABB &)
  493. BIND5(room_set_bound, RID, ObjectID, const Vector<Plane> &, const AABB &, const Vector<Vector3> &)
  494. BIND2(room_prepare, RID, int32_t)
  495. BIND1(rooms_and_portals_clear, RID)
  496. BIND2(rooms_unload, RID, String)
  497. BIND8(rooms_finalize, RID, bool, bool, bool, bool, String, bool, bool)
  498. BIND4(rooms_override_camera, RID, bool, const Vector3 &, const Vector<Plane> *)
  499. BIND2(rooms_set_active, RID, bool)
  500. BIND3(rooms_set_params, RID, int, real_t)
  501. BIND3(rooms_set_debug_feature, RID, RoomsDebugFeature, bool)
  502. BIND2(rooms_update_gameplay_monitor, RID, const Vector<Vector3> &)
  503. // don't use this in a game
  504. BIND1RC(bool, rooms_is_loaded, RID)
  505. // Callbacks
  506. BIND1(callbacks_register, VisualServerCallbacks *)
  507. // don't use these in a game!
  508. BIND2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID)
  509. BIND3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID)
  510. BIND2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID)
  511. BIND3(instance_geometry_set_flag, RID, InstanceFlags, bool)
  512. BIND2(instance_geometry_set_cast_shadows_setting, RID, ShadowCastingSetting)
  513. BIND2(instance_geometry_set_material_override, RID, RID)
  514. BIND2(instance_geometry_set_material_overlay, RID, RID)
  515. BIND5(instance_geometry_set_draw_range, RID, float, float, float, float)
  516. BIND2(instance_geometry_set_as_instance_lod, RID, RID)
  517. #undef BINDBASE
  518. //from now on, calls forwarded to this singleton
  519. #define BINDBASE VSG::canvas
  520. /* CANVAS (2D) */
  521. BIND0R(RID, canvas_create)
  522. BIND3(canvas_set_item_mirroring, RID, RID, const Point2 &)
  523. BIND2(canvas_set_modulate, RID, const Color &)
  524. BIND3(canvas_set_parent, RID, RID, float)
  525. BIND1(canvas_set_disable_scale, bool)
  526. BIND0R(RID, canvas_item_create)
  527. BIND2(canvas_item_set_parent, RID, RID)
  528. BIND2(canvas_item_set_visible, RID, bool)
  529. BIND2(canvas_item_set_light_mask, RID, int)
  530. BIND2(canvas_item_set_update_when_visible, RID, bool)
  531. BIND2(canvas_item_set_transform, RID, const Transform2D &)
  532. BIND2(canvas_item_set_clip, RID, bool)
  533. BIND2(canvas_item_set_distance_field_mode, RID, bool)
  534. BIND3(canvas_item_set_custom_rect, RID, bool, const Rect2 &)
  535. BIND2(canvas_item_set_modulate, RID, const Color &)
  536. BIND2(canvas_item_set_self_modulate, RID, const Color &)
  537. BIND2(canvas_item_set_draw_behind_parent, RID, bool)
  538. BIND6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
  539. BIND5(canvas_item_add_polyline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
  540. BIND5(canvas_item_add_multiline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
  541. BIND3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
  542. BIND4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
  543. BIND7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
  544. BIND8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
  545. BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
  546. BIND7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
  547. BIND7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
  548. BIND12(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, bool, bool)
  549. BIND6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
  550. BIND4(canvas_item_add_multimesh, RID, RID, RID, RID)
  551. BIND4(canvas_item_add_particles, RID, RID, RID, RID)
  552. BIND2(canvas_item_add_set_transform, RID, const Transform2D &)
  553. BIND2(canvas_item_add_clip_ignore, RID, bool)
  554. BIND2(canvas_item_set_sort_children_by_y, RID, bool)
  555. BIND2(canvas_item_set_z_index, RID, int)
  556. BIND2(canvas_item_set_z_as_relative_to_parent, RID, bool)
  557. BIND3(canvas_item_set_copy_to_backbuffer, RID, bool, const Rect2 &)
  558. BIND2(canvas_item_attach_skeleton, RID, RID)
  559. BIND1(canvas_item_clear, RID)
  560. BIND2(canvas_item_set_draw_index, RID, int)
  561. BIND2(canvas_item_set_material, RID, RID)
  562. BIND2(canvas_item_set_use_parent_material, RID, bool)
  563. BIND0R(RID, canvas_light_create)
  564. BIND2(canvas_light_attach_to_canvas, RID, RID)
  565. BIND2(canvas_light_set_enabled, RID, bool)
  566. BIND2(canvas_light_set_scale, RID, float)
  567. BIND2(canvas_light_set_transform, RID, const Transform2D &)
  568. BIND2(canvas_light_set_texture, RID, RID)
  569. BIND2(canvas_light_set_texture_offset, RID, const Vector2 &)
  570. BIND2(canvas_light_set_color, RID, const Color &)
  571. BIND2(canvas_light_set_height, RID, float)
  572. BIND2(canvas_light_set_energy, RID, float)
  573. BIND3(canvas_light_set_z_range, RID, int, int)
  574. BIND3(canvas_light_set_layer_range, RID, int, int)
  575. BIND2(canvas_light_set_item_cull_mask, RID, int)
  576. BIND2(canvas_light_set_item_shadow_cull_mask, RID, int)
  577. BIND2(canvas_light_set_mode, RID, CanvasLightMode)
  578. BIND2(canvas_light_set_shadow_enabled, RID, bool)
  579. BIND2(canvas_light_set_shadow_buffer_size, RID, int)
  580. BIND2(canvas_light_set_shadow_gradient_length, RID, float)
  581. BIND2(canvas_light_set_shadow_filter, RID, CanvasLightShadowFilter)
  582. BIND2(canvas_light_set_shadow_color, RID, const Color &)
  583. BIND2(canvas_light_set_shadow_smooth, RID, float)
  584. BIND0R(RID, canvas_light_occluder_create)
  585. BIND2(canvas_light_occluder_attach_to_canvas, RID, RID)
  586. BIND2(canvas_light_occluder_set_enabled, RID, bool)
  587. BIND2(canvas_light_occluder_set_polygon, RID, RID)
  588. BIND2(canvas_light_occluder_set_transform, RID, const Transform2D &)
  589. BIND2(canvas_light_occluder_set_light_mask, RID, int)
  590. BIND0R(RID, canvas_occluder_polygon_create)
  591. BIND3(canvas_occluder_polygon_set_shape, RID, const PoolVector<Vector2> &, bool)
  592. BIND2(canvas_occluder_polygon_set_shape_as_lines, RID, const PoolVector<Vector2> &)
  593. BIND2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode)
  594. /* BLACK BARS */
  595. virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom);
  596. virtual void black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom);
  597. /* FREE */
  598. virtual void free(RID p_rid); ///< free RIDs associated with the visual server
  599. /* EVENT QUEUING */
  600. virtual void request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata);
  601. virtual void draw(bool p_swap_buffers, double frame_step);
  602. virtual void sync();
  603. virtual bool has_changed(ChangedPriority p_priority = CHANGED_PRIORITY_ANY) const;
  604. virtual void init();
  605. virtual void finish();
  606. /* STATUS INFORMATION */
  607. virtual uint64_t get_render_info(RenderInfo p_info);
  608. virtual String get_video_adapter_name() const;
  609. virtual String get_video_adapter_vendor() const;
  610. virtual RID get_test_cube();
  611. /* TESTING */
  612. virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true);
  613. virtual void set_default_clear_color(const Color &p_color);
  614. virtual void set_shader_time_scale(float p_scale);
  615. virtual bool has_feature(Features p_feature) const;
  616. virtual bool has_os_feature(const String &p_feature) const;
  617. virtual void set_debug_generate_wireframes(bool p_generate);
  618. virtual void call_set_use_vsync(bool p_enable);
  619. virtual bool is_low_end() const;
  620. VisualServerRaster();
  621. ~VisualServerRaster();
  622. #undef DISPLAY_CHANGED
  623. #undef BIND0R
  624. #undef BIND1RC
  625. #undef BIND2RC
  626. #undef BIND3RC
  627. #undef BIND4RC
  628. #undef BIND1
  629. #undef BIND2
  630. #undef BIND3
  631. #undef BIND4
  632. #undef BIND5
  633. #undef BIND6
  634. #undef BIND7
  635. #undef BIND8
  636. #undef BIND9
  637. #undef BIND10
  638. };
  639. #endif // VISUAL_SERVER_RASTER_H