rendering_server.h 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757
  1. /**************************************************************************/
  2. /* rendering_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 RENDERING_SERVER_H
  31. #define RENDERING_SERVER_H
  32. #include "core/io/image.h"
  33. #include "core/math/geometry_3d.h"
  34. #include "core/math/transform_2d.h"
  35. #include "core/object/class_db.h"
  36. #include "core/templates/rid.h"
  37. #include "core/variant/typed_array.h"
  38. #include "core/variant/variant.h"
  39. #include "servers/display_server.h"
  40. #include "servers/rendering/rendering_device.h"
  41. template <typename T>
  42. class TypedArray;
  43. class RenderingServer : public Object {
  44. GDCLASS(RenderingServer, Object);
  45. static RenderingServer *singleton;
  46. int mm_policy = 0;
  47. bool render_loop_enabled = true;
  48. Array _get_array_from_surface(uint64_t p_format, Vector<uint8_t> p_vertex_data, Vector<uint8_t> p_attrib_data, Vector<uint8_t> p_skin_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len, const AABB &p_aabb, const Vector4 &p_uv_scale) const;
  49. const Vector2 SMALL_VEC2 = Vector2(CMP_EPSILON, CMP_EPSILON);
  50. const Vector3 SMALL_VEC3 = Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON);
  51. virtual TypedArray<StringName> _global_shader_parameter_get_list() const;
  52. protected:
  53. RID _make_test_cube();
  54. void _free_internal_rids();
  55. RID test_texture;
  56. RID white_texture;
  57. RID test_material;
  58. Error _surface_set_data(Array p_arrays, uint64_t p_format, uint32_t *p_offsets, uint32_t p_vertex_stride, uint32_t p_normal_stride, uint32_t p_attrib_stride, uint32_t p_skin_stride, Vector<uint8_t> &r_vertex_array, Vector<uint8_t> &r_attrib_array, Vector<uint8_t> &r_skin_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb, Vector4 &r_uv_scale);
  59. static RenderingServer *(*create_func)();
  60. static void _bind_methods();
  61. public:
  62. static RenderingServer *get_singleton();
  63. static RenderingServer *create();
  64. enum {
  65. NO_INDEX_ARRAY = -1,
  66. ARRAY_WEIGHTS_SIZE = 4,
  67. CANVAS_ITEM_Z_MIN = -4096,
  68. CANVAS_ITEM_Z_MAX = 4096,
  69. MAX_GLOW_LEVELS = 7,
  70. MAX_CURSORS = 8,
  71. MAX_2D_DIRECTIONAL_LIGHTS = 8,
  72. MAX_MESH_SURFACES = 256
  73. };
  74. /* TEXTURE API */
  75. enum TextureLayeredType {
  76. TEXTURE_LAYERED_2D_ARRAY,
  77. TEXTURE_LAYERED_CUBEMAP,
  78. TEXTURE_LAYERED_CUBEMAP_ARRAY,
  79. };
  80. enum CubeMapLayer {
  81. CUBEMAP_LAYER_LEFT,
  82. CUBEMAP_LAYER_RIGHT,
  83. CUBEMAP_LAYER_BOTTOM,
  84. CUBEMAP_LAYER_TOP,
  85. CUBEMAP_LAYER_FRONT,
  86. CUBEMAP_LAYER_BACK
  87. };
  88. virtual RID texture_2d_create(const Ref<Image> &p_image) = 0;
  89. virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, TextureLayeredType p_layered_type) = 0;
  90. virtual RID texture_3d_create(Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) = 0; //all slices, then all the mipmaps, must be coherent
  91. virtual RID texture_proxy_create(RID p_base) = 0;
  92. virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0;
  93. virtual void texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) = 0;
  94. virtual void texture_proxy_update(RID p_texture, RID p_proxy_to) = 0;
  95. // These two APIs can be used together or in combination with the others.
  96. virtual RID texture_2d_placeholder_create() = 0;
  97. virtual RID texture_2d_layered_placeholder_create(TextureLayeredType p_layered_type) = 0;
  98. virtual RID texture_3d_placeholder_create() = 0;
  99. virtual Ref<Image> texture_2d_get(RID p_texture) const = 0;
  100. virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const = 0;
  101. virtual Vector<Ref<Image>> texture_3d_get(RID p_texture) const = 0;
  102. virtual void texture_replace(RID p_texture, RID p_by_texture) = 0;
  103. virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) = 0;
  104. virtual void texture_set_path(RID p_texture, const String &p_path) = 0;
  105. virtual String texture_get_path(RID p_texture) const = 0;
  106. virtual Image::Format texture_get_format(RID p_texture) const = 0;
  107. typedef void (*TextureDetectCallback)(void *);
  108. virtual void texture_set_detect_3d_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0;
  109. virtual void texture_set_detect_normal_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0;
  110. enum TextureDetectRoughnessChannel {
  111. TEXTURE_DETECT_ROUGHNESS_R,
  112. TEXTURE_DETECT_ROUGHNESS_G,
  113. TEXTURE_DETECT_ROUGHNESS_B,
  114. TEXTURE_DETECT_ROUGHNESS_A,
  115. TEXTURE_DETECT_ROUGHNESS_GRAY,
  116. };
  117. typedef void (*TextureDetectRoughnessCallback)(void *, const String &, TextureDetectRoughnessChannel);
  118. virtual void texture_set_detect_roughness_callback(RID p_texture, TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0;
  119. struct TextureInfo {
  120. RID texture;
  121. uint32_t width;
  122. uint32_t height;
  123. uint32_t depth;
  124. Image::Format format;
  125. int bytes;
  126. String path;
  127. };
  128. virtual void texture_debug_usage(List<TextureInfo> *r_info) = 0;
  129. Array _texture_debug_usage_bind();
  130. virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0;
  131. virtual RID texture_rd_create(const RID &p_rd_texture, const RenderingServer::TextureLayeredType p_layer_type = RenderingServer::TEXTURE_LAYERED_2D_ARRAY) = 0;
  132. virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const = 0;
  133. virtual uint64_t texture_get_native_handle(RID p_texture, bool p_srgb = false) const = 0;
  134. /* SHADER API */
  135. enum ShaderMode {
  136. SHADER_SPATIAL,
  137. SHADER_CANVAS_ITEM,
  138. SHADER_PARTICLES,
  139. SHADER_SKY,
  140. SHADER_FOG,
  141. SHADER_MAX
  142. };
  143. virtual RID shader_create() = 0;
  144. virtual void shader_set_code(RID p_shader, const String &p_code) = 0;
  145. virtual void shader_set_path_hint(RID p_shader, const String &p_path) = 0;
  146. virtual String shader_get_code(RID p_shader) const = 0;
  147. virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0;
  148. virtual Variant shader_get_parameter_default(RID p_shader, const StringName &p_param) const = 0;
  149. virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index = 0) = 0;
  150. virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index = 0) const = 0;
  151. struct ShaderNativeSourceCode {
  152. struct Version {
  153. struct Stage {
  154. String name;
  155. String code;
  156. };
  157. Vector<Stage> stages;
  158. };
  159. Vector<Version> versions;
  160. };
  161. virtual ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const = 0;
  162. /* COMMON MATERIAL API */
  163. enum {
  164. MATERIAL_RENDER_PRIORITY_MIN = -128,
  165. MATERIAL_RENDER_PRIORITY_MAX = 127,
  166. };
  167. virtual RID material_create() = 0;
  168. virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0;
  169. virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0;
  170. virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0;
  171. virtual void material_set_render_priority(RID p_material, int priority) = 0;
  172. virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0;
  173. /* MESH API */
  174. enum ArrayType {
  175. ARRAY_VERTEX = 0, // RG32F (2D), RGB32F, RGBA16 (compressed)
  176. ARRAY_NORMAL = 1, // RG16
  177. ARRAY_TANGENT = 2, // BA16 (with normal) or A16 (with vertex, when compressed)
  178. ARRAY_COLOR = 3, // RGBA8
  179. ARRAY_TEX_UV = 4, // RG32F or RG16
  180. ARRAY_TEX_UV2 = 5, // RG32F or RG16
  181. ARRAY_CUSTOM0 = 6, // Depends on ArrayCustomFormat.
  182. ARRAY_CUSTOM1 = 7,
  183. ARRAY_CUSTOM2 = 8,
  184. ARRAY_CUSTOM3 = 9,
  185. ARRAY_BONES = 10, // RGBA16UI (x2 if 8 weights)
  186. ARRAY_WEIGHTS = 11, // RGBA16UNORM (x2 if 8 weights)
  187. ARRAY_INDEX = 12, // 16 or 32 bits depending on length > 0xFFFF.
  188. ARRAY_MAX = 13
  189. };
  190. enum {
  191. ARRAY_CUSTOM_COUNT = ARRAY_BONES - ARRAY_CUSTOM0
  192. };
  193. enum ArrayCustomFormat {
  194. ARRAY_CUSTOM_RGBA8_UNORM,
  195. ARRAY_CUSTOM_RGBA8_SNORM,
  196. ARRAY_CUSTOM_RG_HALF,
  197. ARRAY_CUSTOM_RGBA_HALF,
  198. ARRAY_CUSTOM_R_FLOAT,
  199. ARRAY_CUSTOM_RG_FLOAT,
  200. ARRAY_CUSTOM_RGB_FLOAT,
  201. ARRAY_CUSTOM_RGBA_FLOAT,
  202. ARRAY_CUSTOM_MAX
  203. };
  204. enum ArrayFormat : uint64_t {
  205. /* ARRAY FORMAT FLAGS */
  206. ARRAY_FORMAT_VERTEX = 1 << ARRAY_VERTEX,
  207. ARRAY_FORMAT_NORMAL = 1 << ARRAY_NORMAL,
  208. ARRAY_FORMAT_TANGENT = 1 << ARRAY_TANGENT,
  209. ARRAY_FORMAT_COLOR = 1 << ARRAY_COLOR,
  210. ARRAY_FORMAT_TEX_UV = 1 << ARRAY_TEX_UV,
  211. ARRAY_FORMAT_TEX_UV2 = 1 << ARRAY_TEX_UV2,
  212. ARRAY_FORMAT_CUSTOM0 = 1 << ARRAY_CUSTOM0,
  213. ARRAY_FORMAT_CUSTOM1 = 1 << ARRAY_CUSTOM1,
  214. ARRAY_FORMAT_CUSTOM2 = 1 << ARRAY_CUSTOM2,
  215. ARRAY_FORMAT_CUSTOM3 = 1 << ARRAY_CUSTOM3,
  216. ARRAY_FORMAT_BONES = 1 << ARRAY_BONES,
  217. ARRAY_FORMAT_WEIGHTS = 1 << ARRAY_WEIGHTS,
  218. ARRAY_FORMAT_INDEX = 1 << ARRAY_INDEX,
  219. ARRAY_FORMAT_BLEND_SHAPE_MASK = ARRAY_FORMAT_VERTEX | ARRAY_FORMAT_NORMAL | ARRAY_FORMAT_TANGENT,
  220. ARRAY_FORMAT_CUSTOM_BASE = (ARRAY_INDEX + 1),
  221. ARRAY_FORMAT_CUSTOM_BITS = 3,
  222. ARRAY_FORMAT_CUSTOM_MASK = 0x7,
  223. ARRAY_FORMAT_CUSTOM0_SHIFT = (ARRAY_FORMAT_CUSTOM_BASE + 0),
  224. ARRAY_FORMAT_CUSTOM1_SHIFT = (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS),
  225. ARRAY_FORMAT_CUSTOM2_SHIFT = (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * 2),
  226. ARRAY_FORMAT_CUSTOM3_SHIFT = (ARRAY_FORMAT_CUSTOM_BASE + ARRAY_FORMAT_CUSTOM_BITS * 3),
  227. ARRAY_COMPRESS_FLAGS_BASE = (ARRAY_INDEX + 1 + 12),
  228. ARRAY_FLAG_USE_2D_VERTICES = 1 << (ARRAY_COMPRESS_FLAGS_BASE + 0),
  229. ARRAY_FLAG_USE_DYNAMIC_UPDATE = 1 << (ARRAY_COMPRESS_FLAGS_BASE + 1),
  230. ARRAY_FLAG_USE_8_BONE_WEIGHTS = 1 << (ARRAY_COMPRESS_FLAGS_BASE + 2),
  231. ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY = 1 << (ARRAY_COMPRESS_FLAGS_BASE + 3),
  232. ARRAY_FLAG_COMPRESS_ATTRIBUTES = 1 << (ARRAY_COMPRESS_FLAGS_BASE + 4),
  233. // We leave enough room for up to 5 more compression flags.
  234. ARRAY_FLAG_FORMAT_VERSION_BASE = ARRAY_COMPRESS_FLAGS_BASE + 10,
  235. ARRAY_FLAG_FORMAT_VERSION_SHIFT = ARRAY_FLAG_FORMAT_VERSION_BASE,
  236. // When changes are made to the mesh format, add a new version and use it for the CURRENT_VERSION.
  237. ARRAY_FLAG_FORMAT_VERSION_1 = 0,
  238. ARRAY_FLAG_FORMAT_VERSION_2 = 1ULL << ARRAY_FLAG_FORMAT_VERSION_SHIFT,
  239. ARRAY_FLAG_FORMAT_CURRENT_VERSION = ARRAY_FLAG_FORMAT_VERSION_2,
  240. ARRAY_FLAG_FORMAT_VERSION_MASK = 0xFF, // 8 bits version
  241. };
  242. static_assert(sizeof(ArrayFormat) == 8, "ArrayFormat should be 64 bits long.");
  243. enum PrimitiveType {
  244. PRIMITIVE_POINTS,
  245. PRIMITIVE_LINES,
  246. PRIMITIVE_LINE_STRIP,
  247. PRIMITIVE_TRIANGLES,
  248. PRIMITIVE_TRIANGLE_STRIP,
  249. PRIMITIVE_MAX,
  250. };
  251. struct SurfaceData {
  252. PrimitiveType primitive = PRIMITIVE_MAX;
  253. uint64_t format = ARRAY_FLAG_FORMAT_CURRENT_VERSION;
  254. Vector<uint8_t> vertex_data; // Vertex, Normal, Tangent (change with skinning, blendshape).
  255. Vector<uint8_t> attribute_data; // Color, UV, UV2, Custom0-3.
  256. Vector<uint8_t> skin_data; // Bone index, Bone weight.
  257. uint32_t vertex_count = 0;
  258. Vector<uint8_t> index_data;
  259. uint32_t index_count = 0;
  260. AABB aabb;
  261. struct LOD {
  262. float edge_length = 0.0f;
  263. Vector<uint8_t> index_data;
  264. };
  265. Vector<LOD> lods;
  266. Vector<AABB> bone_aabbs;
  267. // Transforms used in runtime bone AABBs compute.
  268. // Since bone AABBs is saved in Mesh space, but bones is in Skeleton space.
  269. Transform3D mesh_to_skeleton_xform;
  270. Vector<uint8_t> blend_shape_data;
  271. Vector4 uv_scale;
  272. RID material;
  273. };
  274. virtual RID mesh_create_from_surfaces(const Vector<SurfaceData> &p_surfaces, int p_blend_shape_count = 0) = 0;
  275. virtual RID mesh_create() = 0;
  276. virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) = 0;
  277. virtual uint32_t mesh_surface_get_format_offset(BitField<ArrayFormat> p_format, int p_vertex_len, int p_array_index) const;
  278. virtual uint32_t mesh_surface_get_format_vertex_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const;
  279. virtual uint32_t mesh_surface_get_format_normal_tangent_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const;
  280. virtual uint32_t mesh_surface_get_format_attribute_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const;
  281. virtual uint32_t mesh_surface_get_format_skin_stride(BitField<ArrayFormat> p_format, int p_vertex_len) const;
  282. /// Returns stride
  283. virtual void mesh_surface_make_offsets_from_format(uint64_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets, uint32_t &r_vertex_element_size, uint32_t &r_normal_element_size, uint32_t &r_attrib_element_size, uint32_t &r_skin_element_size) const;
  284. virtual Error mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint64_t p_compress_format = 0);
  285. Array mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const;
  286. Array mesh_surface_get_arrays(RID p_mesh, int p_surface) const;
  287. TypedArray<Array> mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const;
  288. Dictionary mesh_surface_get_lods(RID p_mesh, int p_surface) const;
  289. virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), BitField<ArrayFormat> p_compress_format = 0);
  290. virtual void mesh_add_surface(RID p_mesh, const SurfaceData &p_surface) = 0;
  291. virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0;
  292. enum BlendShapeMode {
  293. BLEND_SHAPE_MODE_NORMALIZED,
  294. BLEND_SHAPE_MODE_RELATIVE,
  295. };
  296. virtual void mesh_set_blend_shape_mode(RID p_mesh, BlendShapeMode p_mode) = 0;
  297. virtual BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
  298. virtual void mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0;
  299. virtual void mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0;
  300. virtual void mesh_surface_update_skin_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0;
  301. virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
  302. virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0;
  303. virtual SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0;
  304. virtual int mesh_get_surface_count(RID p_mesh) const = 0;
  305. virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0;
  306. virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
  307. virtual void mesh_set_path(RID p_mesh, const String &p_path) = 0;
  308. virtual String mesh_get_path(RID p_mesh) const = 0;
  309. virtual void mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) = 0;
  310. virtual void mesh_clear(RID p_mesh) = 0;
  311. /* MULTIMESH API */
  312. virtual RID multimesh_create() = 0;
  313. enum MultimeshTransformFormat {
  314. MULTIMESH_TRANSFORM_2D,
  315. MULTIMESH_TRANSFORM_3D,
  316. };
  317. virtual void multimesh_allocate_data(RID p_multimesh, int p_instances, MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0;
  318. virtual int multimesh_get_instance_count(RID p_multimesh) const = 0;
  319. virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh) = 0;
  320. virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) = 0;
  321. virtual void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) = 0;
  322. virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0;
  323. virtual void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) = 0;
  324. virtual RID multimesh_get_mesh(RID p_multimesh) const = 0;
  325. virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0;
  326. virtual Transform3D multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0;
  327. virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0;
  328. virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const = 0;
  329. virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
  330. virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
  331. virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const = 0;
  332. virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
  333. virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0;
  334. /* SKELETON API */
  335. virtual RID skeleton_create() = 0;
  336. virtual void skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) = 0;
  337. virtual int skeleton_get_bone_count(RID p_skeleton) const = 0;
  338. virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform3D &p_transform) = 0;
  339. virtual Transform3D skeleton_bone_get_transform(RID p_skeleton, int p_bone) const = 0;
  340. virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) = 0;
  341. virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const = 0;
  342. virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) = 0;
  343. /* Light API */
  344. enum LightType {
  345. LIGHT_DIRECTIONAL,
  346. LIGHT_OMNI,
  347. LIGHT_SPOT
  348. };
  349. enum LightParam {
  350. LIGHT_PARAM_ENERGY,
  351. LIGHT_PARAM_INDIRECT_ENERGY,
  352. LIGHT_PARAM_VOLUMETRIC_FOG_ENERGY,
  353. LIGHT_PARAM_SPECULAR,
  354. LIGHT_PARAM_RANGE,
  355. LIGHT_PARAM_SIZE,
  356. LIGHT_PARAM_ATTENUATION,
  357. LIGHT_PARAM_SPOT_ANGLE,
  358. LIGHT_PARAM_SPOT_ATTENUATION,
  359. LIGHT_PARAM_SHADOW_MAX_DISTANCE,
  360. LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET,
  361. LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET,
  362. LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET,
  363. LIGHT_PARAM_SHADOW_FADE_START,
  364. LIGHT_PARAM_SHADOW_NORMAL_BIAS,
  365. LIGHT_PARAM_SHADOW_BIAS,
  366. LIGHT_PARAM_SHADOW_PANCAKE_SIZE,
  367. LIGHT_PARAM_SHADOW_OPACITY,
  368. LIGHT_PARAM_SHADOW_BLUR,
  369. LIGHT_PARAM_TRANSMITTANCE_BIAS,
  370. LIGHT_PARAM_INTENSITY,
  371. LIGHT_PARAM_MAX
  372. };
  373. virtual RID directional_light_create() = 0;
  374. virtual RID omni_light_create() = 0;
  375. virtual RID spot_light_create() = 0;
  376. virtual void light_set_color(RID p_light, const Color &p_color) = 0;
  377. virtual void light_set_param(RID p_light, LightParam p_param, float p_value) = 0;
  378. virtual void light_set_shadow(RID p_light, bool p_enabled) = 0;
  379. virtual void light_set_projector(RID p_light, RID p_texture) = 0;
  380. virtual void light_set_negative(RID p_light, bool p_enable) = 0;
  381. virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
  382. virtual void light_set_distance_fade(RID p_light, bool p_enabled, float p_begin, float p_shadow, float p_length) = 0;
  383. virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
  384. enum LightBakeMode {
  385. LIGHT_BAKE_DISABLED,
  386. LIGHT_BAKE_STATIC,
  387. LIGHT_BAKE_DYNAMIC,
  388. };
  389. virtual void light_set_bake_mode(RID p_light, LightBakeMode p_bake_mode) = 0;
  390. virtual void light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) = 0;
  391. // Omni light
  392. enum LightOmniShadowMode {
  393. LIGHT_OMNI_SHADOW_DUAL_PARABOLOID,
  394. LIGHT_OMNI_SHADOW_CUBE,
  395. };
  396. virtual void light_omni_set_shadow_mode(RID p_light, LightOmniShadowMode p_mode) = 0;
  397. // Directional light
  398. enum LightDirectionalShadowMode {
  399. LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL,
  400. LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS,
  401. LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS,
  402. };
  403. enum LightDirectionalSkyMode {
  404. LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_AND_SKY,
  405. LIGHT_DIRECTIONAL_SKY_MODE_LIGHT_ONLY,
  406. LIGHT_DIRECTIONAL_SKY_MODE_SKY_ONLY,
  407. };
  408. virtual void light_directional_set_shadow_mode(RID p_light, LightDirectionalShadowMode p_mode) = 0;
  409. virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) = 0;
  410. virtual void light_directional_set_sky_mode(RID p_light, LightDirectionalSkyMode p_mode) = 0;
  411. // Shadow atlas
  412. virtual RID shadow_atlas_create() = 0;
  413. virtual void shadow_atlas_set_size(RID p_atlas, int p_size, bool p_use_16_bits = true) = 0;
  414. virtual void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) = 0;
  415. virtual void directional_shadow_atlas_set_size(int p_size, bool p_16_bits = true) = 0;
  416. enum ShadowQuality {
  417. SHADOW_QUALITY_HARD,
  418. SHADOW_QUALITY_SOFT_VERY_LOW,
  419. SHADOW_QUALITY_SOFT_LOW,
  420. SHADOW_QUALITY_SOFT_MEDIUM,
  421. SHADOW_QUALITY_SOFT_HIGH,
  422. SHADOW_QUALITY_SOFT_ULTRA,
  423. SHADOW_QUALITY_MAX
  424. };
  425. virtual void positional_soft_shadow_filter_set_quality(ShadowQuality p_quality) = 0;
  426. virtual void directional_soft_shadow_filter_set_quality(ShadowQuality p_quality) = 0;
  427. enum LightProjectorFilter {
  428. LIGHT_PROJECTOR_FILTER_NEAREST,
  429. LIGHT_PROJECTOR_FILTER_LINEAR,
  430. LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS,
  431. LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS,
  432. LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS_ANISOTROPIC,
  433. LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC,
  434. };
  435. virtual void light_projectors_set_filter(LightProjectorFilter p_filter) = 0;
  436. /* PROBE API */
  437. virtual RID reflection_probe_create() = 0;
  438. enum ReflectionProbeUpdateMode {
  439. REFLECTION_PROBE_UPDATE_ONCE,
  440. REFLECTION_PROBE_UPDATE_ALWAYS,
  441. };
  442. virtual void reflection_probe_set_update_mode(RID p_probe, ReflectionProbeUpdateMode p_mode) = 0;
  443. virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0;
  444. enum ReflectionProbeAmbientMode {
  445. REFLECTION_PROBE_AMBIENT_DISABLED,
  446. REFLECTION_PROBE_AMBIENT_ENVIRONMENT,
  447. REFLECTION_PROBE_AMBIENT_COLOR,
  448. };
  449. virtual void reflection_probe_set_ambient_mode(RID p_probe, ReflectionProbeAmbientMode p_mode) = 0;
  450. virtual void reflection_probe_set_ambient_color(RID p_probe, const Color &p_color) = 0;
  451. virtual void reflection_probe_set_ambient_energy(RID p_probe, float p_energy) = 0;
  452. virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) = 0;
  453. virtual void reflection_probe_set_size(RID p_probe, const Vector3 &p_size) = 0;
  454. virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) = 0;
  455. virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) = 0;
  456. virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0;
  457. virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
  458. virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
  459. virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0;
  460. virtual void reflection_probe_set_mesh_lod_threshold(RID p_probe, float p_pixels) = 0;
  461. /* DECAL API */
  462. enum DecalTexture {
  463. DECAL_TEXTURE_ALBEDO,
  464. DECAL_TEXTURE_NORMAL,
  465. DECAL_TEXTURE_ORM,
  466. DECAL_TEXTURE_EMISSION,
  467. DECAL_TEXTURE_MAX
  468. };
  469. virtual RID decal_create() = 0;
  470. virtual void decal_set_size(RID p_decal, const Vector3 &p_size) = 0;
  471. virtual void decal_set_texture(RID p_decal, DecalTexture p_type, RID p_texture) = 0;
  472. virtual void decal_set_emission_energy(RID p_decal, float p_energy) = 0;
  473. virtual void decal_set_albedo_mix(RID p_decal, float p_mix) = 0;
  474. virtual void decal_set_modulate(RID p_decal, const Color &p_modulate) = 0;
  475. virtual void decal_set_cull_mask(RID p_decal, uint32_t p_layers) = 0;
  476. virtual void decal_set_distance_fade(RID p_decal, bool p_enabled, float p_begin, float p_length) = 0;
  477. virtual void decal_set_fade(RID p_decal, float p_above, float p_below) = 0;
  478. virtual void decal_set_normal_fade(RID p_decal, float p_fade) = 0;
  479. enum DecalFilter {
  480. DECAL_FILTER_NEAREST,
  481. DECAL_FILTER_LINEAR,
  482. DECAL_FILTER_NEAREST_MIPMAPS,
  483. DECAL_FILTER_LINEAR_MIPMAPS,
  484. DECAL_FILTER_NEAREST_MIPMAPS_ANISOTROPIC,
  485. DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC,
  486. };
  487. virtual void decals_set_filter(DecalFilter p_quality) = 0;
  488. /* VOXEL GI API */
  489. virtual RID voxel_gi_create() = 0;
  490. virtual void voxel_gi_allocate_data(RID p_voxel_gi, const Transform3D &p_to_cell_xform, const AABB &p_aabb, const Vector3i &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) = 0;
  491. virtual AABB voxel_gi_get_bounds(RID p_voxel_gi) const = 0;
  492. virtual Vector3i voxel_gi_get_octree_size(RID p_voxel_gi) const = 0;
  493. virtual Vector<uint8_t> voxel_gi_get_octree_cells(RID p_voxel_gi) const = 0;
  494. virtual Vector<uint8_t> voxel_gi_get_data_cells(RID p_voxel_gi) const = 0;
  495. virtual Vector<uint8_t> voxel_gi_get_distance_field(RID p_voxel_gi) const = 0;
  496. virtual Vector<int> voxel_gi_get_level_counts(RID p_voxel_gi) const = 0;
  497. virtual Transform3D voxel_gi_get_to_cell_xform(RID p_voxel_gi) const = 0;
  498. virtual void voxel_gi_set_dynamic_range(RID p_voxel_gi, float p_range) = 0;
  499. virtual void voxel_gi_set_propagation(RID p_voxel_gi, float p_range) = 0;
  500. virtual void voxel_gi_set_energy(RID p_voxel_gi, float p_energy) = 0;
  501. virtual void voxel_gi_set_baked_exposure_normalization(RID p_voxel_gi, float p_baked_exposure) = 0;
  502. virtual void voxel_gi_set_bias(RID p_voxel_gi, float p_bias) = 0;
  503. virtual void voxel_gi_set_normal_bias(RID p_voxel_gi, float p_range) = 0;
  504. virtual void voxel_gi_set_interior(RID p_voxel_gi, bool p_enable) = 0;
  505. virtual void voxel_gi_set_use_two_bounces(RID p_voxel_gi, bool p_enable) = 0;
  506. enum VoxelGIQuality {
  507. VOXEL_GI_QUALITY_LOW,
  508. VOXEL_GI_QUALITY_HIGH,
  509. };
  510. virtual void voxel_gi_set_quality(VoxelGIQuality) = 0;
  511. virtual void sdfgi_reset() = 0;
  512. /* LIGHTMAP */
  513. virtual RID lightmap_create() = 0;
  514. virtual void lightmap_set_textures(RID p_lightmap, RID p_light, bool p_uses_spherical_haromics) = 0;
  515. virtual void lightmap_set_probe_bounds(RID p_lightmap, const AABB &p_bounds) = 0;
  516. virtual void lightmap_set_probe_interior(RID p_lightmap, bool p_interior) = 0;
  517. virtual void lightmap_set_probe_capture_data(RID p_lightmap, const PackedVector3Array &p_points, const PackedColorArray &p_point_sh, const PackedInt32Array &p_tetrahedra, const PackedInt32Array &p_bsp_tree) = 0;
  518. virtual void lightmap_set_baked_exposure_normalization(RID p_lightmap, float p_exposure) = 0;
  519. virtual PackedVector3Array lightmap_get_probe_capture_points(RID p_lightmap) const = 0;
  520. virtual PackedColorArray lightmap_get_probe_capture_sh(RID p_lightmap) const = 0;
  521. virtual PackedInt32Array lightmap_get_probe_capture_tetrahedra(RID p_lightmap) const = 0;
  522. virtual PackedInt32Array lightmap_get_probe_capture_bsp_tree(RID p_lightmap) const = 0;
  523. virtual void lightmap_set_probe_capture_update_speed(float p_speed) = 0;
  524. /* PARTICLES API */
  525. virtual RID particles_create() = 0;
  526. enum ParticlesMode {
  527. PARTICLES_MODE_2D,
  528. PARTICLES_MODE_3D
  529. };
  530. virtual void particles_set_mode(RID p_particles, ParticlesMode p_mode) = 0;
  531. virtual void particles_set_emitting(RID p_particles, bool p_enable) = 0;
  532. virtual bool particles_get_emitting(RID p_particles) = 0;
  533. virtual void particles_set_amount(RID p_particles, int p_amount) = 0;
  534. virtual void particles_set_amount_ratio(RID p_particles, float p_amount_ratio) = 0;
  535. virtual void particles_set_lifetime(RID p_particles, double p_lifetime) = 0;
  536. virtual void particles_set_one_shot(RID p_particles, bool p_one_shot) = 0;
  537. virtual void particles_set_pre_process_time(RID p_particles, double p_time) = 0;
  538. virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0;
  539. virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0;
  540. virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0;
  541. virtual void particles_set_speed_scale(RID p_particles, double p_scale) = 0;
  542. virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0;
  543. virtual void particles_set_process_material(RID p_particles, RID p_material) = 0;
  544. virtual void particles_set_fixed_fps(RID p_particles, int p_fps) = 0;
  545. virtual void particles_set_interpolate(RID p_particles, bool p_enable) = 0;
  546. virtual void particles_set_fractional_delta(RID p_particles, bool p_enable) = 0;
  547. virtual void particles_set_collision_base_size(RID p_particles, float p_size) = 0;
  548. enum ParticlesTransformAlign {
  549. PARTICLES_TRANSFORM_ALIGN_DISABLED,
  550. PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD,
  551. PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY,
  552. PARTICLES_TRANSFORM_ALIGN_Z_BILLBOARD_Y_TO_VELOCITY,
  553. };
  554. virtual void particles_set_transform_align(RID p_particles, ParticlesTransformAlign p_transform_align) = 0;
  555. virtual void particles_set_trails(RID p_particles, bool p_enable, float p_length_sec) = 0;
  556. virtual void particles_set_trail_bind_poses(RID p_particles, const Vector<Transform3D> &p_bind_poses) = 0;
  557. virtual bool particles_is_inactive(RID p_particles) = 0;
  558. virtual void particles_request_process(RID p_particles) = 0;
  559. virtual void particles_restart(RID p_particles) = 0;
  560. virtual void particles_set_subemitter(RID p_particles, RID p_subemitter_particles) = 0;
  561. enum ParticlesEmitFlags {
  562. PARTICLES_EMIT_FLAG_POSITION = 1,
  563. PARTICLES_EMIT_FLAG_ROTATION_SCALE = 2,
  564. PARTICLES_EMIT_FLAG_VELOCITY = 4,
  565. PARTICLES_EMIT_FLAG_COLOR = 8,
  566. PARTICLES_EMIT_FLAG_CUSTOM = 16
  567. };
  568. virtual void particles_emit(RID p_particles, const Transform3D &p_transform, const Vector3 &p_velocity, const Color &p_color, const Color &p_custom, uint32_t p_emit_flags) = 0;
  569. enum ParticlesDrawOrder {
  570. PARTICLES_DRAW_ORDER_INDEX,
  571. PARTICLES_DRAW_ORDER_LIFETIME,
  572. PARTICLES_DRAW_ORDER_REVERSE_LIFETIME,
  573. PARTICLES_DRAW_ORDER_VIEW_DEPTH,
  574. };
  575. virtual void particles_set_draw_order(RID p_particles, ParticlesDrawOrder p_order) = 0;
  576. virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0;
  577. virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0;
  578. virtual AABB particles_get_current_aabb(RID p_particles) = 0;
  579. virtual void particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) = 0; // This is only used for 2D, in 3D it's automatic.
  580. virtual void particles_set_emitter_velocity(RID p_particles, const Vector3 &p_velocity) = 0;
  581. virtual void particles_set_interp_to_end(RID p_particles, float p_interp) = 0;
  582. /* PARTICLES COLLISION API */
  583. virtual RID particles_collision_create() = 0;
  584. enum ParticlesCollisionType {
  585. PARTICLES_COLLISION_TYPE_SPHERE_ATTRACT,
  586. PARTICLES_COLLISION_TYPE_BOX_ATTRACT,
  587. PARTICLES_COLLISION_TYPE_VECTOR_FIELD_ATTRACT,
  588. PARTICLES_COLLISION_TYPE_SPHERE_COLLIDE,
  589. PARTICLES_COLLISION_TYPE_BOX_COLLIDE,
  590. PARTICLES_COLLISION_TYPE_SDF_COLLIDE,
  591. PARTICLES_COLLISION_TYPE_HEIGHTFIELD_COLLIDE,
  592. };
  593. virtual void particles_collision_set_collision_type(RID p_particles_collision, ParticlesCollisionType p_type) = 0;
  594. virtual void particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) = 0;
  595. virtual void particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) = 0; // For spheres.
  596. virtual void particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) = 0; // For non-spheres.
  597. virtual void particles_collision_set_attractor_strength(RID p_particles_collision, real_t p_strength) = 0;
  598. virtual void particles_collision_set_attractor_directionality(RID p_particles_collision, real_t p_directionality) = 0;
  599. virtual void particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) = 0;
  600. virtual void particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) = 0; // For SDF and vector field, heightfield is dynamic.
  601. virtual void particles_collision_height_field_update(RID p_particles_collision) = 0; // For SDF and vector field.
  602. enum ParticlesCollisionHeightfieldResolution { // Longest axis resolution.
  603. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_256,
  604. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_512,
  605. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024,
  606. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_2048,
  607. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_4096,
  608. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_8192,
  609. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX,
  610. };
  611. virtual void particles_collision_set_height_field_resolution(RID p_particles_collision, ParticlesCollisionHeightfieldResolution p_resolution) = 0; // For SDF and vector field.
  612. /* FOG VOLUME API */
  613. virtual RID fog_volume_create() = 0;
  614. enum FogVolumeShape {
  615. FOG_VOLUME_SHAPE_ELLIPSOID,
  616. FOG_VOLUME_SHAPE_CONE,
  617. FOG_VOLUME_SHAPE_CYLINDER,
  618. FOG_VOLUME_SHAPE_BOX,
  619. FOG_VOLUME_SHAPE_WORLD,
  620. FOG_VOLUME_SHAPE_MAX,
  621. };
  622. virtual void fog_volume_set_shape(RID p_fog_volume, FogVolumeShape p_shape) = 0;
  623. virtual void fog_volume_set_size(RID p_fog_volume, const Vector3 &p_size) = 0;
  624. virtual void fog_volume_set_material(RID p_fog_volume, RID p_material) = 0;
  625. /* VISIBILITY NOTIFIER API */
  626. virtual RID visibility_notifier_create() = 0;
  627. virtual void visibility_notifier_set_aabb(RID p_notifier, const AABB &p_aabb) = 0;
  628. virtual void visibility_notifier_set_callbacks(RID p_notifier, const Callable &p_enter_callbable, const Callable &p_exit_callable) = 0;
  629. /* OCCLUDER API */
  630. virtual RID occluder_create() = 0;
  631. virtual void occluder_set_mesh(RID p_occluder, const PackedVector3Array &p_vertices, const PackedInt32Array &p_indices) = 0;
  632. /* CAMERA API */
  633. virtual RID camera_create() = 0;
  634. virtual void camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) = 0;
  635. virtual void camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) = 0;
  636. virtual void camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) = 0;
  637. virtual void camera_set_transform(RID p_camera, const Transform3D &p_transform) = 0;
  638. virtual void camera_set_cull_mask(RID p_camera, uint32_t p_layers) = 0;
  639. virtual void camera_set_environment(RID p_camera, RID p_env) = 0;
  640. virtual void camera_set_camera_attributes(RID p_camera, RID p_camera_attributes) = 0;
  641. virtual void camera_set_use_vertical_aspect(RID p_camera, bool p_enable) = 0;
  642. /* VIEWPORT API */
  643. enum CanvasItemTextureFilter {
  644. CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, // Uses canvas item setting for draw command, uses global setting for canvas item.
  645. CANVAS_ITEM_TEXTURE_FILTER_NEAREST,
  646. CANVAS_ITEM_TEXTURE_FILTER_LINEAR,
  647. CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS,
  648. CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS,
  649. CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC,
  650. CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC,
  651. CANVAS_ITEM_TEXTURE_FILTER_MAX
  652. };
  653. enum CanvasItemTextureRepeat {
  654. CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, // Uses canvas item setting for draw command, uses global setting for canvas item.
  655. CANVAS_ITEM_TEXTURE_REPEAT_DISABLED,
  656. CANVAS_ITEM_TEXTURE_REPEAT_ENABLED,
  657. CANVAS_ITEM_TEXTURE_REPEAT_MIRROR,
  658. CANVAS_ITEM_TEXTURE_REPEAT_MAX,
  659. };
  660. virtual RID viewport_create() = 0;
  661. enum ViewportScaling3DMode {
  662. VIEWPORT_SCALING_3D_MODE_BILINEAR,
  663. VIEWPORT_SCALING_3D_MODE_FSR,
  664. VIEWPORT_SCALING_3D_MODE_FSR2,
  665. VIEWPORT_SCALING_3D_MODE_MAX,
  666. VIEWPORT_SCALING_3D_MODE_OFF = 255, // for internal use only
  667. };
  668. virtual void viewport_set_use_xr(RID p_viewport, bool p_use_xr) = 0;
  669. virtual void viewport_set_size(RID p_viewport, int p_width, int p_height) = 0;
  670. virtual void viewport_set_active(RID p_viewport, bool p_active) = 0;
  671. virtual void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) = 0;
  672. virtual void viewport_set_canvas_cull_mask(RID p_viewport, uint32_t p_canvas_cull_mask) = 0;
  673. virtual void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), DisplayServer::WindowID p_screen = DisplayServer::MAIN_WINDOW_ID) = 0;
  674. virtual void viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) = 0;
  675. virtual void viewport_set_scaling_3d_mode(RID p_viewport, ViewportScaling3DMode p_scaling_3d_mode) = 0;
  676. virtual void viewport_set_scaling_3d_scale(RID p_viewport, float p_scaling_3d_scale) = 0;
  677. virtual void viewport_set_fsr_sharpness(RID p_viewport, float p_fsr_sharpness) = 0;
  678. virtual void viewport_set_texture_mipmap_bias(RID p_viewport, float p_texture_mipmap_bias) = 0;
  679. enum ViewportUpdateMode {
  680. VIEWPORT_UPDATE_DISABLED,
  681. VIEWPORT_UPDATE_ONCE, // Then goes to disabled, must be manually updated.
  682. VIEWPORT_UPDATE_WHEN_VISIBLE, // Default
  683. VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE,
  684. VIEWPORT_UPDATE_ALWAYS
  685. };
  686. virtual void viewport_set_update_mode(RID p_viewport, ViewportUpdateMode p_mode) = 0;
  687. enum ViewportClearMode {
  688. VIEWPORT_CLEAR_ALWAYS,
  689. VIEWPORT_CLEAR_NEVER,
  690. VIEWPORT_CLEAR_ONLY_NEXT_FRAME
  691. };
  692. virtual void viewport_set_clear_mode(RID p_viewport, ViewportClearMode p_clear_mode) = 0;
  693. virtual RID viewport_get_render_target(RID p_viewport) const = 0;
  694. virtual RID viewport_get_texture(RID p_viewport) const = 0;
  695. enum ViewportEnvironmentMode {
  696. VIEWPORT_ENVIRONMENT_DISABLED,
  697. VIEWPORT_ENVIRONMENT_ENABLED,
  698. VIEWPORT_ENVIRONMENT_INHERIT,
  699. VIEWPORT_ENVIRONMENT_MAX,
  700. };
  701. virtual void viewport_set_environment_mode(RID p_viewport, ViewportEnvironmentMode p_mode) = 0;
  702. virtual void viewport_set_disable_3d(RID p_viewport, bool p_disable) = 0;
  703. virtual void viewport_set_disable_2d(RID p_viewport, bool p_disable) = 0;
  704. virtual void viewport_attach_camera(RID p_viewport, RID p_camera) = 0;
  705. virtual void viewport_set_scenario(RID p_viewport, RID p_scenario) = 0;
  706. virtual void viewport_attach_canvas(RID p_viewport, RID p_canvas) = 0;
  707. virtual void viewport_remove_canvas(RID p_viewport, RID p_canvas) = 0;
  708. virtual void viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) = 0;
  709. virtual void viewport_set_transparent_background(RID p_viewport, bool p_enabled) = 0;
  710. virtual void viewport_set_use_hdr_2d(RID p_viewport, bool p_use_hdr) = 0;
  711. virtual void viewport_set_snap_2d_transforms_to_pixel(RID p_viewport, bool p_enabled) = 0;
  712. virtual void viewport_set_snap_2d_vertices_to_pixel(RID p_viewport, bool p_enabled) = 0;
  713. virtual void viewport_set_default_canvas_item_texture_filter(RID p_viewport, CanvasItemTextureFilter p_filter) = 0;
  714. virtual void viewport_set_default_canvas_item_texture_repeat(RID p_viewport, CanvasItemTextureRepeat p_repeat) = 0;
  715. virtual void viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) = 0;
  716. virtual void viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) = 0;
  717. enum ViewportSDFOversize {
  718. VIEWPORT_SDF_OVERSIZE_100_PERCENT,
  719. VIEWPORT_SDF_OVERSIZE_120_PERCENT,
  720. VIEWPORT_SDF_OVERSIZE_150_PERCENT,
  721. VIEWPORT_SDF_OVERSIZE_200_PERCENT,
  722. VIEWPORT_SDF_OVERSIZE_MAX
  723. };
  724. enum ViewportSDFScale {
  725. VIEWPORT_SDF_SCALE_100_PERCENT,
  726. VIEWPORT_SDF_SCALE_50_PERCENT,
  727. VIEWPORT_SDF_SCALE_25_PERCENT,
  728. VIEWPORT_SDF_SCALE_MAX
  729. };
  730. virtual void viewport_set_sdf_oversize_and_scale(RID p_viewport, ViewportSDFOversize p_oversize, ViewportSDFScale p_scale) = 0;
  731. virtual void viewport_set_positional_shadow_atlas_size(RID p_viewport, int p_size, bool p_16_bits = true) = 0;
  732. virtual void viewport_set_positional_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) = 0;
  733. enum ViewportMSAA {
  734. VIEWPORT_MSAA_DISABLED,
  735. VIEWPORT_MSAA_2X,
  736. VIEWPORT_MSAA_4X,
  737. VIEWPORT_MSAA_8X,
  738. VIEWPORT_MSAA_MAX,
  739. };
  740. virtual void viewport_set_msaa_3d(RID p_viewport, ViewportMSAA p_msaa) = 0;
  741. virtual void viewport_set_msaa_2d(RID p_viewport, ViewportMSAA p_msaa) = 0;
  742. enum ViewportScreenSpaceAA {
  743. VIEWPORT_SCREEN_SPACE_AA_DISABLED,
  744. VIEWPORT_SCREEN_SPACE_AA_FXAA,
  745. VIEWPORT_SCREEN_SPACE_AA_MAX,
  746. };
  747. virtual void viewport_set_screen_space_aa(RID p_viewport, ViewportScreenSpaceAA p_mode) = 0;
  748. virtual void viewport_set_use_taa(RID p_viewport, bool p_use_taa) = 0;
  749. virtual void viewport_set_use_debanding(RID p_viewport, bool p_use_debanding) = 0;
  750. virtual void viewport_set_mesh_lod_threshold(RID p_viewport, float p_pixels) = 0;
  751. virtual void viewport_set_use_occlusion_culling(RID p_viewport, bool p_use_occlusion_culling) = 0;
  752. virtual void viewport_set_occlusion_rays_per_thread(int p_rays_per_thread) = 0;
  753. enum ViewportOcclusionCullingBuildQuality {
  754. VIEWPORT_OCCLUSION_BUILD_QUALITY_LOW = 0,
  755. VIEWPORT_OCCLUSION_BUILD_QUALITY_MEDIUM = 1,
  756. VIEWPORT_OCCLUSION_BUILD_QUALITY_HIGH = 2,
  757. };
  758. virtual void viewport_set_occlusion_culling_build_quality(ViewportOcclusionCullingBuildQuality p_quality) = 0;
  759. enum ViewportRenderInfo {
  760. VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME,
  761. VIEWPORT_RENDER_INFO_PRIMITIVES_IN_FRAME,
  762. VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME,
  763. VIEWPORT_RENDER_INFO_MAX,
  764. };
  765. enum ViewportRenderInfoType {
  766. VIEWPORT_RENDER_INFO_TYPE_VISIBLE,
  767. VIEWPORT_RENDER_INFO_TYPE_SHADOW,
  768. VIEWPORT_RENDER_INFO_TYPE_MAX
  769. };
  770. virtual int viewport_get_render_info(RID p_viewport, ViewportRenderInfoType p_type, ViewportRenderInfo p_info) = 0;
  771. enum ViewportDebugDraw {
  772. VIEWPORT_DEBUG_DRAW_DISABLED,
  773. VIEWPORT_DEBUG_DRAW_UNSHADED,
  774. VIEWPORT_DEBUG_DRAW_LIGHTING,
  775. VIEWPORT_DEBUG_DRAW_OVERDRAW,
  776. VIEWPORT_DEBUG_DRAW_WIREFRAME,
  777. VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER,
  778. VIEWPORT_DEBUG_DRAW_VOXEL_GI_ALBEDO,
  779. VIEWPORT_DEBUG_DRAW_VOXEL_GI_LIGHTING,
  780. VIEWPORT_DEBUG_DRAW_VOXEL_GI_EMISSION,
  781. VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS,
  782. VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
  783. VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE,
  784. VIEWPORT_DEBUG_DRAW_SSAO,
  785. VIEWPORT_DEBUG_DRAW_SSIL,
  786. VIEWPORT_DEBUG_DRAW_PSSM_SPLITS,
  787. VIEWPORT_DEBUG_DRAW_DECAL_ATLAS,
  788. VIEWPORT_DEBUG_DRAW_SDFGI,
  789. VIEWPORT_DEBUG_DRAW_SDFGI_PROBES,
  790. VIEWPORT_DEBUG_DRAW_GI_BUFFER,
  791. VIEWPORT_DEBUG_DRAW_DISABLE_LOD,
  792. VIEWPORT_DEBUG_DRAW_CLUSTER_OMNI_LIGHTS,
  793. VIEWPORT_DEBUG_DRAW_CLUSTER_SPOT_LIGHTS,
  794. VIEWPORT_DEBUG_DRAW_CLUSTER_DECALS,
  795. VIEWPORT_DEBUG_DRAW_CLUSTER_REFLECTION_PROBES,
  796. VIEWPORT_DEBUG_DRAW_OCCLUDERS,
  797. VIEWPORT_DEBUG_DRAW_MOTION_VECTORS,
  798. VIEWPORT_DEBUG_DRAW_INTERNAL_BUFFER,
  799. };
  800. virtual void viewport_set_debug_draw(RID p_viewport, ViewportDebugDraw p_draw) = 0;
  801. virtual void viewport_set_measure_render_time(RID p_viewport, bool p_enable) = 0;
  802. virtual double viewport_get_measured_render_time_cpu(RID p_viewport) const = 0;
  803. virtual double viewport_get_measured_render_time_gpu(RID p_viewport) const = 0;
  804. virtual RID viewport_find_from_screen_attachment(DisplayServer::WindowID p_id = DisplayServer::MAIN_WINDOW_ID) const = 0;
  805. enum ViewportVRSMode {
  806. VIEWPORT_VRS_DISABLED,
  807. VIEWPORT_VRS_TEXTURE,
  808. VIEWPORT_VRS_XR,
  809. VIEWPORT_VRS_MAX,
  810. };
  811. virtual void viewport_set_vrs_mode(RID p_viewport, ViewportVRSMode p_mode) = 0;
  812. virtual void viewport_set_vrs_texture(RID p_viewport, RID p_texture) = 0;
  813. /* SKY API */
  814. enum SkyMode {
  815. SKY_MODE_AUTOMATIC,
  816. SKY_MODE_QUALITY,
  817. SKY_MODE_INCREMENTAL,
  818. SKY_MODE_REALTIME
  819. };
  820. virtual RID sky_create() = 0;
  821. virtual void sky_set_radiance_size(RID p_sky, int p_radiance_size) = 0;
  822. virtual void sky_set_mode(RID p_sky, SkyMode p_mode) = 0;
  823. virtual void sky_set_material(RID p_sky, RID p_material) = 0;
  824. virtual Ref<Image> sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) = 0;
  825. /* ENVIRONMENT API */
  826. virtual RID environment_create() = 0;
  827. enum EnvironmentBG {
  828. ENV_BG_CLEAR_COLOR,
  829. ENV_BG_COLOR,
  830. ENV_BG_SKY,
  831. ENV_BG_CANVAS,
  832. ENV_BG_KEEP,
  833. ENV_BG_CAMERA_FEED,
  834. ENV_BG_MAX
  835. };
  836. enum EnvironmentAmbientSource {
  837. ENV_AMBIENT_SOURCE_BG,
  838. ENV_AMBIENT_SOURCE_DISABLED,
  839. ENV_AMBIENT_SOURCE_COLOR,
  840. ENV_AMBIENT_SOURCE_SKY,
  841. };
  842. enum EnvironmentReflectionSource {
  843. ENV_REFLECTION_SOURCE_BG,
  844. ENV_REFLECTION_SOURCE_DISABLED,
  845. ENV_REFLECTION_SOURCE_SKY,
  846. };
  847. virtual void environment_set_background(RID p_env, EnvironmentBG p_bg) = 0;
  848. virtual void environment_set_sky(RID p_env, RID p_sky) = 0;
  849. virtual void environment_set_sky_custom_fov(RID p_env, float p_scale) = 0;
  850. virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) = 0;
  851. virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0;
  852. virtual void environment_set_bg_energy(RID p_env, float p_multiplier, float p_exposure_value) = 0;
  853. virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0;
  854. virtual void environment_set_ambient_light(RID p_env, const Color &p_color, EnvironmentAmbientSource p_ambient = ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, EnvironmentReflectionSource p_reflection_source = ENV_REFLECTION_SOURCE_BG) = 0;
  855. enum EnvironmentGlowBlendMode {
  856. ENV_GLOW_BLEND_MODE_ADDITIVE,
  857. ENV_GLOW_BLEND_MODE_SCREEN,
  858. ENV_GLOW_BLEND_MODE_SOFTLIGHT,
  859. ENV_GLOW_BLEND_MODE_REPLACE,
  860. ENV_GLOW_BLEND_MODE_MIX,
  861. };
  862. virtual void environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, float p_glow_map_strength, RID p_glow_map) = 0;
  863. virtual void environment_glow_set_use_bicubic_upscale(bool p_enable) = 0;
  864. enum EnvironmentToneMapper {
  865. ENV_TONE_MAPPER_LINEAR,
  866. ENV_TONE_MAPPER_REINHARD,
  867. ENV_TONE_MAPPER_FILMIC,
  868. ENV_TONE_MAPPER_ACES
  869. };
  870. virtual void environment_set_tonemap(RID p_env, EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white) = 0;
  871. virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) = 0;
  872. 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) = 0;
  873. enum EnvironmentSSRRoughnessQuality {
  874. ENV_SSR_ROUGHNESS_QUALITY_DISABLED,
  875. ENV_SSR_ROUGHNESS_QUALITY_LOW,
  876. ENV_SSR_ROUGHNESS_QUALITY_MEDIUM,
  877. ENV_SSR_ROUGHNESS_QUALITY_HIGH,
  878. };
  879. virtual void environment_set_ssr_roughness_quality(EnvironmentSSRRoughnessQuality p_quality) = 0;
  880. virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) = 0;
  881. enum EnvironmentSSAOQuality {
  882. ENV_SSAO_QUALITY_VERY_LOW,
  883. ENV_SSAO_QUALITY_LOW,
  884. ENV_SSAO_QUALITY_MEDIUM,
  885. ENV_SSAO_QUALITY_HIGH,
  886. ENV_SSAO_QUALITY_ULTRA,
  887. };
  888. virtual void environment_set_ssao_quality(EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) = 0;
  889. virtual void environment_set_ssil(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_sharpness, float p_normal_rejection) = 0;
  890. enum EnvironmentSSILQuality {
  891. ENV_SSIL_QUALITY_VERY_LOW,
  892. ENV_SSIL_QUALITY_LOW,
  893. ENV_SSIL_QUALITY_MEDIUM,
  894. ENV_SSIL_QUALITY_HIGH,
  895. ENV_SSIL_QUALITY_ULTRA,
  896. };
  897. virtual void environment_set_ssil_quality(EnvironmentSSILQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) = 0;
  898. enum EnvironmentSDFGIYScale {
  899. ENV_SDFGI_Y_SCALE_50_PERCENT,
  900. ENV_SDFGI_Y_SCALE_75_PERCENT,
  901. ENV_SDFGI_Y_SCALE_100_PERCENT,
  902. };
  903. virtual void environment_set_sdfgi(RID p_env, bool p_enable, int p_cascades, float p_min_cell_size, EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) = 0;
  904. enum EnvironmentSDFGIRayCount {
  905. ENV_SDFGI_RAY_COUNT_4,
  906. ENV_SDFGI_RAY_COUNT_8,
  907. ENV_SDFGI_RAY_COUNT_16,
  908. ENV_SDFGI_RAY_COUNT_32,
  909. ENV_SDFGI_RAY_COUNT_64,
  910. ENV_SDFGI_RAY_COUNT_96,
  911. ENV_SDFGI_RAY_COUNT_128,
  912. ENV_SDFGI_RAY_COUNT_MAX,
  913. };
  914. virtual void environment_set_sdfgi_ray_count(EnvironmentSDFGIRayCount p_ray_count) = 0;
  915. enum EnvironmentSDFGIFramesToConverge {
  916. ENV_SDFGI_CONVERGE_IN_5_FRAMES,
  917. ENV_SDFGI_CONVERGE_IN_10_FRAMES,
  918. ENV_SDFGI_CONVERGE_IN_15_FRAMES,
  919. ENV_SDFGI_CONVERGE_IN_20_FRAMES,
  920. ENV_SDFGI_CONVERGE_IN_25_FRAMES,
  921. ENV_SDFGI_CONVERGE_IN_30_FRAMES,
  922. ENV_SDFGI_CONVERGE_MAX
  923. };
  924. virtual void environment_set_sdfgi_frames_to_converge(EnvironmentSDFGIFramesToConverge p_frames) = 0;
  925. enum EnvironmentSDFGIFramesToUpdateLight {
  926. ENV_SDFGI_UPDATE_LIGHT_IN_1_FRAME,
  927. ENV_SDFGI_UPDATE_LIGHT_IN_2_FRAMES,
  928. ENV_SDFGI_UPDATE_LIGHT_IN_4_FRAMES,
  929. ENV_SDFGI_UPDATE_LIGHT_IN_8_FRAMES,
  930. ENV_SDFGI_UPDATE_LIGHT_IN_16_FRAMES,
  931. ENV_SDFGI_UPDATE_LIGHT_MAX,
  932. };
  933. virtual void environment_set_sdfgi_frames_to_update_light(EnvironmentSDFGIFramesToUpdateLight p_update) = 0;
  934. virtual void environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective, float p_sky_affect) = 0;
  935. virtual void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_albedo, const Color &p_emission, float p_emission_energy, float p_anisotropy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount, float p_ambient_inject, float p_sky_affect) = 0;
  936. virtual void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) = 0;
  937. virtual void environment_set_volumetric_fog_filter_active(bool p_enable) = 0;
  938. virtual Ref<Image> environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) = 0;
  939. virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_limit) = 0;
  940. enum SubSurfaceScatteringQuality {
  941. SUB_SURFACE_SCATTERING_QUALITY_DISABLED,
  942. SUB_SURFACE_SCATTERING_QUALITY_LOW,
  943. SUB_SURFACE_SCATTERING_QUALITY_MEDIUM,
  944. SUB_SURFACE_SCATTERING_QUALITY_HIGH,
  945. };
  946. virtual void sub_surface_scattering_set_quality(SubSurfaceScatteringQuality p_quality) = 0;
  947. virtual void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) = 0;
  948. /* CAMERA EFFECTS */
  949. virtual RID camera_attributes_create() = 0;
  950. enum DOFBlurQuality {
  951. DOF_BLUR_QUALITY_VERY_LOW,
  952. DOF_BLUR_QUALITY_LOW,
  953. DOF_BLUR_QUALITY_MEDIUM,
  954. DOF_BLUR_QUALITY_HIGH,
  955. };
  956. virtual void camera_attributes_set_dof_blur_quality(DOFBlurQuality p_quality, bool p_use_jitter) = 0;
  957. enum DOFBokehShape {
  958. DOF_BOKEH_BOX,
  959. DOF_BOKEH_HEXAGON,
  960. DOF_BOKEH_CIRCLE
  961. };
  962. virtual void camera_attributes_set_dof_blur_bokeh_shape(DOFBokehShape p_shape) = 0;
  963. virtual void camera_attributes_set_dof_blur(RID p_camera_attributes, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) = 0;
  964. virtual void camera_attributes_set_exposure(RID p_camera_attributes, float p_multiplier, float p_exposure_normalization) = 0;
  965. virtual void camera_attributes_set_auto_exposure(RID p_camera_attributes, bool p_enable, float p_min_sensitivity, float p_max_sensitivity, float p_speed, float p_scale) = 0;
  966. /* SCENARIO API */
  967. virtual RID scenario_create() = 0;
  968. virtual void scenario_set_environment(RID p_scenario, RID p_environment) = 0;
  969. virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment) = 0;
  970. virtual void scenario_set_camera_attributes(RID p_scenario, RID p_camera_attributes) = 0;
  971. /* INSTANCING API */
  972. enum InstanceType {
  973. INSTANCE_NONE,
  974. INSTANCE_MESH,
  975. INSTANCE_MULTIMESH,
  976. INSTANCE_PARTICLES,
  977. INSTANCE_PARTICLES_COLLISION,
  978. INSTANCE_LIGHT,
  979. INSTANCE_REFLECTION_PROBE,
  980. INSTANCE_DECAL,
  981. INSTANCE_VOXEL_GI,
  982. INSTANCE_LIGHTMAP,
  983. INSTANCE_OCCLUDER,
  984. INSTANCE_VISIBLITY_NOTIFIER,
  985. INSTANCE_FOG_VOLUME,
  986. INSTANCE_MAX,
  987. INSTANCE_GEOMETRY_MASK = (1 << INSTANCE_MESH) | (1 << INSTANCE_MULTIMESH) | (1 << INSTANCE_PARTICLES)
  988. };
  989. virtual RID instance_create2(RID p_base, RID p_scenario);
  990. virtual RID instance_create() = 0;
  991. virtual void instance_set_base(RID p_instance, RID p_base) = 0;
  992. virtual void instance_set_scenario(RID p_instance, RID p_scenario) = 0;
  993. virtual void instance_set_layer_mask(RID p_instance, uint32_t p_mask) = 0;
  994. virtual void instance_set_pivot_data(RID p_instance, float p_sorting_offset, bool p_use_aabb_center) = 0;
  995. virtual void instance_set_transform(RID p_instance, const Transform3D &p_transform) = 0;
  996. virtual void instance_attach_object_instance_id(RID p_instance, ObjectID p_id) = 0;
  997. virtual void instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) = 0;
  998. virtual void instance_set_surface_override_material(RID p_instance, int p_surface, RID p_material) = 0;
  999. virtual void instance_set_visible(RID p_instance, bool p_visible) = 0;
  1000. virtual void instance_set_custom_aabb(RID p_instance, AABB aabb) = 0;
  1001. virtual void instance_attach_skeleton(RID p_instance, RID p_skeleton) = 0;
  1002. virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0;
  1003. virtual void instance_set_visibility_parent(RID p_instance, RID p_parent_instance) = 0;
  1004. virtual void instance_set_ignore_culling(RID p_instance, bool p_enabled) = 0;
  1005. // Don't use these in a game!
  1006. virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const = 0;
  1007. virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0;
  1008. virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0;
  1009. PackedInt64Array _instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario = RID()) const;
  1010. PackedInt64Array _instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const;
  1011. PackedInt64Array _instances_cull_convex_bind(const TypedArray<Plane> &p_convex, RID p_scenario = RID()) const;
  1012. enum InstanceFlags {
  1013. INSTANCE_FLAG_USE_BAKED_LIGHT,
  1014. INSTANCE_FLAG_USE_DYNAMIC_GI,
  1015. INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE,
  1016. INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING,
  1017. INSTANCE_FLAG_MAX
  1018. };
  1019. enum ShadowCastingSetting {
  1020. SHADOW_CASTING_SETTING_OFF,
  1021. SHADOW_CASTING_SETTING_ON,
  1022. SHADOW_CASTING_SETTING_DOUBLE_SIDED,
  1023. SHADOW_CASTING_SETTING_SHADOWS_ONLY,
  1024. };
  1025. enum VisibilityRangeFadeMode {
  1026. VISIBILITY_RANGE_FADE_DISABLED,
  1027. VISIBILITY_RANGE_FADE_SELF,
  1028. VISIBILITY_RANGE_FADE_DEPENDENCIES,
  1029. };
  1030. virtual void instance_geometry_set_flag(RID p_instance, InstanceFlags p_flags, bool p_enabled) = 0;
  1031. virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, ShadowCastingSetting p_shadow_casting_setting) = 0;
  1032. virtual void instance_geometry_set_material_override(RID p_instance, RID p_material) = 0;
  1033. virtual void instance_geometry_set_material_overlay(RID p_instance, RID p_material) = 0;
  1034. virtual void instance_geometry_set_visibility_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin, VisibilityRangeFadeMode p_fade_mode) = 0;
  1035. virtual void instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice) = 0;
  1036. virtual void instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) = 0;
  1037. virtual void instance_geometry_set_transparency(RID p_instance, float p_transparency) = 0;
  1038. virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &, const Variant &p_value) = 0;
  1039. virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &) const = 0;
  1040. virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &) const = 0;
  1041. virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0;
  1042. /* Bake 3D objects */
  1043. enum BakeChannels {
  1044. BAKE_CHANNEL_ALBEDO_ALPHA,
  1045. BAKE_CHANNEL_NORMAL,
  1046. BAKE_CHANNEL_ORM,
  1047. BAKE_CHANNEL_EMISSION
  1048. };
  1049. virtual TypedArray<Image> bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size) = 0;
  1050. /* CANVAS (2D) */
  1051. virtual RID canvas_create() = 0;
  1052. virtual void canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) = 0;
  1053. virtual void canvas_set_modulate(RID p_canvas, const Color &p_color) = 0;
  1054. virtual void canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) = 0;
  1055. virtual void canvas_set_disable_scale(bool p_disable) = 0;
  1056. /* CANVAS TEXTURE */
  1057. virtual RID canvas_texture_create() = 0;
  1058. enum CanvasTextureChannel {
  1059. CANVAS_TEXTURE_CHANNEL_DIFFUSE,
  1060. CANVAS_TEXTURE_CHANNEL_NORMAL,
  1061. CANVAS_TEXTURE_CHANNEL_SPECULAR,
  1062. };
  1063. virtual void canvas_texture_set_channel(RID p_canvas_texture, CanvasTextureChannel p_channel, RID p_texture) = 0;
  1064. virtual void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) = 0;
  1065. // Takes effect only for new draw commands.
  1066. virtual void canvas_texture_set_texture_filter(RID p_canvas_texture, CanvasItemTextureFilter p_filter) = 0;
  1067. virtual void canvas_texture_set_texture_repeat(RID p_canvas_texture, CanvasItemTextureRepeat p_repeat) = 0;
  1068. /* CANVAS ITEM */
  1069. virtual RID canvas_item_create() = 0;
  1070. virtual void canvas_item_set_parent(RID p_item, RID p_parent) = 0;
  1071. virtual void canvas_item_set_default_texture_filter(RID p_item, CanvasItemTextureFilter p_filter) = 0;
  1072. virtual void canvas_item_set_default_texture_repeat(RID p_item, CanvasItemTextureRepeat p_repeat) = 0;
  1073. virtual void canvas_item_set_visible(RID p_item, bool p_visible) = 0;
  1074. virtual void canvas_item_set_light_mask(RID p_item, int p_mask) = 0;
  1075. virtual void canvas_item_set_update_when_visible(RID p_item, bool p_update) = 0;
  1076. virtual void canvas_item_set_transform(RID p_item, const Transform2D &p_transform) = 0;
  1077. virtual void canvas_item_set_clip(RID p_item, bool p_clip) = 0;
  1078. virtual void canvas_item_set_distance_field_mode(RID p_item, bool p_enable) = 0;
  1079. virtual void canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect = Rect2()) = 0;
  1080. virtual void canvas_item_set_modulate(RID p_item, const Color &p_color) = 0;
  1081. virtual void canvas_item_set_self_modulate(RID p_item, const Color &p_color) = 0;
  1082. virtual void canvas_item_set_visibility_layer(RID p_item, uint32_t p_visibility_layer) = 0;
  1083. virtual void canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) = 0;
  1084. enum NinePatchAxisMode {
  1085. NINE_PATCH_STRETCH,
  1086. NINE_PATCH_TILE,
  1087. NINE_PATCH_TILE_FIT,
  1088. };
  1089. 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;
  1090. 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;
  1091. virtual void canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = -1.0) = 0;
  1092. virtual void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) = 0;
  1093. virtual void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) = 0;
  1094. 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) = 0;
  1095. 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, bool p_clip_uv = false) = 0;
  1096. virtual void canvas_item_add_msdf_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), int p_outline_size = 0, float p_px_range = 1.0, float p_scale = 1.0) = 0;
  1097. virtual void canvas_item_add_lcd_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)) = 0;
  1098. 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)) = 0;
  1099. 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) = 0;
  1100. 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()) = 0;
  1101. 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) = 0;
  1102. 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()) = 0;
  1103. virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID()) = 0;
  1104. virtual void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture) = 0;
  1105. virtual void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) = 0;
  1106. virtual void canvas_item_add_clip_ignore(RID p_item, bool p_ignore) = 0;
  1107. virtual void canvas_item_add_animation_slice(RID p_item, double p_animation_length, double p_slice_begin, double p_slice_end, double p_offset) = 0;
  1108. virtual void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) = 0;
  1109. virtual void canvas_item_set_z_index(RID p_item, int p_z) = 0;
  1110. virtual void canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) = 0;
  1111. virtual void canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) = 0;
  1112. virtual void canvas_item_attach_skeleton(RID p_item, RID p_skeleton) = 0;
  1113. virtual void canvas_item_clear(RID p_item) = 0;
  1114. virtual void canvas_item_set_draw_index(RID p_item, int p_index) = 0;
  1115. virtual void canvas_item_set_material(RID p_item, RID p_material) = 0;
  1116. virtual void canvas_item_set_use_parent_material(RID p_item, bool p_enable) = 0;
  1117. virtual void canvas_item_set_visibility_notifier(RID p_item, bool p_enable, const Rect2 &p_area, const Callable &p_enter_callbable, const Callable &p_exit_callable) = 0;
  1118. enum CanvasGroupMode {
  1119. CANVAS_GROUP_MODE_DISABLED,
  1120. CANVAS_GROUP_MODE_CLIP_ONLY,
  1121. CANVAS_GROUP_MODE_CLIP_AND_DRAW,
  1122. CANVAS_GROUP_MODE_TRANSPARENT,
  1123. };
  1124. virtual void canvas_item_set_canvas_group_mode(RID p_item, CanvasGroupMode p_mode, float p_clear_margin = 5.0, bool p_fit_empty = false, float p_fit_margin = 0.0, bool p_blur_mipmaps = false) = 0;
  1125. virtual void canvas_item_set_debug_redraw(bool p_enabled) = 0;
  1126. virtual bool canvas_item_get_debug_redraw() const = 0;
  1127. /* CANVAS LIGHT */
  1128. virtual RID canvas_light_create() = 0;
  1129. enum CanvasLightMode {
  1130. CANVAS_LIGHT_MODE_POINT,
  1131. CANVAS_LIGHT_MODE_DIRECTIONAL,
  1132. };
  1133. virtual void canvas_light_set_mode(RID p_light, CanvasLightMode p_mode) = 0;
  1134. virtual void canvas_light_attach_to_canvas(RID p_light, RID p_canvas) = 0;
  1135. virtual void canvas_light_set_enabled(RID p_light, bool p_enabled) = 0;
  1136. virtual void canvas_light_set_transform(RID p_light, const Transform2D &p_transform) = 0;
  1137. virtual void canvas_light_set_color(RID p_light, const Color &p_color) = 0;
  1138. virtual void canvas_light_set_height(RID p_light, float p_height) = 0;
  1139. virtual void canvas_light_set_energy(RID p_light, float p_energy) = 0;
  1140. virtual void canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) = 0;
  1141. virtual void canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) = 0;
  1142. virtual void canvas_light_set_item_cull_mask(RID p_light, int p_mask) = 0;
  1143. virtual void canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) = 0;
  1144. virtual void canvas_light_set_directional_distance(RID p_light, float p_distance) = 0;
  1145. virtual void canvas_light_set_texture_scale(RID p_light, float p_scale) = 0;
  1146. virtual void canvas_light_set_texture(RID p_light, RID p_texture) = 0;
  1147. virtual void canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) = 0;
  1148. enum CanvasLightBlendMode {
  1149. CANVAS_LIGHT_BLEND_MODE_ADD,
  1150. CANVAS_LIGHT_BLEND_MODE_SUB,
  1151. CANVAS_LIGHT_BLEND_MODE_MIX,
  1152. };
  1153. virtual void canvas_light_set_blend_mode(RID p_light, CanvasLightBlendMode p_mode) = 0;
  1154. enum CanvasLightShadowFilter {
  1155. CANVAS_LIGHT_FILTER_NONE,
  1156. CANVAS_LIGHT_FILTER_PCF5,
  1157. CANVAS_LIGHT_FILTER_PCF13,
  1158. CANVAS_LIGHT_FILTER_MAX
  1159. };
  1160. virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) = 0;
  1161. virtual void canvas_light_set_shadow_filter(RID p_light, CanvasLightShadowFilter p_filter) = 0;
  1162. virtual void canvas_light_set_shadow_color(RID p_light, const Color &p_color) = 0;
  1163. virtual void canvas_light_set_shadow_smooth(RID p_light, float p_smooth) = 0;
  1164. /* CANVAS LIGHT OCCLUDER */
  1165. virtual RID canvas_light_occluder_create() = 0;
  1166. virtual void canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) = 0;
  1167. virtual void canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) = 0;
  1168. virtual void canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) = 0;
  1169. virtual void canvas_light_occluder_set_as_sdf_collision(RID p_occluder, bool p_enable) = 0;
  1170. virtual void canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) = 0;
  1171. virtual void canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) = 0;
  1172. /* CANVAS LIGHT OCCLUDER POLYGON */
  1173. virtual RID canvas_occluder_polygon_create() = 0;
  1174. virtual void canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) = 0;
  1175. enum CanvasOccluderPolygonCullMode {
  1176. CANVAS_OCCLUDER_POLYGON_CULL_DISABLED,
  1177. CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE,
  1178. CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE,
  1179. };
  1180. virtual void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, CanvasOccluderPolygonCullMode p_mode) = 0;
  1181. virtual void canvas_set_shadow_texture_size(int p_size) = 0;
  1182. Rect2 debug_canvas_item_get_rect(RID p_item);
  1183. virtual Rect2 _debug_canvas_item_get_rect(RID p_item) = 0;
  1184. /* GLOBAL SHADER UNIFORMS */
  1185. enum GlobalShaderParameterType {
  1186. GLOBAL_VAR_TYPE_BOOL,
  1187. GLOBAL_VAR_TYPE_BVEC2,
  1188. GLOBAL_VAR_TYPE_BVEC3,
  1189. GLOBAL_VAR_TYPE_BVEC4,
  1190. GLOBAL_VAR_TYPE_INT,
  1191. GLOBAL_VAR_TYPE_IVEC2,
  1192. GLOBAL_VAR_TYPE_IVEC3,
  1193. GLOBAL_VAR_TYPE_IVEC4,
  1194. GLOBAL_VAR_TYPE_RECT2I,
  1195. GLOBAL_VAR_TYPE_UINT,
  1196. GLOBAL_VAR_TYPE_UVEC2,
  1197. GLOBAL_VAR_TYPE_UVEC3,
  1198. GLOBAL_VAR_TYPE_UVEC4,
  1199. GLOBAL_VAR_TYPE_FLOAT,
  1200. GLOBAL_VAR_TYPE_VEC2,
  1201. GLOBAL_VAR_TYPE_VEC3,
  1202. GLOBAL_VAR_TYPE_VEC4,
  1203. GLOBAL_VAR_TYPE_COLOR,
  1204. GLOBAL_VAR_TYPE_RECT2,
  1205. GLOBAL_VAR_TYPE_MAT2,
  1206. GLOBAL_VAR_TYPE_MAT3,
  1207. GLOBAL_VAR_TYPE_MAT4,
  1208. GLOBAL_VAR_TYPE_TRANSFORM_2D,
  1209. GLOBAL_VAR_TYPE_TRANSFORM,
  1210. GLOBAL_VAR_TYPE_SAMPLER2D,
  1211. GLOBAL_VAR_TYPE_SAMPLER2DARRAY,
  1212. GLOBAL_VAR_TYPE_SAMPLER3D,
  1213. GLOBAL_VAR_TYPE_SAMPLERCUBE,
  1214. GLOBAL_VAR_TYPE_MAX
  1215. };
  1216. virtual void global_shader_parameter_add(const StringName &p_name, GlobalShaderParameterType p_type, const Variant &p_value) = 0;
  1217. virtual void global_shader_parameter_remove(const StringName &p_name) = 0;
  1218. virtual Vector<StringName> global_shader_parameter_get_list() const = 0;
  1219. virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) = 0;
  1220. virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) = 0;
  1221. virtual Variant global_shader_parameter_get(const StringName &p_name) const = 0;
  1222. virtual GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const = 0;
  1223. virtual void global_shader_parameters_load_settings(bool p_load_textures) = 0;
  1224. virtual void global_shader_parameters_clear() = 0;
  1225. static int global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type);
  1226. /* FREE */
  1227. virtual void free(RID p_rid) = 0; // Free RIDs associated with the rendering server.
  1228. /* EVENT QUEUING */
  1229. virtual void request_frame_drawn_callback(const Callable &p_callable) = 0;
  1230. virtual void draw(bool p_swap_buffers = true, double frame_step = 0.0) = 0;
  1231. virtual void sync() = 0;
  1232. virtual bool has_changed() const = 0;
  1233. virtual void init();
  1234. virtual void finish() = 0;
  1235. /* STATUS INFORMATION */
  1236. enum RenderingInfo {
  1237. RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME,
  1238. RENDERING_INFO_TOTAL_PRIMITIVES_IN_FRAME,
  1239. RENDERING_INFO_TOTAL_DRAW_CALLS_IN_FRAME,
  1240. RENDERING_INFO_TEXTURE_MEM_USED,
  1241. RENDERING_INFO_BUFFER_MEM_USED,
  1242. RENDERING_INFO_VIDEO_MEM_USED,
  1243. RENDERING_INFO_MAX
  1244. };
  1245. virtual uint64_t get_rendering_info(RenderingInfo p_info) = 0;
  1246. virtual String get_video_adapter_name() const = 0;
  1247. virtual String get_video_adapter_vendor() const = 0;
  1248. virtual RenderingDevice::DeviceType get_video_adapter_type() const = 0;
  1249. virtual String get_video_adapter_api_version() const = 0;
  1250. struct FrameProfileArea {
  1251. String name;
  1252. double gpu_msec;
  1253. double cpu_msec;
  1254. };
  1255. virtual void set_frame_profiling_enabled(bool p_enable) = 0;
  1256. virtual Vector<FrameProfileArea> get_frame_profile() = 0;
  1257. virtual uint64_t get_frame_profile_frame() = 0;
  1258. virtual double get_frame_setup_time_cpu() const = 0;
  1259. virtual void gi_set_use_half_resolution(bool p_enable) = 0;
  1260. /* TESTING */
  1261. virtual RID get_test_cube() = 0;
  1262. virtual RID get_test_texture();
  1263. virtual RID get_white_texture();
  1264. virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) = 0;
  1265. virtual RID make_sphere_mesh(int p_lats, int p_lons, real_t p_radius);
  1266. virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data);
  1267. virtual void mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes);
  1268. virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter = true) = 0;
  1269. virtual Color get_default_clear_color() = 0;
  1270. virtual void set_default_clear_color(const Color &p_color) = 0;
  1271. enum Features {
  1272. FEATURE_SHADERS,
  1273. FEATURE_MULTITHREADED,
  1274. };
  1275. virtual bool has_feature(Features p_feature) const = 0;
  1276. virtual bool has_os_feature(const String &p_feature) const = 0;
  1277. virtual void set_debug_generate_wireframes(bool p_generate) = 0;
  1278. virtual void call_set_vsync_mode(DisplayServer::VSyncMode p_mode, DisplayServer::WindowID p_window) = 0;
  1279. virtual bool is_low_end() const = 0;
  1280. virtual void set_print_gpu_profile(bool p_enable) = 0;
  1281. virtual Size2i get_maximum_viewport_size() const = 0;
  1282. RenderingDevice *get_rendering_device() const;
  1283. RenderingDevice *create_local_rendering_device() const;
  1284. bool is_render_loop_enabled() const;
  1285. void set_render_loop_enabled(bool p_enabled);
  1286. virtual void call_on_render_thread(const Callable &p_callable) = 0;
  1287. RenderingServer();
  1288. virtual ~RenderingServer();
  1289. #ifdef TOOLS_ENABLED
  1290. typedef void (*SurfaceUpgradeCallback)();
  1291. void set_surface_upgrade_callback(SurfaceUpgradeCallback p_callback);
  1292. void set_warn_on_surface_upgrade(bool p_warn);
  1293. #endif
  1294. #ifndef DISABLE_DEPRECATED
  1295. void fix_surface_compatibility(SurfaceData &p_surface, const String &p_path = "");
  1296. #endif
  1297. private:
  1298. // Binder helpers
  1299. RID _texture_2d_layered_create(const TypedArray<Image> &p_layers, TextureLayeredType p_layered_type);
  1300. RID _texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const TypedArray<Image> &p_data);
  1301. void _texture_3d_update(RID p_texture, const TypedArray<Image> &p_data);
  1302. TypedArray<Image> _texture_3d_get(RID p_texture) const;
  1303. TypedArray<Dictionary> _shader_get_shader_parameter_list(RID p_shader) const;
  1304. RID _mesh_create_from_surfaces(const TypedArray<Dictionary> &p_surfaces, int p_blend_shape_count);
  1305. void _mesh_add_surface(RID p_mesh, const Dictionary &p_surface);
  1306. Dictionary _mesh_get_surface(RID p_mesh, int p_idx);
  1307. TypedArray<Dictionary> _instance_geometry_get_shader_parameter_list(RID p_instance) const;
  1308. TypedArray<Image> _bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size);
  1309. void _particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses);
  1310. #ifdef TOOLS_ENABLED
  1311. SurfaceUpgradeCallback surface_upgrade_callback = nullptr;
  1312. bool warn_on_surface_upgrade = true;
  1313. #endif
  1314. };
  1315. // Make variant understand the enums.
  1316. VARIANT_ENUM_CAST(RenderingServer::TextureLayeredType);
  1317. VARIANT_ENUM_CAST(RenderingServer::CubeMapLayer);
  1318. VARIANT_ENUM_CAST(RenderingServer::ShaderMode);
  1319. VARIANT_ENUM_CAST(RenderingServer::ArrayType);
  1320. VARIANT_BITFIELD_CAST(RenderingServer::ArrayFormat);
  1321. VARIANT_ENUM_CAST(RenderingServer::ArrayCustomFormat);
  1322. VARIANT_ENUM_CAST(RenderingServer::PrimitiveType);
  1323. VARIANT_ENUM_CAST(RenderingServer::BlendShapeMode);
  1324. VARIANT_ENUM_CAST(RenderingServer::MultimeshTransformFormat);
  1325. VARIANT_ENUM_CAST(RenderingServer::LightType);
  1326. VARIANT_ENUM_CAST(RenderingServer::LightParam);
  1327. VARIANT_ENUM_CAST(RenderingServer::LightBakeMode);
  1328. VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowMode);
  1329. VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowMode);
  1330. VARIANT_ENUM_CAST(RenderingServer::LightDirectionalSkyMode);
  1331. VARIANT_ENUM_CAST(RenderingServer::LightProjectorFilter);
  1332. VARIANT_ENUM_CAST(RenderingServer::ReflectionProbeUpdateMode);
  1333. VARIANT_ENUM_CAST(RenderingServer::ReflectionProbeAmbientMode);
  1334. VARIANT_ENUM_CAST(RenderingServer::VoxelGIQuality);
  1335. VARIANT_ENUM_CAST(RenderingServer::DecalTexture);
  1336. VARIANT_ENUM_CAST(RenderingServer::DecalFilter);
  1337. VARIANT_ENUM_CAST(RenderingServer::ParticlesMode);
  1338. VARIANT_ENUM_CAST(RenderingServer::ParticlesTransformAlign);
  1339. VARIANT_ENUM_CAST(RenderingServer::ParticlesDrawOrder);
  1340. VARIANT_ENUM_CAST(RenderingServer::ParticlesEmitFlags);
  1341. VARIANT_ENUM_CAST(RenderingServer::ParticlesCollisionType);
  1342. VARIANT_ENUM_CAST(RenderingServer::ParticlesCollisionHeightfieldResolution);
  1343. VARIANT_ENUM_CAST(RenderingServer::FogVolumeShape);
  1344. VARIANT_ENUM_CAST(RenderingServer::ViewportScaling3DMode);
  1345. VARIANT_ENUM_CAST(RenderingServer::ViewportUpdateMode);
  1346. VARIANT_ENUM_CAST(RenderingServer::ViewportClearMode);
  1347. VARIANT_ENUM_CAST(RenderingServer::ViewportEnvironmentMode);
  1348. VARIANT_ENUM_CAST(RenderingServer::ViewportMSAA);
  1349. VARIANT_ENUM_CAST(RenderingServer::ViewportScreenSpaceAA);
  1350. VARIANT_ENUM_CAST(RenderingServer::ViewportRenderInfo);
  1351. VARIANT_ENUM_CAST(RenderingServer::ViewportRenderInfoType);
  1352. VARIANT_ENUM_CAST(RenderingServer::ViewportDebugDraw);
  1353. VARIANT_ENUM_CAST(RenderingServer::ViewportOcclusionCullingBuildQuality);
  1354. VARIANT_ENUM_CAST(RenderingServer::ViewportSDFOversize);
  1355. VARIANT_ENUM_CAST(RenderingServer::ViewportSDFScale);
  1356. VARIANT_ENUM_CAST(RenderingServer::ViewportVRSMode);
  1357. VARIANT_ENUM_CAST(RenderingServer::SkyMode);
  1358. VARIANT_ENUM_CAST(RenderingServer::EnvironmentBG);
  1359. VARIANT_ENUM_CAST(RenderingServer::EnvironmentAmbientSource);
  1360. VARIANT_ENUM_CAST(RenderingServer::EnvironmentReflectionSource);
  1361. VARIANT_ENUM_CAST(RenderingServer::EnvironmentGlowBlendMode);
  1362. VARIANT_ENUM_CAST(RenderingServer::EnvironmentToneMapper);
  1363. VARIANT_ENUM_CAST(RenderingServer::EnvironmentSSRRoughnessQuality);
  1364. VARIANT_ENUM_CAST(RenderingServer::EnvironmentSSAOQuality);
  1365. VARIANT_ENUM_CAST(RenderingServer::EnvironmentSSILQuality);
  1366. VARIANT_ENUM_CAST(RenderingServer::EnvironmentSDFGIFramesToConverge);
  1367. VARIANT_ENUM_CAST(RenderingServer::EnvironmentSDFGIRayCount);
  1368. VARIANT_ENUM_CAST(RenderingServer::EnvironmentSDFGIFramesToUpdateLight);
  1369. VARIANT_ENUM_CAST(RenderingServer::EnvironmentSDFGIYScale);
  1370. VARIANT_ENUM_CAST(RenderingServer::SubSurfaceScatteringQuality);
  1371. VARIANT_ENUM_CAST(RenderingServer::DOFBlurQuality);
  1372. VARIANT_ENUM_CAST(RenderingServer::DOFBokehShape);
  1373. VARIANT_ENUM_CAST(RenderingServer::ShadowQuality);
  1374. VARIANT_ENUM_CAST(RenderingServer::InstanceType);
  1375. VARIANT_ENUM_CAST(RenderingServer::InstanceFlags);
  1376. VARIANT_ENUM_CAST(RenderingServer::ShadowCastingSetting);
  1377. VARIANT_ENUM_CAST(RenderingServer::VisibilityRangeFadeMode);
  1378. VARIANT_ENUM_CAST(RenderingServer::NinePatchAxisMode);
  1379. VARIANT_ENUM_CAST(RenderingServer::CanvasItemTextureFilter);
  1380. VARIANT_ENUM_CAST(RenderingServer::CanvasItemTextureRepeat);
  1381. VARIANT_ENUM_CAST(RenderingServer::CanvasGroupMode);
  1382. VARIANT_ENUM_CAST(RenderingServer::CanvasLightMode);
  1383. VARIANT_ENUM_CAST(RenderingServer::CanvasLightBlendMode);
  1384. VARIANT_ENUM_CAST(RenderingServer::CanvasLightShadowFilter);
  1385. VARIANT_ENUM_CAST(RenderingServer::CanvasOccluderPolygonCullMode);
  1386. VARIANT_ENUM_CAST(RenderingServer::GlobalShaderParameterType);
  1387. VARIANT_ENUM_CAST(RenderingServer::RenderingInfo);
  1388. VARIANT_ENUM_CAST(RenderingServer::Features);
  1389. VARIANT_ENUM_CAST(RenderingServer::CanvasTextureChannel);
  1390. VARIANT_ENUM_CAST(RenderingServer::BakeChannels);
  1391. // Alias to make it easier to use.
  1392. #define RS RenderingServer
  1393. #endif // RENDERING_SERVER_H