visual_server.h 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. /**************************************************************************/
  2. /* visual_server.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_H
  31. #define VISUAL_SERVER_H
  32. #include "core/image.h"
  33. #include "core/math/bsp_tree.h"
  34. #include "core/math/geometry.h"
  35. #include "core/math/transform_2d.h"
  36. #include "core/object.h"
  37. #include "core/rid.h"
  38. #include "core/variant.h"
  39. class VisualServerCallbacks;
  40. class VisualServer : public Object {
  41. GDCLASS(VisualServer, Object);
  42. static VisualServer *singleton;
  43. int mm_policy;
  44. bool render_loop_enabled = true;
  45. #ifdef DEBUG_ENABLED
  46. bool force_shader_fallbacks = false;
  47. #endif
  48. void _camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far);
  49. void _canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate = Color(1, 1, 1));
  50. Array _get_array_from_surface(uint32_t p_format, PoolVector<uint8_t> p_vertex_data, int p_vertex_len, PoolVector<uint8_t> p_index_data, int p_index_len) const;
  51. protected:
  52. RID _make_test_cube();
  53. void _free_internal_rids();
  54. RID test_texture;
  55. RID white_texture;
  56. RID test_material;
  57. Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t *p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb);
  58. static VisualServer *(*create_func)();
  59. static void _bind_methods();
  60. public:
  61. static VisualServer *get_singleton();
  62. static VisualServer *create();
  63. static Vector2 norm_to_oct(const Vector3 v);
  64. static Vector2 tangent_to_oct(const Vector3 v, const float sign, const bool high_precision);
  65. static Vector3 oct_to_norm(const Vector2 v);
  66. static Vector3 oct_to_tangent(const Vector2 v, float *out_sign);
  67. enum {
  68. NO_INDEX_ARRAY = -1,
  69. ARRAY_WEIGHTS_SIZE = 4,
  70. CANVAS_ITEM_Z_MIN = -4096,
  71. CANVAS_ITEM_Z_MAX = 4096,
  72. MAX_GLOW_LEVELS = 7,
  73. MAX_CURSORS = 8,
  74. };
  75. /* TEXTURE API */
  76. enum TextureFlags : unsigned int { // unsigned to stop sanitizer complaining about bit operations on ints
  77. TEXTURE_FLAG_MIPMAPS = 1, /// Enable automatic mipmap generation - when available
  78. TEXTURE_FLAG_REPEAT = 2, /// Repeat texture (Tiling), otherwise Clamping
  79. TEXTURE_FLAG_FILTER = 4, /// Create texture with linear (or available) filter
  80. TEXTURE_FLAG_ANISOTROPIC_FILTER = 8,
  81. TEXTURE_FLAG_CONVERT_TO_LINEAR = 16,
  82. TEXTURE_FLAG_MIRRORED_REPEAT = 32, /// Repeat texture, with alternate sections mirrored
  83. TEXTURE_FLAG_USED_FOR_STREAMING = 2048,
  84. TEXTURE_FLAGS_DEFAULT = TEXTURE_FLAG_REPEAT | TEXTURE_FLAG_MIPMAPS | TEXTURE_FLAG_FILTER
  85. };
  86. enum TextureType {
  87. TEXTURE_TYPE_2D,
  88. TEXTURE_TYPE_EXTERNAL,
  89. TEXTURE_TYPE_CUBEMAP,
  90. TEXTURE_TYPE_2D_ARRAY,
  91. TEXTURE_TYPE_3D,
  92. };
  93. enum CubeMapSide {
  94. CUBEMAP_LEFT,
  95. CUBEMAP_RIGHT,
  96. CUBEMAP_BOTTOM,
  97. CUBEMAP_TOP,
  98. CUBEMAP_FRONT,
  99. CUBEMAP_BACK
  100. };
  101. virtual RID texture_create() = 0;
  102. RID texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags = TEXTURE_FLAGS_DEFAULT); // helper
  103. virtual void texture_allocate(RID p_texture,
  104. int p_width,
  105. int p_height,
  106. int p_depth_3d,
  107. Image::Format p_format,
  108. TextureType p_type,
  109. uint32_t p_flags = TEXTURE_FLAGS_DEFAULT) = 0;
  110. virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0;
  111. virtual void texture_set_data_partial(RID p_texture,
  112. const Ref<Image> &p_image,
  113. int src_x, int src_y,
  114. int src_w, int src_h,
  115. int dst_x, int dst_y,
  116. int p_dst_mip,
  117. int p_layer = 0) = 0;
  118. virtual Ref<Image> texture_get_data(RID p_texture, int p_layer = 0) const = 0;
  119. virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0;
  120. virtual uint32_t texture_get_flags(RID p_texture) const = 0;
  121. virtual Image::Format texture_get_format(RID p_texture) const = 0;
  122. virtual TextureType texture_get_type(RID p_texture) const = 0;
  123. virtual uint32_t texture_get_texid(RID p_texture) const = 0;
  124. virtual uint32_t texture_get_width(RID p_texture) const = 0;
  125. virtual uint32_t texture_get_height(RID p_texture) const = 0;
  126. virtual uint32_t texture_get_depth(RID p_texture) const = 0;
  127. virtual void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth_3d) = 0;
  128. virtual void texture_bind(RID p_texture, uint32_t p_texture_no) = 0;
  129. virtual void texture_set_path(RID p_texture, const String &p_path) = 0;
  130. virtual String texture_get_path(RID p_texture) const = 0;
  131. virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable) = 0;
  132. typedef void (*TextureDetectCallback)(void *);
  133. virtual void texture_set_detect_3d_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0;
  134. virtual void texture_set_detect_srgb_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0;
  135. virtual void texture_set_detect_normal_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0;
  136. struct TextureInfo {
  137. RID texture;
  138. uint32_t width;
  139. uint32_t height;
  140. uint32_t depth;
  141. Image::Format format;
  142. int bytes;
  143. String path;
  144. };
  145. virtual void texture_debug_usage(List<TextureInfo> *r_info) = 0;
  146. Array _texture_debug_usage_bind();
  147. virtual void textures_keep_original(bool p_enable) = 0;
  148. virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0;
  149. virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0;
  150. /* SKY API */
  151. virtual RID sky_create() = 0;
  152. virtual void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) = 0;
  153. /* SHADER API */
  154. enum ShaderMode {
  155. SHADER_SPATIAL,
  156. SHADER_CANVAS_ITEM,
  157. SHADER_PARTICLES,
  158. SHADER_MAX
  159. };
  160. virtual RID shader_create() = 0;
  161. virtual void shader_set_code(RID p_shader, const String &p_code) = 0;
  162. virtual String shader_get_code(RID p_shader) const = 0;
  163. virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0;
  164. Array _shader_get_param_list_bind(RID p_shader) const;
  165. virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) = 0;
  166. virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const = 0;
  167. virtual void shader_add_custom_define(RID p_shader, const String &p_define) = 0;
  168. virtual void shader_get_custom_defines(RID p_shader, Vector<String> *p_defines) const = 0;
  169. virtual void shader_remove_custom_define(RID p_shader, const String &p_define) = 0;
  170. virtual void set_shader_async_hidden_forbidden(bool p_forbidden) = 0;
  171. /* COMMON MATERIAL API */
  172. enum {
  173. MATERIAL_RENDER_PRIORITY_MIN = -128,
  174. MATERIAL_RENDER_PRIORITY_MAX = 127,
  175. };
  176. virtual RID material_create() = 0;
  177. virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0;
  178. virtual RID material_get_shader(RID p_shader_material) const = 0;
  179. virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0;
  180. virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0;
  181. virtual Variant material_get_param_default(RID p_material, const StringName &p_param) const = 0;
  182. virtual void material_set_render_priority(RID p_material, int priority) = 0;
  183. virtual void material_set_line_width(RID p_material, float p_width) = 0;
  184. virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0;
  185. /* MESH API */
  186. enum ArrayType {
  187. ARRAY_VERTEX = 0,
  188. ARRAY_NORMAL = 1,
  189. ARRAY_TANGENT = 2,
  190. ARRAY_COLOR = 3,
  191. ARRAY_TEX_UV = 4,
  192. ARRAY_TEX_UV2 = 5,
  193. ARRAY_BONES = 6,
  194. ARRAY_WEIGHTS = 7,
  195. ARRAY_INDEX = 8,
  196. ARRAY_MAX = 9
  197. };
  198. enum ArrayFormat {
  199. /* ARRAY FORMAT FLAGS */
  200. ARRAY_FORMAT_VERTEX = 1 << ARRAY_VERTEX, // mandatory
  201. ARRAY_FORMAT_NORMAL = 1 << ARRAY_NORMAL,
  202. ARRAY_FORMAT_TANGENT = 1 << ARRAY_TANGENT,
  203. ARRAY_FORMAT_COLOR = 1 << ARRAY_COLOR,
  204. ARRAY_FORMAT_TEX_UV = 1 << ARRAY_TEX_UV,
  205. ARRAY_FORMAT_TEX_UV2 = 1 << ARRAY_TEX_UV2,
  206. ARRAY_FORMAT_BONES = 1 << ARRAY_BONES,
  207. ARRAY_FORMAT_WEIGHTS = 1 << ARRAY_WEIGHTS,
  208. ARRAY_FORMAT_INDEX = 1 << ARRAY_INDEX,
  209. ARRAY_COMPRESS_BASE = (ARRAY_INDEX + 1),
  210. ARRAY_COMPRESS_VERTEX = 1 << (ARRAY_VERTEX + ARRAY_COMPRESS_BASE), // mandatory
  211. ARRAY_COMPRESS_NORMAL = 1 << (ARRAY_NORMAL + ARRAY_COMPRESS_BASE),
  212. ARRAY_COMPRESS_TANGENT = 1 << (ARRAY_TANGENT + ARRAY_COMPRESS_BASE),
  213. ARRAY_COMPRESS_COLOR = 1 << (ARRAY_COLOR + ARRAY_COMPRESS_BASE),
  214. ARRAY_COMPRESS_TEX_UV = 1 << (ARRAY_TEX_UV + ARRAY_COMPRESS_BASE),
  215. ARRAY_COMPRESS_TEX_UV2 = 1 << (ARRAY_TEX_UV2 + ARRAY_COMPRESS_BASE),
  216. ARRAY_COMPRESS_BONES = 1 << (ARRAY_BONES + ARRAY_COMPRESS_BASE),
  217. ARRAY_COMPRESS_WEIGHTS = 1 << (ARRAY_WEIGHTS + ARRAY_COMPRESS_BASE),
  218. ARRAY_COMPRESS_INDEX = 1 << (ARRAY_INDEX + ARRAY_COMPRESS_BASE),
  219. ARRAY_FLAG_USE_2D_VERTICES = ARRAY_COMPRESS_INDEX << 1,
  220. ARRAY_FLAG_USE_16_BIT_BONES = ARRAY_COMPRESS_INDEX << 2,
  221. ARRAY_FLAG_USE_DYNAMIC_UPDATE = ARRAY_COMPRESS_INDEX << 3,
  222. ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION = ARRAY_COMPRESS_INDEX << 4,
  223. ARRAY_FLAG_USE_VERTEX_CACHE_OPTIMIZATION = ARRAY_COMPRESS_INDEX << 5,
  224. ARRAY_COMPRESS_DEFAULT = ARRAY_COMPRESS_NORMAL | ARRAY_COMPRESS_TANGENT | ARRAY_COMPRESS_COLOR | ARRAY_COMPRESS_TEX_UV | ARRAY_COMPRESS_TEX_UV2 | ARRAY_COMPRESS_WEIGHTS | ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION
  225. };
  226. enum PrimitiveType {
  227. PRIMITIVE_POINTS = 0,
  228. PRIMITIVE_LINES = 1,
  229. PRIMITIVE_LINE_STRIP = 2,
  230. PRIMITIVE_LINE_LOOP = 3,
  231. PRIMITIVE_TRIANGLES = 4,
  232. PRIMITIVE_TRIANGLE_STRIP = 5,
  233. PRIMITIVE_TRIANGLE_FAN = 6,
  234. PRIMITIVE_MAX = 7,
  235. };
  236. virtual RID mesh_create() = 0;
  237. virtual uint32_t mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const;
  238. virtual uint32_t mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const;
  239. /// Returns stride
  240. virtual void mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets, uint32_t *r_strides) const;
  241. virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = ARRAY_COMPRESS_DEFAULT);
  242. virtual uint32_t mesh_find_format_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = ARRAY_COMPRESS_DEFAULT);
  243. bool _mesh_find_format(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, uint32_t p_compress_format, bool p_use_split_stream, uint32_t r_offsets[], int &r_attributes_base_offset, int &r_attributes_stride, int &r_positions_stride, uint32_t &r_format, int &r_index_array_len, int &r_array_len);
  244. virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t>> &p_blend_shapes = Vector<PoolVector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0;
  245. virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0;
  246. virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0;
  247. enum BlendShapeMode {
  248. BLEND_SHAPE_MODE_NORMALIZED,
  249. BLEND_SHAPE_MODE_RELATIVE,
  250. };
  251. virtual void mesh_set_blend_shape_mode(RID p_mesh, BlendShapeMode p_mode) = 0;
  252. virtual BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
  253. virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) = 0;
  254. virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
  255. virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0;
  256. virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const = 0;
  257. virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const = 0;
  258. virtual PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const = 0;
  259. virtual PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const = 0;
  260. virtual Array mesh_surface_get_arrays(RID p_mesh, int p_surface) const;
  261. virtual Array mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const;
  262. virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0;
  263. virtual PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0;
  264. virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0;
  265. virtual Vector<PoolVector<uint8_t>> mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0;
  266. virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0;
  267. Array _mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const;
  268. virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0;
  269. virtual int mesh_get_surface_count(RID p_mesh) const = 0;
  270. virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0;
  271. virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
  272. virtual void mesh_clear(RID p_mesh) = 0;
  273. /* MULTIMESH API */
  274. virtual RID multimesh_create() = 0;
  275. enum MultimeshTransformFormat {
  276. MULTIMESH_TRANSFORM_2D,
  277. MULTIMESH_TRANSFORM_3D,
  278. };
  279. enum MultimeshColorFormat {
  280. MULTIMESH_COLOR_NONE,
  281. MULTIMESH_COLOR_8BIT,
  282. MULTIMESH_COLOR_FLOAT,
  283. MULTIMESH_COLOR_MAX,
  284. };
  285. enum MultimeshCustomDataFormat {
  286. MULTIMESH_CUSTOM_DATA_NONE,
  287. MULTIMESH_CUSTOM_DATA_8BIT,
  288. MULTIMESH_CUSTOM_DATA_FLOAT,
  289. MULTIMESH_CUSTOM_DATA_MAX,
  290. };
  291. enum MultimeshPhysicsInterpolationQuality {
  292. MULTIMESH_INTERP_QUALITY_FAST,
  293. MULTIMESH_INTERP_QUALITY_HIGH,
  294. };
  295. virtual void multimesh_allocate(RID p_multimesh, int p_instances, MultimeshTransformFormat p_transform_format, MultimeshColorFormat p_color_format, MultimeshCustomDataFormat p_data_format = MULTIMESH_CUSTOM_DATA_NONE) = 0;
  296. virtual int multimesh_get_instance_count(RID p_multimesh) const = 0;
  297. virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh) = 0;
  298. virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) = 0;
  299. virtual void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) = 0;
  300. virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0;
  301. virtual void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) = 0;
  302. virtual RID multimesh_get_mesh(RID p_multimesh) const = 0;
  303. virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0;
  304. virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0;
  305. virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0;
  306. virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const = 0;
  307. virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
  308. virtual void multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array) = 0;
  309. // Interpolation
  310. virtual void multimesh_set_as_bulk_array_interpolated(RID p_multimesh, const PoolVector<float> &p_array, const PoolVector<float> &p_array_prev) = 0;
  311. virtual void multimesh_set_physics_interpolated(RID p_multimesh, bool p_interpolated) = 0;
  312. virtual void multimesh_set_physics_interpolation_quality(RID p_multimesh, MultimeshPhysicsInterpolationQuality p_quality) = 0;
  313. virtual void multimesh_instance_reset_physics_interpolation(RID p_multimesh, int p_index) = 0;
  314. virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
  315. virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0;
  316. /* IMMEDIATE API */
  317. virtual RID immediate_create() = 0;
  318. virtual void immediate_begin(RID p_immediate, PrimitiveType p_rimitive, RID p_texture = RID()) = 0;
  319. virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) = 0;
  320. virtual void immediate_vertex_2d(RID p_immediate, const Vector2 &p_vertex);
  321. virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal) = 0;
  322. virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent) = 0;
  323. virtual void immediate_color(RID p_immediate, const Color &p_color) = 0;
  324. virtual void immediate_uv(RID p_immediate, const Vector2 &tex_uv) = 0;
  325. virtual void immediate_uv2(RID p_immediate, const Vector2 &tex_uv) = 0;
  326. virtual void immediate_end(RID p_immediate) = 0;
  327. virtual void immediate_clear(RID p_immediate) = 0;
  328. virtual void immediate_set_material(RID p_immediate, RID p_material) = 0;
  329. virtual RID immediate_get_material(RID p_immediate) const = 0;
  330. /* SKELETON API */
  331. virtual RID skeleton_create() = 0;
  332. virtual void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) = 0;
  333. virtual int skeleton_get_bone_count(RID p_skeleton) const = 0;
  334. virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) = 0;
  335. virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const = 0;
  336. virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) = 0;
  337. virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const = 0;
  338. virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) = 0;
  339. /* Light API */
  340. enum LightType {
  341. LIGHT_DIRECTIONAL,
  342. LIGHT_OMNI,
  343. LIGHT_SPOT
  344. };
  345. enum LightParam {
  346. LIGHT_PARAM_ENERGY,
  347. LIGHT_PARAM_INDIRECT_ENERGY,
  348. LIGHT_PARAM_SIZE,
  349. LIGHT_PARAM_SPECULAR,
  350. LIGHT_PARAM_RANGE,
  351. LIGHT_PARAM_ATTENUATION,
  352. LIGHT_PARAM_SPOT_ANGLE,
  353. LIGHT_PARAM_SPOT_ATTENUATION,
  354. LIGHT_PARAM_CONTACT_SHADOW_SIZE,
  355. LIGHT_PARAM_SHADOW_MAX_DISTANCE,
  356. LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
  357. LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,
  358. LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET,
  359. LIGHT_PARAM_SHADOW_NORMAL_BIAS,
  360. LIGHT_PARAM_SHADOW_BIAS,
  361. LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE,
  362. LIGHT_PARAM_SHADOW_FADE_START,
  363. LIGHT_PARAM_MAX
  364. };
  365. virtual RID directional_light_create() = 0;
  366. virtual RID omni_light_create() = 0;
  367. virtual RID spot_light_create() = 0;
  368. virtual void light_set_color(RID p_light, const Color &p_color) = 0;
  369. virtual void light_set_param(RID p_light, LightParam p_param, float p_value) = 0;
  370. virtual void light_set_shadow(RID p_light, bool p_enabled) = 0;
  371. virtual void light_set_shadow_color(RID p_light, const Color &p_color) = 0;
  372. virtual void light_set_projector(RID p_light, RID p_texture) = 0;
  373. virtual void light_set_negative(RID p_light, bool p_enable) = 0;
  374. virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
  375. virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
  376. virtual void light_set_use_gi(RID p_light, bool p_enable) = 0;
  377. // bake mode
  378. enum LightBakeMode {
  379. LIGHT_BAKE_DISABLED,
  380. LIGHT_BAKE_INDIRECT,
  381. LIGHT_BAKE_ALL
  382. };
  383. virtual void light_set_bake_mode(RID p_light, LightBakeMode p_bake_mode) = 0;
  384. // omni light
  385. enum LightOmniShadowMode {
  386. LIGHT_OMNI_SHADOW_DUAL_PARABOLOID,
  387. LIGHT_OMNI_SHADOW_CUBE,
  388. };
  389. virtual void light_omni_set_shadow_mode(RID p_light, LightOmniShadowMode p_mode) = 0;
  390. // omni light
  391. enum LightOmniShadowDetail {
  392. LIGHT_OMNI_SHADOW_DETAIL_VERTICAL,
  393. LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL
  394. };
  395. virtual void light_omni_set_shadow_detail(RID p_light, LightOmniShadowDetail p_detail) = 0;
  396. // directional light
  397. enum LightDirectionalShadowMode {
  398. LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL,
  399. LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS,
  400. LIGHT_DIRECTIONAL_SHADOW_PARALLEL_3_SPLITS,
  401. LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS
  402. };
  403. virtual void light_directional_set_shadow_mode(RID p_light, LightDirectionalShadowMode p_mode) = 0;
  404. virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) = 0;
  405. enum LightDirectionalShadowDepthRangeMode {
  406. LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE,
  407. LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED,
  408. };
  409. virtual void light_directional_set_shadow_depth_range_mode(RID p_light, LightDirectionalShadowDepthRangeMode p_range_mode) = 0;
  410. /* PROBE API */
  411. virtual RID reflection_probe_create() = 0;
  412. enum ReflectionProbeUpdateMode {
  413. REFLECTION_PROBE_UPDATE_ONCE,
  414. REFLECTION_PROBE_UPDATE_ALWAYS,
  415. };
  416. virtual void reflection_probe_set_update_mode(RID p_probe, ReflectionProbeUpdateMode p_mode) = 0;
  417. virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0;
  418. virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_color) = 0;
  419. virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) = 0;
  420. virtual void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) = 0;
  421. virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) = 0;
  422. virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) = 0;
  423. virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) = 0;
  424. virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) = 0;
  425. virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0;
  426. virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
  427. virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
  428. virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0;
  429. /* GI PROBE API */
  430. virtual RID gi_probe_create() = 0;
  431. virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) = 0;
  432. virtual AABB gi_probe_get_bounds(RID p_probe) const = 0;
  433. virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0;
  434. virtual float gi_probe_get_cell_size(RID p_probe) const = 0;
  435. virtual void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform) = 0;
  436. virtual Transform gi_probe_get_to_cell_xform(RID p_probe) const = 0;
  437. virtual void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) = 0;
  438. virtual PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const = 0;
  439. virtual void gi_probe_set_dynamic_range(RID p_probe, int p_range) = 0;
  440. virtual int gi_probe_get_dynamic_range(RID p_probe) const = 0;
  441. virtual void gi_probe_set_energy(RID p_probe, float p_range) = 0;
  442. virtual float gi_probe_get_energy(RID p_probe) const = 0;
  443. virtual void gi_probe_set_bias(RID p_probe, float p_range) = 0;
  444. virtual float gi_probe_get_bias(RID p_probe) const = 0;
  445. virtual void gi_probe_set_normal_bias(RID p_probe, float p_range) = 0;
  446. virtual float gi_probe_get_normal_bias(RID p_probe) const = 0;
  447. virtual void gi_probe_set_propagation(RID p_probe, float p_range) = 0;
  448. virtual float gi_probe_get_propagation(RID p_probe) const = 0;
  449. virtual void gi_probe_set_interior(RID p_probe, bool p_enable) = 0;
  450. virtual bool gi_probe_is_interior(RID p_probe) const = 0;
  451. virtual void gi_probe_set_compress(RID p_probe, bool p_enable) = 0;
  452. virtual bool gi_probe_is_compressed(RID p_probe) const = 0;
  453. /* LIGHTMAP CAPTURE */
  454. virtual RID lightmap_capture_create() = 0;
  455. virtual void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) = 0;
  456. virtual AABB lightmap_capture_get_bounds(RID p_capture) const = 0;
  457. virtual void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) = 0;
  458. virtual void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform) = 0;
  459. virtual Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const = 0;
  460. virtual void lightmap_capture_set_octree_cell_subdiv(RID p_capture, int p_subdiv) = 0;
  461. virtual int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const = 0;
  462. virtual PoolVector<uint8_t> lightmap_capture_get_octree(RID p_capture) const = 0;
  463. virtual void lightmap_capture_set_energy(RID p_capture, float p_energy) = 0;
  464. virtual float lightmap_capture_get_energy(RID p_capture) const = 0;
  465. virtual void lightmap_capture_set_interior(RID p_capture, bool p_interior) = 0;
  466. virtual bool lightmap_capture_is_interior(RID p_capture) const = 0;
  467. /* PARTICLES API */
  468. virtual RID particles_create() = 0;
  469. virtual void particles_set_emitting(RID p_particles, bool p_emitting) = 0;
  470. virtual bool particles_get_emitting(RID p_particles) = 0;
  471. virtual void particles_set_amount(RID p_particles, int p_amount) = 0;
  472. virtual void particles_set_lifetime(RID p_particles, float p_lifetime) = 0;
  473. virtual void particles_set_one_shot(RID p_particles, bool p_one_shot) = 0;
  474. virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0;
  475. virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0;
  476. virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0;
  477. virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0;
  478. virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0;
  479. virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0;
  480. virtual void particles_set_process_material(RID p_particles, RID p_material) = 0;
  481. virtual void particles_set_fixed_fps(RID p_particles, int p_fps) = 0;
  482. virtual void particles_set_fractional_delta(RID p_particles, bool p_enable) = 0;
  483. virtual bool particles_is_inactive(RID p_particles) = 0;
  484. virtual void particles_request_process(RID p_particles) = 0;
  485. virtual void particles_restart(RID p_particles) = 0;
  486. enum ParticlesDrawOrder {
  487. PARTICLES_DRAW_ORDER_INDEX,
  488. PARTICLES_DRAW_ORDER_LIFETIME,
  489. PARTICLES_DRAW_ORDER_VIEW_DEPTH,
  490. };
  491. virtual void particles_set_draw_order(RID p_particles, ParticlesDrawOrder p_order) = 0;
  492. virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0;
  493. virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0;
  494. virtual AABB particles_get_current_aabb(RID p_particles) = 0;
  495. virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; //this is only used for 2D, in 3D it's automatic
  496. /* CAMERA API */
  497. virtual RID camera_create() = 0;
  498. virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) = 0;
  499. virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) = 0;
  500. virtual void camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) = 0;
  501. virtual void camera_set_transform(RID p_camera, const Transform &p_transform) = 0;
  502. virtual void camera_set_cull_mask(RID p_camera, uint32_t p_layers) = 0;
  503. virtual void camera_set_environment(RID p_camera, RID p_env) = 0;
  504. virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable) = 0;
  505. /*
  506. enum ParticlesCollisionMode {
  507. PARTICLES_COLLISION_NONE,
  508. PARTICLES_COLLISION_TEXTURE,
  509. PARTICLES_COLLISION_CUBEMAP,
  510. };
  511. virtual void particles_set_collision(RID p_particles,ParticlesCollisionMode p_mode,const Transform&, p_xform,const RID p_depth_tex,const RID p_normal_tex)=0;
  512. */
  513. /* VIEWPORT TARGET API */
  514. virtual RID viewport_create() = 0;
  515. virtual void viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) = 0;
  516. virtual void viewport_set_size(RID p_viewport, int p_width, int p_height) = 0;
  517. virtual void viewport_set_active(RID p_viewport, bool p_active) = 0;
  518. virtual void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) = 0;
  519. virtual void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), int p_screen = 0) = 0;
  520. virtual void viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) = 0;
  521. virtual void viewport_detach(RID p_viewport) = 0;
  522. enum ViewportUpdateMode {
  523. VIEWPORT_UPDATE_DISABLED,
  524. VIEWPORT_UPDATE_ONCE, //then goes to disabled, must be manually updated
  525. VIEWPORT_UPDATE_WHEN_VISIBLE, // default
  526. VIEWPORT_UPDATE_ALWAYS
  527. };
  528. virtual void viewport_set_update_mode(RID p_viewport, ViewportUpdateMode p_mode) = 0;
  529. virtual void viewport_set_vflip(RID p_viewport, bool p_enable) = 0;
  530. enum ViewportClearMode {
  531. VIEWPORT_CLEAR_ALWAYS,
  532. VIEWPORT_CLEAR_NEVER,
  533. VIEWPORT_CLEAR_ONLY_NEXT_FRAME
  534. };
  535. virtual void viewport_set_clear_mode(RID p_viewport, ViewportClearMode p_clear_mode) = 0;
  536. virtual RID viewport_get_texture(RID p_viewport) const = 0;
  537. virtual void viewport_set_hide_scenario(RID p_viewport, bool p_hide) = 0;
  538. virtual void viewport_set_hide_canvas(RID p_viewport, bool p_hide) = 0;
  539. virtual void viewport_set_disable_environment(RID p_viewport, bool p_disable) = 0;
  540. virtual void viewport_set_disable_3d(RID p_viewport, bool p_disable) = 0;
  541. virtual void viewport_set_keep_3d_linear(RID p_viewport, bool p_disable) = 0;
  542. virtual void viewport_attach_camera(RID p_viewport, RID p_camera) = 0;
  543. virtual void viewport_set_scenario(RID p_viewport, RID p_scenario) = 0;
  544. virtual void viewport_attach_canvas(RID p_viewport, RID p_canvas) = 0;
  545. virtual void viewport_remove_canvas(RID p_viewport, RID p_canvas) = 0;
  546. virtual void viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) = 0;
  547. virtual void viewport_set_transparent_background(RID p_viewport, bool p_enabled) = 0;
  548. virtual void viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) = 0;
  549. virtual void viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) = 0;
  550. virtual void viewport_set_shadow_atlas_size(RID p_viewport, int p_size) = 0;
  551. virtual void viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) = 0;
  552. enum ViewportMSAA {
  553. VIEWPORT_MSAA_DISABLED,
  554. VIEWPORT_MSAA_2X,
  555. VIEWPORT_MSAA_4X,
  556. VIEWPORT_MSAA_8X,
  557. VIEWPORT_MSAA_16X,
  558. VIEWPORT_MSAA_EXT_2X,
  559. VIEWPORT_MSAA_EXT_4X,
  560. };
  561. virtual void viewport_set_msaa(RID p_viewport, ViewportMSAA p_msaa) = 0;
  562. virtual void viewport_set_use_fxaa(RID p_viewport, bool p_fxaa) = 0;
  563. virtual void viewport_set_use_debanding(RID p_viewport, bool p_debanding) = 0;
  564. virtual void viewport_set_sharpen_intensity(RID p_viewport, float p_intensity) = 0;
  565. enum ViewportUsage {
  566. VIEWPORT_USAGE_2D,
  567. VIEWPORT_USAGE_2D_NO_SAMPLING,
  568. VIEWPORT_USAGE_3D,
  569. VIEWPORT_USAGE_3D_NO_EFFECTS,
  570. };
  571. virtual void viewport_set_hdr(RID p_viewport, bool p_enabled) = 0;
  572. virtual void viewport_set_use_32_bpc_depth(RID p_viewport, bool p_enabled) = 0;
  573. virtual void viewport_set_usage(RID p_viewport, ViewportUsage p_usage) = 0;
  574. enum ViewportRenderInfo {
  575. VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME,
  576. VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME,
  577. VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME,
  578. VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME,
  579. VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME,
  580. VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME,
  581. VIEWPORT_RENDER_INFO_2D_ITEMS_IN_FRAME,
  582. VIEWPORT_RENDER_INFO_2D_DRAW_CALLS_IN_FRAME,
  583. VIEWPORT_RENDER_INFO_MAX
  584. };
  585. virtual int viewport_get_render_info(RID p_viewport, ViewportRenderInfo p_info) = 0;
  586. enum ViewportDebugDraw {
  587. VIEWPORT_DEBUG_DRAW_DISABLED,
  588. VIEWPORT_DEBUG_DRAW_UNSHADED,
  589. VIEWPORT_DEBUG_DRAW_OVERDRAW,
  590. VIEWPORT_DEBUG_DRAW_WIREFRAME,
  591. };
  592. virtual void viewport_set_debug_draw(RID p_viewport, ViewportDebugDraw p_draw) = 0;
  593. /* ENVIRONMENT API */
  594. virtual RID environment_create() = 0;
  595. enum EnvironmentBG {
  596. ENV_BG_CLEAR_COLOR,
  597. ENV_BG_COLOR,
  598. ENV_BG_SKY,
  599. ENV_BG_COLOR_SKY,
  600. ENV_BG_CANVAS,
  601. ENV_BG_KEEP,
  602. ENV_BG_CAMERA_FEED,
  603. ENV_BG_MAX
  604. };
  605. virtual void environment_set_background(RID p_env, EnvironmentBG p_bg) = 0;
  606. virtual void environment_set_sky(RID p_env, RID p_sky) = 0;
  607. virtual void environment_set_sky_custom_fov(RID p_env, float p_scale) = 0;
  608. virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) = 0;
  609. virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0;
  610. virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0;
  611. virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0;
  612. virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) = 0;
  613. virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) = 0;
  614. //set default SSAO options
  615. //set default SSR options
  616. //set default SSSSS options
  617. enum EnvironmentDOFBlurQuality {
  618. ENV_DOF_BLUR_QUALITY_LOW,
  619. ENV_DOF_BLUR_QUALITY_MEDIUM,
  620. ENV_DOF_BLUR_QUALITY_HIGH,
  621. };
  622. virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, EnvironmentDOFBlurQuality p_quality) = 0;
  623. virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, EnvironmentDOFBlurQuality p_quality) = 0;
  624. enum EnvironmentGlowBlendMode {
  625. GLOW_BLEND_MODE_ADDITIVE,
  626. GLOW_BLEND_MODE_SCREEN,
  627. GLOW_BLEND_MODE_SOFTLIGHT,
  628. GLOW_BLEND_MODE_REPLACE,
  629. };
  630. virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale, bool p_high_quality) = 0;
  631. virtual void environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map) = 0;
  632. enum EnvironmentToneMapper {
  633. ENV_TONE_MAPPER_LINEAR,
  634. ENV_TONE_MAPPER_REINHARD,
  635. ENV_TONE_MAPPER_FILMIC,
  636. ENV_TONE_MAPPER_ACES,
  637. ENV_TONE_MAPPER_ACES_FITTED
  638. };
  639. virtual void environment_set_tonemap(RID p_env, 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_grey) = 0;
  640. virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) = 0;
  641. virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness) = 0;
  642. enum EnvironmentSSAOQuality {
  643. ENV_SSAO_QUALITY_LOW,
  644. ENV_SSAO_QUALITY_MEDIUM,
  645. ENV_SSAO_QUALITY_HIGH,
  646. };
  647. enum EnvironmentSSAOBlur {
  648. ENV_SSAO_BLUR_DISABLED,
  649. ENV_SSAO_BLUR_1x1,
  650. ENV_SSAO_BLUR_2x2,
  651. ENV_SSAO_BLUR_3x3,
  652. };
  653. virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, EnvironmentSSAOQuality p_quality, EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) = 0;
  654. virtual void environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) = 0;
  655. virtual void environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) = 0;
  656. virtual void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) = 0;
  657. /* INTERPOLATION API */
  658. virtual void set_physics_interpolation_enabled(bool p_enabled) = 0;
  659. /* SCENARIO API */
  660. virtual RID scenario_create() = 0;
  661. enum ScenarioDebugMode {
  662. SCENARIO_DEBUG_DISABLED,
  663. SCENARIO_DEBUG_WIREFRAME,
  664. SCENARIO_DEBUG_OVERDRAW,
  665. SCENARIO_DEBUG_SHADELESS,
  666. };
  667. virtual void scenario_set_debug(RID p_scenario, ScenarioDebugMode p_debug_mode) = 0;
  668. virtual void scenario_set_environment(RID p_scenario, RID p_environment) = 0;
  669. virtual void scenario_set_reflection_atlas_size(RID p_scenario, int p_size, int p_subdiv) = 0;
  670. virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment) = 0;
  671. /* INSTANCING API */
  672. enum InstanceType {
  673. INSTANCE_NONE,
  674. INSTANCE_MESH,
  675. INSTANCE_MULTIMESH,
  676. INSTANCE_IMMEDIATE,
  677. INSTANCE_PARTICLES,
  678. INSTANCE_LIGHT,
  679. INSTANCE_REFLECTION_PROBE,
  680. INSTANCE_GI_PROBE,
  681. INSTANCE_LIGHTMAP_CAPTURE,
  682. INSTANCE_MAX,
  683. INSTANCE_GEOMETRY_MASK = (1 << INSTANCE_MESH) | (1 << INSTANCE_MULTIMESH) | (1 << INSTANCE_IMMEDIATE) | (1 << INSTANCE_PARTICLES)
  684. };
  685. virtual RID instance_create2(RID p_base, RID p_scenario);
  686. virtual RID instance_create() = 0;
  687. virtual void instance_set_base(RID p_instance, RID p_base) = 0;
  688. virtual void instance_set_scenario(RID p_instance, RID p_scenario) = 0;
  689. virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask) = 0;
  690. virtual void instance_set_pivot_data(RID p_instance, float p_sorting_offset, bool p_use_aabb_center) = 0;
  691. virtual void instance_set_transform(RID p_instance, const Transform &p_transform) = 0;
  692. virtual void instance_set_interpolated(RID p_instance, bool p_interpolated) = 0;
  693. virtual void instance_reset_physics_interpolation(RID p_instance) = 0;
  694. virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id) = 0;
  695. virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0;
  696. virtual void instance_set_surface_material(RID p_instance, int p_surface, RID p_material) = 0;
  697. virtual void instance_set_visible(RID p_instance, bool p_visible) = 0;
  698. virtual void instance_set_use_lightmap(RID p_instance, RID p_lightmap_instance, RID p_lightmap, int p_lightmap_slice, const Rect2 &p_lightmap_uv_rect) = 0;
  699. virtual void instance_set_custom_aabb(RID p_instance, AABB aabb) = 0;
  700. virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton) = 0;
  701. virtual void instance_set_exterior(RID p_instance, bool p_enabled) = 0;
  702. virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0;
  703. /* PORTALS API */
  704. enum InstancePortalMode {
  705. INSTANCE_PORTAL_MODE_STATIC, // not moving within a room
  706. INSTANCE_PORTAL_MODE_DYNAMIC, // moving within room
  707. INSTANCE_PORTAL_MODE_ROAMING, // moving between rooms
  708. INSTANCE_PORTAL_MODE_GLOBAL, // frustum culled only
  709. INSTANCE_PORTAL_MODE_IGNORE, // don't show at all - e.g. manual bounds, hidden portals
  710. };
  711. virtual void instance_set_portal_mode(RID p_instance, InstancePortalMode p_mode) = 0;
  712. virtual RID ghost_create() = 0;
  713. virtual void ghost_set_scenario(RID p_ghost, RID p_scenario, ObjectID p_id, const AABB &p_aabb) = 0;
  714. virtual void ghost_update(RID p_ghost, const AABB &p_aabb) = 0;
  715. virtual RID portal_create() = 0;
  716. virtual void portal_set_scenario(RID p_portal, RID p_scenario) = 0;
  717. virtual void portal_set_geometry(RID p_portal, const Vector<Vector3> &p_points, real_t p_margin) = 0;
  718. virtual void portal_link(RID p_portal, RID p_room_from, RID p_room_to, bool p_two_way) = 0;
  719. virtual void portal_set_active(RID p_portal, bool p_active) = 0;
  720. /* ROOMGROUPS API */
  721. virtual RID roomgroup_create() = 0;
  722. virtual void roomgroup_prepare(RID p_roomgroup, ObjectID p_roomgroup_object_id) = 0;
  723. virtual void roomgroup_set_scenario(RID p_roomgroup, RID p_scenario) = 0;
  724. virtual void roomgroup_add_room(RID p_roomgroup, RID p_room) = 0;
  725. /* OCCLUDERS API */
  726. enum OccluderType {
  727. OCCLUDER_TYPE_UNDEFINED,
  728. OCCLUDER_TYPE_SPHERE,
  729. OCCLUDER_TYPE_MESH,
  730. OCCLUDER_TYPE_NUM_TYPES,
  731. };
  732. virtual RID occluder_instance_create() = 0;
  733. virtual void occluder_instance_set_scenario(RID p_occluder_instance, RID p_scenario) = 0;
  734. virtual void occluder_instance_link_resource(RID p_occluder_instance, RID p_occluder_resource) = 0;
  735. virtual void occluder_instance_set_transform(RID p_occluder_instance, const Transform &p_xform) = 0;
  736. virtual void occluder_instance_set_active(RID p_occluder_instance, bool p_active) = 0;
  737. virtual RID occluder_resource_create() = 0;
  738. virtual void occluder_resource_prepare(RID p_occluder_resource, VisualServer::OccluderType p_type) = 0;
  739. virtual void occluder_resource_spheres_update(RID p_occluder_resource, const Vector<Plane> &p_spheres) = 0;
  740. virtual void occluder_resource_mesh_update(RID p_occluder_resource, const Geometry::OccluderMeshData &p_mesh_data) = 0;
  741. virtual void set_use_occlusion_culling(bool p_enable) = 0;
  742. virtual Geometry::MeshData occlusion_debug_get_current_polys(RID p_scenario) const = 0;
  743. /* ROOMS API */
  744. enum RoomsDebugFeature {
  745. ROOMS_DEBUG_SPRAWL,
  746. };
  747. virtual RID room_create() = 0;
  748. virtual void room_set_scenario(RID p_room, RID p_scenario) = 0;
  749. virtual void room_add_instance(RID p_room, RID p_instance, const AABB &p_aabb, const Vector<Vector3> &p_object_pts) = 0;
  750. virtual void room_add_ghost(RID p_room, ObjectID p_object_id, const AABB &p_aabb) = 0;
  751. virtual void room_set_bound(RID p_room, ObjectID p_room_object_id, const Vector<Plane> &p_convex, const AABB &p_aabb, const Vector<Vector3> &p_verts) = 0;
  752. virtual void room_prepare(RID p_room, int32_t p_priority) = 0;
  753. virtual void rooms_and_portals_clear(RID p_scenario) = 0;
  754. virtual void rooms_unload(RID p_scenario, String p_reason) = 0;
  755. virtual void rooms_finalize(RID p_scenario, bool p_generate_pvs, bool p_cull_using_pvs, bool p_use_secondary_pvs, bool p_use_signals, String p_pvs_filename, bool p_use_simple_pvs, bool p_log_pvs_generation) = 0;
  756. virtual void rooms_override_camera(RID p_scenario, bool p_override, const Vector3 &p_point, const Vector<Plane> *p_convex) = 0;
  757. virtual void rooms_set_active(RID p_scenario, bool p_active) = 0;
  758. virtual void rooms_set_params(RID p_scenario, int p_portal_depth_limit, real_t p_roaming_expansion_margin) = 0;
  759. virtual void rooms_set_debug_feature(RID p_scenario, RoomsDebugFeature p_feature, bool p_active) = 0;
  760. virtual void rooms_update_gameplay_monitor(RID p_scenario, const Vector<Vector3> &p_camera_positions) = 0;
  761. // don't use this in a game!
  762. virtual bool rooms_is_loaded(RID p_scenario) const = 0;
  763. // callbacks are used to send messages back from the visual server to scene tree in thread friendly manner
  764. virtual void callbacks_register(VisualServerCallbacks *p_callbacks) = 0;
  765. // don't use these in a game!
  766. virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const = 0;
  767. virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0;
  768. virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0;
  769. Array _instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario = RID()) const;
  770. Array _instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const;
  771. Array _instances_cull_convex_bind(const Array &p_convex, RID p_scenario = RID()) const;
  772. enum InstanceFlags {
  773. INSTANCE_FLAG_USE_BAKED_LIGHT,
  774. INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE,
  775. INSTANCE_FLAG_MAX
  776. };
  777. enum ShadowCastingSetting {
  778. SHADOW_CASTING_SETTING_OFF,
  779. SHADOW_CASTING_SETTING_ON,
  780. SHADOW_CASTING_SETTING_DOUBLE_SIDED,
  781. SHADOW_CASTING_SETTING_SHADOWS_ONLY,
  782. };
  783. virtual void instance_geometry_set_flag(RID p_instance, InstanceFlags p_flags, bool p_enabled) = 0;
  784. virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, ShadowCastingSetting p_shadow_casting_setting) = 0;
  785. virtual void instance_geometry_set_material_override(RID p_instance, RID p_material) = 0;
  786. virtual void instance_geometry_set_material_overlay(RID p_instance, RID p_material) = 0;
  787. /* CANVAS (2D) */
  788. virtual RID canvas_create() = 0;
  789. virtual void canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) = 0;
  790. virtual void canvas_set_modulate(RID p_canvas, const Color &p_color) = 0;
  791. virtual void canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) = 0;
  792. virtual void canvas_set_disable_scale(bool p_disable) = 0;
  793. virtual RID canvas_item_create() = 0;
  794. virtual void canvas_item_set_parent(RID p_item, RID p_parent) = 0;
  795. virtual void canvas_item_set_name(RID p_item, String p_name) = 0;
  796. virtual void canvas_item_set_visible(RID p_item, bool p_visible) = 0;
  797. virtual void canvas_item_set_light_mask(RID p_item, int p_mask) = 0;
  798. virtual void canvas_item_set_update_when_visible(RID p_item, bool p_update) = 0;
  799. virtual void canvas_item_set_transform(RID p_item, const Transform2D &p_transform) = 0;
  800. virtual void canvas_item_set_clip(RID p_item, bool p_clip) = 0;
  801. virtual void canvas_item_set_distance_field_mode(RID p_item, bool p_enable) = 0;
  802. virtual void canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect = Rect2()) = 0;
  803. virtual void canvas_item_set_modulate(RID p_item, const Color &p_color) = 0;
  804. virtual void canvas_item_set_self_modulate(RID p_item, const Color &p_color) = 0;
  805. virtual void canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) = 0;
  806. virtual void canvas_item_set_use_identity_transform(RID p_item, bool p_enable) = 0;
  807. enum NinePatchAxisMode {
  808. NINE_PATCH_STRETCH,
  809. NINE_PATCH_TILE,
  810. NINE_PATCH_TILE_FIT,
  811. };
  812. virtual void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false) = 0;
  813. virtual void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false) = 0;
  814. virtual void canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false) = 0;
  815. virtual void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) = 0;
  816. virtual void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) = 0;
  817. virtual void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID()) = 0;
  818. virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false) = 0;
  819. virtual void canvas_item_add_texture_multirect_region(RID p_item, const Vector<Rect2> &p_rects, RID p_texture, const Vector<Rect2> &p_src_rects, const Color &p_modulate = Color(1, 1, 1), uint32_t p_canvas_rect_flags = 0, RID p_normal_map = RID()) = 0;
  820. virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0;
  821. virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0;
  822. virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0;
  823. virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), bool p_antialiased = false, bool p_antialiasing_use_indices = false) = 0;
  824. virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID()) = 0;
  825. virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID()) = 0;
  826. virtual void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map) = 0;
  827. virtual void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) = 0;
  828. virtual void canvas_item_add_clip_ignore(RID p_item, bool p_ignore) = 0;
  829. virtual void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) = 0;
  830. virtual void canvas_item_set_z_index(RID p_item, int p_z) = 0;
  831. virtual void canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) = 0;
  832. virtual void canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) = 0;
  833. virtual void canvas_item_clear(RID p_item) = 0;
  834. virtual void canvas_item_set_draw_index(RID p_item, int p_index) = 0;
  835. virtual void canvas_item_set_material(RID p_item, RID p_material) = 0;
  836. virtual void canvas_item_set_use_parent_material(RID p_item, bool p_enable) = 0;
  837. virtual void canvas_item_attach_skeleton(RID p_item, RID p_skeleton) = 0;
  838. virtual void canvas_item_set_skeleton_relative_xform(RID p_item, Transform2D p_relative_xform) = 0;
  839. #ifdef TOOLS_ENABLED
  840. Rect2 debug_canvas_item_get_rect(RID p_item) { return _debug_canvas_item_get_rect(p_item); }
  841. Rect2 debug_canvas_item_get_local_bound(RID p_item) { return _debug_canvas_item_get_local_bound(p_item); }
  842. #else
  843. Rect2 debug_canvas_item_get_rect(RID p_item) { return Rect2(); }
  844. Rect2 debug_canvas_item_get_local_bound(RID p_item) { return Rect2(); }
  845. #endif
  846. virtual Rect2 _debug_canvas_item_get_rect(RID p_item) = 0;
  847. virtual Rect2 _debug_canvas_item_get_local_bound(RID p_item) = 0;
  848. virtual void canvas_item_set_interpolated(RID p_item, bool p_interpolated) = 0;
  849. virtual void canvas_item_reset_physics_interpolation(RID p_item) = 0;
  850. virtual void canvas_item_transform_physics_interpolation(RID p_item, const Transform2D &p_transform) = 0;
  851. virtual RID canvas_light_create() = 0;
  852. virtual void canvas_light_attach_to_canvas(RID p_light, RID p_canvas) = 0;
  853. virtual void canvas_light_set_enabled(RID p_light, bool p_enabled) = 0;
  854. virtual void canvas_light_set_scale(RID p_light, float p_scale) = 0;
  855. virtual void canvas_light_set_transform(RID p_light, const Transform2D &p_transform) = 0;
  856. virtual void canvas_light_set_texture(RID p_light, RID p_texture) = 0;
  857. virtual void canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) = 0;
  858. virtual void canvas_light_set_color(RID p_light, const Color &p_color) = 0;
  859. virtual void canvas_light_set_height(RID p_light, float p_height) = 0;
  860. virtual void canvas_light_set_energy(RID p_light, float p_energy) = 0;
  861. virtual void canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) = 0;
  862. virtual void canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) = 0;
  863. virtual void canvas_light_set_item_cull_mask(RID p_light, int p_mask) = 0;
  864. virtual void canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) = 0;
  865. virtual void canvas_light_set_interpolated(RID p_light, bool p_interpolated) = 0;
  866. virtual void canvas_light_reset_physics_interpolation(RID p_light) = 0;
  867. virtual void canvas_light_transform_physics_interpolation(RID p_light, const Transform2D &p_transform) = 0;
  868. enum CanvasLightMode {
  869. CANVAS_LIGHT_MODE_ADD,
  870. CANVAS_LIGHT_MODE_SUB,
  871. CANVAS_LIGHT_MODE_MIX,
  872. CANVAS_LIGHT_MODE_MASK,
  873. };
  874. virtual void canvas_light_set_mode(RID p_light, CanvasLightMode p_mode) = 0;
  875. enum CanvasLightShadowFilter {
  876. CANVAS_LIGHT_FILTER_NONE,
  877. CANVAS_LIGHT_FILTER_PCF3,
  878. CANVAS_LIGHT_FILTER_PCF5,
  879. CANVAS_LIGHT_FILTER_PCF7,
  880. CANVAS_LIGHT_FILTER_PCF9,
  881. CANVAS_LIGHT_FILTER_PCF13,
  882. };
  883. virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) = 0;
  884. virtual void canvas_light_set_shadow_buffer_size(RID p_light, int p_size) = 0;
  885. virtual void canvas_light_set_shadow_gradient_length(RID p_light, float p_length) = 0;
  886. virtual void canvas_light_set_shadow_filter(RID p_light, CanvasLightShadowFilter p_filter) = 0;
  887. virtual void canvas_light_set_shadow_color(RID p_light, const Color &p_color) = 0;
  888. virtual void canvas_light_set_shadow_smooth(RID p_light, float p_smooth) = 0;
  889. virtual RID canvas_light_occluder_create() = 0;
  890. virtual void canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) = 0;
  891. virtual void canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) = 0;
  892. virtual void canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) = 0;
  893. virtual void canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) = 0;
  894. virtual void canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) = 0;
  895. virtual void canvas_light_occluder_set_interpolated(RID p_occluder, bool p_interpolated) = 0;
  896. virtual void canvas_light_occluder_reset_physics_interpolation(RID p_occluder) = 0;
  897. virtual void canvas_light_occluder_transform_physics_interpolation(RID p_occluder, const Transform2D &p_transform) = 0;
  898. virtual RID canvas_occluder_polygon_create() = 0;
  899. virtual void canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape, bool p_closed) = 0;
  900. virtual void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const PoolVector<Vector2> &p_shape) = 0;
  901. enum CanvasOccluderPolygonCullMode {
  902. CANVAS_OCCLUDER_POLYGON_CULL_DISABLED,
  903. CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE,
  904. CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE,
  905. };
  906. virtual void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, CanvasOccluderPolygonCullMode p_mode) = 0;
  907. /* BLACK BARS */
  908. virtual void black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) = 0;
  909. virtual void black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) = 0;
  910. /* FREE */
  911. virtual void free(RID p_rid) = 0; ///< free RIDs associated with the visual server
  912. virtual void request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) = 0;
  913. /* EVENT QUEUING */
  914. enum ChangedPriority {
  915. CHANGED_PRIORITY_ANY = 0,
  916. CHANGED_PRIORITY_LOW,
  917. CHANGED_PRIORITY_HIGH,
  918. };
  919. virtual void draw(bool p_swap_buffers = true, double frame_step = 0.0) = 0;
  920. virtual void sync() = 0;
  921. virtual bool has_changed(ChangedPriority p_priority = CHANGED_PRIORITY_ANY) const = 0;
  922. virtual void init() = 0;
  923. virtual void finish() = 0;
  924. virtual void tick() = 0;
  925. virtual void pre_draw(bool p_will_draw) = 0;
  926. /* STATUS INFORMATION */
  927. enum RenderInfo {
  928. INFO_OBJECTS_IN_FRAME,
  929. INFO_VERTICES_IN_FRAME,
  930. INFO_MATERIAL_CHANGES_IN_FRAME,
  931. INFO_SHADER_CHANGES_IN_FRAME,
  932. INFO_SHADER_COMPILES_IN_FRAME,
  933. INFO_SURFACE_CHANGES_IN_FRAME,
  934. INFO_DRAW_CALLS_IN_FRAME,
  935. INFO_2D_ITEMS_IN_FRAME,
  936. INFO_2D_DRAW_CALLS_IN_FRAME,
  937. INFO_USAGE_VIDEO_MEM_TOTAL,
  938. INFO_VIDEO_MEM_USED,
  939. INFO_TEXTURE_MEM_USED,
  940. INFO_VERTEX_MEM_USED,
  941. };
  942. virtual uint64_t get_render_info(RenderInfo p_info) = 0;
  943. virtual String get_video_adapter_name() const = 0;
  944. virtual String get_video_adapter_vendor() const = 0;
  945. /* Materials for 2D on 3D */
  946. /* TESTING */
  947. virtual RID get_test_cube() = 0;
  948. virtual RID get_test_texture();
  949. virtual RID get_white_texture();
  950. virtual RID make_sphere_mesh(int p_lats, int p_lons, float p_radius);
  951. virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data);
  952. virtual void mesh_add_surface_from_planes(RID p_mesh, const PoolVector<Plane> &p_planes);
  953. virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
  954. virtual void set_default_clear_color(const Color &p_color) = 0;
  955. virtual void set_shader_time_scale(float p_scale) = 0;
  956. enum Features {
  957. FEATURE_SHADERS,
  958. FEATURE_MULTITHREADED,
  959. };
  960. virtual bool has_feature(Features p_feature) const = 0;
  961. virtual bool has_os_feature(const String &p_feature) const = 0;
  962. virtual void set_debug_generate_wireframes(bool p_generate) = 0;
  963. virtual void call_set_use_vsync(bool p_enable) = 0;
  964. virtual bool is_low_end() const = 0;
  965. bool is_render_loop_enabled() const;
  966. void set_render_loop_enabled(bool p_enabled);
  967. #ifdef DEBUG_ENABLED
  968. bool is_force_shader_fallbacks_enabled() const;
  969. void set_force_shader_fallbacks_enabled(bool p_enabled);
  970. #endif
  971. VisualServer();
  972. virtual ~VisualServer();
  973. };
  974. // make variant understand the enums
  975. VARIANT_ENUM_CAST(VisualServer::CubeMapSide);
  976. VARIANT_ENUM_CAST(VisualServer::TextureFlags);
  977. VARIANT_ENUM_CAST(VisualServer::ShaderMode);
  978. VARIANT_ENUM_CAST(VisualServer::ArrayType);
  979. VARIANT_ENUM_CAST(VisualServer::ArrayFormat);
  980. VARIANT_ENUM_CAST(VisualServer::PrimitiveType);
  981. VARIANT_ENUM_CAST(VisualServer::BlendShapeMode);
  982. VARIANT_ENUM_CAST(VisualServer::LightType);
  983. VARIANT_ENUM_CAST(VisualServer::LightParam);
  984. VARIANT_ENUM_CAST(VisualServer::ViewportUpdateMode);
  985. VARIANT_ENUM_CAST(VisualServer::ViewportClearMode);
  986. VARIANT_ENUM_CAST(VisualServer::ViewportMSAA);
  987. VARIANT_ENUM_CAST(VisualServer::ViewportUsage);
  988. VARIANT_ENUM_CAST(VisualServer::ViewportRenderInfo);
  989. VARIANT_ENUM_CAST(VisualServer::ViewportDebugDraw);
  990. VARIANT_ENUM_CAST(VisualServer::ScenarioDebugMode);
  991. VARIANT_ENUM_CAST(VisualServer::InstanceType);
  992. VARIANT_ENUM_CAST(VisualServer::InstancePortalMode);
  993. VARIANT_ENUM_CAST(VisualServer::NinePatchAxisMode);
  994. VARIANT_ENUM_CAST(VisualServer::CanvasLightMode);
  995. VARIANT_ENUM_CAST(VisualServer::CanvasLightShadowFilter);
  996. VARIANT_ENUM_CAST(VisualServer::CanvasOccluderPolygonCullMode);
  997. VARIANT_ENUM_CAST(VisualServer::RenderInfo);
  998. VARIANT_ENUM_CAST(VisualServer::Features);
  999. VARIANT_ENUM_CAST(VisualServer::MultimeshTransformFormat);
  1000. VARIANT_ENUM_CAST(VisualServer::MultimeshColorFormat);
  1001. VARIANT_ENUM_CAST(VisualServer::MultimeshCustomDataFormat);
  1002. VARIANT_ENUM_CAST(VisualServer::MultimeshPhysicsInterpolationQuality);
  1003. VARIANT_ENUM_CAST(VisualServer::LightBakeMode);
  1004. VARIANT_ENUM_CAST(VisualServer::LightOmniShadowMode);
  1005. VARIANT_ENUM_CAST(VisualServer::LightOmniShadowDetail);
  1006. VARIANT_ENUM_CAST(VisualServer::LightDirectionalShadowMode);
  1007. VARIANT_ENUM_CAST(VisualServer::LightDirectionalShadowDepthRangeMode);
  1008. VARIANT_ENUM_CAST(VisualServer::ReflectionProbeUpdateMode);
  1009. VARIANT_ENUM_CAST(VisualServer::ParticlesDrawOrder);
  1010. VARIANT_ENUM_CAST(VisualServer::EnvironmentBG);
  1011. VARIANT_ENUM_CAST(VisualServer::EnvironmentDOFBlurQuality);
  1012. VARIANT_ENUM_CAST(VisualServer::EnvironmentGlowBlendMode);
  1013. VARIANT_ENUM_CAST(VisualServer::EnvironmentToneMapper);
  1014. VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOQuality);
  1015. VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOBlur);
  1016. VARIANT_ENUM_CAST(VisualServer::InstanceFlags);
  1017. VARIANT_ENUM_CAST(VisualServer::ShadowCastingSetting);
  1018. VARIANT_ENUM_CAST(VisualServer::TextureType);
  1019. VARIANT_ENUM_CAST(VisualServer::ChangedPriority);
  1020. //typedef VisualServer VS; // makes it easier to use
  1021. #define VS VisualServer
  1022. #endif // VISUAL_SERVER_H