rendering_server.h 73 KB

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