rasterizer_dummy.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. /*************************************************************************/
  2. /* rasterizer_dummy.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  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 RASTERIZER_DUMMY_H
  31. #define RASTERIZER_DUMMY_H
  32. #include "core/math/camera_matrix.h"
  33. #include "core/self_list.h"
  34. #include "scene/resources/mesh.h"
  35. #include "servers/visual/rasterizer.h"
  36. #include "servers/visual_server.h"
  37. class RasterizerSceneDummy : public RasterizerScene {
  38. public:
  39. /* SHADOW ATLAS API */
  40. RID shadow_atlas_create() { return RID(); }
  41. void shadow_atlas_set_size(RID p_atlas, int p_size) {}
  42. void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {}
  43. bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { return false; }
  44. int get_directional_light_shadow_size(RID p_light_intance) { return 0; }
  45. void set_directional_shadow_count(int p_count) {}
  46. /* ENVIRONMENT API */
  47. RID environment_create() { return RID(); }
  48. void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) {}
  49. void environment_set_sky(RID p_env, RID p_sky) {}
  50. void environment_set_sky_custom_fov(RID p_env, float p_scale) {}
  51. void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {}
  52. void environment_set_bg_color(RID p_env, const Color &p_color) {}
  53. void environment_set_bg_energy(RID p_env, float p_energy) {}
  54. void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {}
  55. void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) {}
  56. void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) {}
  57. void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) {}
  58. void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {}
  59. void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {}
  60. void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {}
  61. void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {}
  62. void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {}
  63. void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {}
  64. void environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {}
  65. void environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) {}
  66. void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {}
  67. bool is_environment(RID p_env) { return false; }
  68. VS::EnvironmentBG environment_get_background(RID p_env) { return VS::ENV_BG_KEEP; }
  69. int environment_get_canvas_max_layer(RID p_env) { return 0; }
  70. RID light_instance_create(RID p_light) { return RID(); }
  71. void light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {}
  72. void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0) {}
  73. void light_instance_mark_visible(RID p_light_instance) {}
  74. RID reflection_atlas_create() { return RID(); }
  75. void reflection_atlas_set_size(RID p_ref_atlas, int p_size) {}
  76. void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv) {}
  77. RID reflection_probe_instance_create(RID p_probe) { return RID(); }
  78. void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {}
  79. void reflection_probe_release_atlas_index(RID p_instance) {}
  80. bool reflection_probe_instance_needs_redraw(RID p_instance) { return false; }
  81. bool reflection_probe_instance_has_reflection(RID p_instance) { return false; }
  82. bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { return false; }
  83. bool reflection_probe_instance_postprocess_step(RID p_instance) { return true; }
  84. RID gi_probe_instance_create() { return RID(); }
  85. void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data) {}
  86. void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {}
  87. void gi_probe_instance_set_bounds(RID p_probe, const Vector3 &p_bounds) {}
  88. void render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {}
  89. void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {}
  90. void set_scene_pass(uint64_t p_pass) {}
  91. void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) {}
  92. bool free(RID p_rid) { return true; }
  93. RasterizerSceneDummy() {}
  94. ~RasterizerSceneDummy() {}
  95. };
  96. class RasterizerStorageDummy : public RasterizerStorage {
  97. public:
  98. /* TEXTURE API */
  99. struct DummyTexture : public RID_Data {
  100. int width;
  101. int height;
  102. uint32_t flags;
  103. Image::Format format;
  104. Ref<Image> image;
  105. String path;
  106. };
  107. struct DummySurface {
  108. uint32_t format;
  109. VS::PrimitiveType primitive;
  110. PoolVector<uint8_t> array;
  111. int vertex_count;
  112. PoolVector<uint8_t> index_array;
  113. int index_count;
  114. AABB aabb;
  115. Vector<PoolVector<uint8_t> > blend_shapes;
  116. Vector<AABB> bone_aabbs;
  117. };
  118. struct DummyMesh : public RID_Data {
  119. Vector<DummySurface> surfaces;
  120. int blend_shape_count;
  121. VS::BlendShapeMode blend_shape_mode;
  122. };
  123. mutable RID_Owner<DummyTexture> texture_owner;
  124. mutable RID_Owner<DummyMesh> mesh_owner;
  125. RID texture_create() {
  126. DummyTexture *texture = memnew(DummyTexture);
  127. ERR_FAIL_COND_V(!texture, RID());
  128. return texture_owner.make_rid(texture);
  129. }
  130. void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, VisualServer::TextureType p_type = VS::TEXTURE_TYPE_2D, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT) {
  131. DummyTexture *t = texture_owner.getornull(p_texture);
  132. ERR_FAIL_COND(!t);
  133. t->width = p_width;
  134. t->height = p_height;
  135. t->flags = p_flags;
  136. t->format = p_format;
  137. t->image = Ref<Image>(memnew(Image));
  138. t->image->create(p_width, p_height, false, p_format);
  139. }
  140. void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_level) {
  141. DummyTexture *t = texture_owner.getornull(p_texture);
  142. ERR_FAIL_COND(!t);
  143. t->width = p_image->get_width();
  144. t->height = p_image->get_height();
  145. t->format = p_image->get_format();
  146. t->image->create(t->width, t->height, false, t->format, p_image->get_data());
  147. }
  148. void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_level) {
  149. DummyTexture *t = texture_owner.get(p_texture);
  150. ERR_FAIL_COND(!t);
  151. ERR_FAIL_COND(t->format != p_image->get_format());
  152. ERR_FAIL_COND(p_image.is_null());
  153. ERR_FAIL_COND(src_w <= 0 || src_h <= 0);
  154. ERR_FAIL_COND(src_x < 0 || src_y < 0 || src_x + src_w > p_image->get_width() || src_y + src_h > p_image->get_height());
  155. ERR_FAIL_COND(dst_x < 0 || dst_y < 0 || dst_x + src_w > t->width || dst_y + src_h > t->height);
  156. t->image->blit_rect(p_image, Rect2(src_x, src_y, src_w, src_h), Vector2(dst_x, dst_y));
  157. }
  158. Ref<Image> texture_get_data(RID p_texture, int p_level) const {
  159. DummyTexture *t = texture_owner.getornull(p_texture);
  160. ERR_FAIL_COND_V(!t, Ref<Image>());
  161. return t->image;
  162. }
  163. void texture_set_flags(RID p_texture, uint32_t p_flags) {
  164. DummyTexture *t = texture_owner.getornull(p_texture);
  165. ERR_FAIL_COND(!t);
  166. t->flags = p_flags;
  167. }
  168. uint32_t texture_get_flags(RID p_texture) const {
  169. DummyTexture *t = texture_owner.getornull(p_texture);
  170. ERR_FAIL_COND_V(!t, 0);
  171. return t->flags;
  172. }
  173. Image::Format texture_get_format(RID p_texture) const {
  174. DummyTexture *t = texture_owner.getornull(p_texture);
  175. ERR_FAIL_COND_V(!t, Image::FORMAT_RGB8);
  176. return t->format;
  177. }
  178. VisualServer::TextureType texture_get_type(RID p_texture) const { return VS::TEXTURE_TYPE_2D; }
  179. uint32_t texture_get_texid(RID p_texture) const { return 0; }
  180. uint32_t texture_get_width(RID p_texture) const { return 0; }
  181. uint32_t texture_get_height(RID p_texture) const { return 0; }
  182. uint32_t texture_get_depth(RID p_texture) const { return 0; }
  183. void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth_3d) {}
  184. void texture_set_path(RID p_texture, const String &p_path) {
  185. DummyTexture *t = texture_owner.getornull(p_texture);
  186. ERR_FAIL_COND(!t);
  187. t->path = p_path;
  188. }
  189. String texture_get_path(RID p_texture) const {
  190. DummyTexture *t = texture_owner.getornull(p_texture);
  191. ERR_FAIL_COND_V(!t, String());
  192. return t->path;
  193. }
  194. void texture_set_shrink_all_x2_on_set_data(bool p_enable) {}
  195. void texture_debug_usage(List<VS::TextureInfo> *r_info) {}
  196. RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const { return RID(); }
  197. void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {}
  198. void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {}
  199. void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {}
  200. void textures_keep_original(bool p_enable) {}
  201. void texture_set_proxy(RID p_proxy, RID p_base) {}
  202. void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
  203. /* SKY API */
  204. RID sky_create() { return RID(); }
  205. void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {}
  206. /* SHADER API */
  207. RID shader_create() { return RID(); }
  208. void shader_set_code(RID p_shader, const String &p_code) {}
  209. String shader_get_code(RID p_shader) const { return ""; }
  210. void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {}
  211. void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {}
  212. RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const { return RID(); }
  213. /* COMMON MATERIAL API */
  214. RID material_create() { return RID(); }
  215. void material_set_render_priority(RID p_material, int priority) {}
  216. void material_set_shader(RID p_shader_material, RID p_shader) {}
  217. RID material_get_shader(RID p_shader_material) const { return RID(); }
  218. void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {}
  219. Variant material_get_param(RID p_material, const StringName &p_param) const { return Variant(); }
  220. Variant material_get_param_default(RID p_material, const StringName &p_param) const { return Variant(); }
  221. void material_set_line_width(RID p_material, float p_width) {}
  222. void material_set_next_pass(RID p_material, RID p_next_material) {}
  223. bool material_is_animated(RID p_material) { return false; }
  224. bool material_casts_shadows(RID p_material) { return false; }
  225. void material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {}
  226. void material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {}
  227. /* MESH API */
  228. RID mesh_create() {
  229. DummyMesh *mesh = memnew(DummyMesh);
  230. ERR_FAIL_COND_V(!mesh, RID());
  231. mesh->blend_shape_count = 0;
  232. mesh->blend_shape_mode = VS::BLEND_SHAPE_MODE_NORMALIZED;
  233. return mesh_owner.make_rid(mesh);
  234. }
  235. void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) {
  236. DummyMesh *m = mesh_owner.getornull(p_mesh);
  237. ERR_FAIL_COND(!m);
  238. m->surfaces.push_back(DummySurface());
  239. DummySurface *s = &m->surfaces.write[m->surfaces.size() - 1];
  240. s->format = p_format;
  241. s->primitive = p_primitive;
  242. s->array = p_array;
  243. s->vertex_count = p_vertex_count;
  244. s->index_array = p_index_array;
  245. s->index_count = p_index_count;
  246. s->aabb = p_aabb;
  247. s->blend_shapes = p_blend_shapes;
  248. s->bone_aabbs = p_bone_aabbs;
  249. }
  250. void mesh_set_blend_shape_count(RID p_mesh, int p_amount) {
  251. DummyMesh *m = mesh_owner.getornull(p_mesh);
  252. ERR_FAIL_COND(!m);
  253. m->blend_shape_count = p_amount;
  254. }
  255. int mesh_get_blend_shape_count(RID p_mesh) const {
  256. DummyMesh *m = mesh_owner.getornull(p_mesh);
  257. ERR_FAIL_COND_V(!m, 0);
  258. return m->blend_shape_count;
  259. }
  260. void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) {
  261. DummyMesh *m = mesh_owner.getornull(p_mesh);
  262. ERR_FAIL_COND(!m);
  263. m->blend_shape_mode = p_mode;
  264. }
  265. VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const {
  266. DummyMesh *m = mesh_owner.getornull(p_mesh);
  267. ERR_FAIL_COND_V(!m, VS::BLEND_SHAPE_MODE_NORMALIZED);
  268. return m->blend_shape_mode;
  269. }
  270. void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {}
  271. void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {}
  272. RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); }
  273. int mesh_surface_get_array_len(RID p_mesh, int p_surface) const {
  274. DummyMesh *m = mesh_owner.getornull(p_mesh);
  275. ERR_FAIL_COND_V(!m, 0);
  276. return m->surfaces[p_surface].vertex_count;
  277. }
  278. int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const {
  279. DummyMesh *m = mesh_owner.getornull(p_mesh);
  280. ERR_FAIL_COND_V(!m, 0);
  281. return m->surfaces[p_surface].index_count;
  282. }
  283. PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const {
  284. DummyMesh *m = mesh_owner.getornull(p_mesh);
  285. ERR_FAIL_COND_V(!m, PoolVector<uint8_t>());
  286. return m->surfaces[p_surface].array;
  287. }
  288. PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const {
  289. DummyMesh *m = mesh_owner.getornull(p_mesh);
  290. ERR_FAIL_COND_V(!m, PoolVector<uint8_t>());
  291. return m->surfaces[p_surface].index_array;
  292. }
  293. uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const {
  294. DummyMesh *m = mesh_owner.getornull(p_mesh);
  295. ERR_FAIL_COND_V(!m, 0);
  296. return m->surfaces[p_surface].format;
  297. }
  298. VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const {
  299. DummyMesh *m = mesh_owner.getornull(p_mesh);
  300. ERR_FAIL_COND_V(!m, VS::PRIMITIVE_POINTS);
  301. return m->surfaces[p_surface].primitive;
  302. }
  303. AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const {
  304. DummyMesh *m = mesh_owner.getornull(p_mesh);
  305. ERR_FAIL_COND_V(!m, AABB());
  306. return m->surfaces[p_surface].aabb;
  307. }
  308. Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const {
  309. DummyMesh *m = mesh_owner.getornull(p_mesh);
  310. ERR_FAIL_COND_V(!m, Vector<PoolVector<uint8_t> >());
  311. return m->surfaces[p_surface].blend_shapes;
  312. }
  313. Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
  314. DummyMesh *m = mesh_owner.getornull(p_mesh);
  315. ERR_FAIL_COND_V(!m, Vector<AABB>());
  316. return m->surfaces[p_surface].bone_aabbs;
  317. }
  318. void mesh_remove_surface(RID p_mesh, int p_index) {
  319. DummyMesh *m = mesh_owner.getornull(p_mesh);
  320. ERR_FAIL_COND(!m);
  321. ERR_FAIL_COND(p_index >= m->surfaces.size());
  322. m->surfaces.remove(p_index);
  323. }
  324. int mesh_get_surface_count(RID p_mesh) const {
  325. DummyMesh *m = mesh_owner.getornull(p_mesh);
  326. ERR_FAIL_COND_V(!m, 0);
  327. return m->surfaces.size();
  328. }
  329. void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {}
  330. AABB mesh_get_custom_aabb(RID p_mesh) const { return AABB(); }
  331. AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const { return AABB(); }
  332. void mesh_clear(RID p_mesh) {}
  333. /* MULTIMESH API */
  334. virtual RID multimesh_create() { return RID(); }
  335. void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format, VS::MultimeshCustomDataFormat p_data = VS::MULTIMESH_CUSTOM_DATA_NONE) {}
  336. int multimesh_get_instance_count(RID p_multimesh) const { return 0; }
  337. void multimesh_set_mesh(RID p_multimesh, RID p_mesh) {}
  338. void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) {}
  339. void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {}
  340. void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {}
  341. void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {}
  342. RID multimesh_get_mesh(RID p_multimesh) const { return RID(); }
  343. Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const { return Transform(); }
  344. Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const { return Transform2D(); }
  345. Color multimesh_instance_get_color(RID p_multimesh, int p_index) const { return Color(); }
  346. Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { return Color(); }
  347. void multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array) {}
  348. void multimesh_set_visible_instances(RID p_multimesh, int p_visible) {}
  349. int multimesh_get_visible_instances(RID p_multimesh) const { return 0; }
  350. AABB multimesh_get_aabb(RID p_multimesh) const { return AABB(); }
  351. /* IMMEDIATE API */
  352. RID immediate_create() { return RID(); }
  353. void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) {}
  354. void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {}
  355. void immediate_normal(RID p_immediate, const Vector3 &p_normal) {}
  356. void immediate_tangent(RID p_immediate, const Plane &p_tangent) {}
  357. void immediate_color(RID p_immediate, const Color &p_color) {}
  358. void immediate_uv(RID p_immediate, const Vector2 &tex_uv) {}
  359. void immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {}
  360. void immediate_end(RID p_immediate) {}
  361. void immediate_clear(RID p_immediate) {}
  362. void immediate_set_material(RID p_immediate, RID p_material) {}
  363. RID immediate_get_material(RID p_immediate) const { return RID(); }
  364. AABB immediate_get_aabb(RID p_immediate) const { return AABB(); }
  365. /* SKELETON API */
  366. RID skeleton_create() { return RID(); }
  367. void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) {}
  368. void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {}
  369. int skeleton_get_bone_count(RID p_skeleton) const { return 0; }
  370. void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) {}
  371. Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const { return Transform(); }
  372. void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {}
  373. Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const { return Transform2D(); }
  374. /* Light API */
  375. RID light_create(VS::LightType p_type) { return RID(); }
  376. RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); }
  377. RID omni_light_create() { return light_create(VS::LIGHT_OMNI); }
  378. RID spot_light_create() { return light_create(VS::LIGHT_SPOT); }
  379. void light_set_color(RID p_light, const Color &p_color) {}
  380. void light_set_param(RID p_light, VS::LightParam p_param, float p_value) {}
  381. void light_set_shadow(RID p_light, bool p_enabled) {}
  382. void light_set_shadow_color(RID p_light, const Color &p_color) {}
  383. void light_set_projector(RID p_light, RID p_texture) {}
  384. void light_set_negative(RID p_light, bool p_enable) {}
  385. void light_set_cull_mask(RID p_light, uint32_t p_mask) {}
  386. void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {}
  387. void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {}
  388. void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) {}
  389. void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {}
  390. void light_directional_set_blend_splits(RID p_light, bool p_enable) {}
  391. bool light_directional_get_blend_splits(RID p_light) const { return false; }
  392. void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) {}
  393. VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const { return VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; }
  394. VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) { return VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; }
  395. VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) { return VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; }
  396. bool light_has_shadow(RID p_light) const { return false; }
  397. VS::LightType light_get_type(RID p_light) const { return VS::LIGHT_OMNI; }
  398. AABB light_get_aabb(RID p_light) const { return AABB(); }
  399. float light_get_param(RID p_light, VS::LightParam p_param) { return 0.0; }
  400. Color light_get_color(RID p_light) { return Color(); }
  401. uint64_t light_get_version(RID p_light) const { return 0; }
  402. /* PROBE API */
  403. RID reflection_probe_create() { return RID(); }
  404. void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) {}
  405. void reflection_probe_set_intensity(RID p_probe, float p_intensity) {}
  406. void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {}
  407. void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {}
  408. void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {}
  409. void reflection_probe_set_max_distance(RID p_probe, float p_distance) {}
  410. void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {}
  411. void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {}
  412. void reflection_probe_set_as_interior(RID p_probe, bool p_enable) {}
  413. void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {}
  414. void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {}
  415. void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {}
  416. void reflection_probe_set_resolution(RID p_probe, int p_resolution) {}
  417. AABB reflection_probe_get_aabb(RID p_probe) const { return AABB(); }
  418. VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return VisualServer::REFLECTION_PROBE_UPDATE_ONCE; }
  419. uint32_t reflection_probe_get_cull_mask(RID p_probe) const { return 0; }
  420. Vector3 reflection_probe_get_extents(RID p_probe) const { return Vector3(); }
  421. Vector3 reflection_probe_get_origin_offset(RID p_probe) const { return Vector3(); }
  422. float reflection_probe_get_origin_max_distance(RID p_probe) const { return 0.0; }
  423. bool reflection_probe_renders_shadows(RID p_probe) const { return false; }
  424. void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {}
  425. void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {}
  426. void instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
  427. void instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
  428. /* GI PROBE API */
  429. RID gi_probe_create() { return RID(); }
  430. void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) {}
  431. AABB gi_probe_get_bounds(RID p_probe) const { return AABB(); }
  432. void gi_probe_set_cell_size(RID p_probe, float p_range) {}
  433. float gi_probe_get_cell_size(RID p_probe) const { return 0.0; }
  434. void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform) {}
  435. Transform gi_probe_get_to_cell_xform(RID p_probe) const { return Transform(); }
  436. void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) {}
  437. PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const {
  438. PoolVector<int> p;
  439. return p;
  440. }
  441. void gi_probe_set_dynamic_range(RID p_probe, int p_range) {}
  442. int gi_probe_get_dynamic_range(RID p_probe) const { return 0; }
  443. void gi_probe_set_energy(RID p_probe, float p_range) {}
  444. float gi_probe_get_energy(RID p_probe) const { return 0.0; }
  445. void gi_probe_set_bias(RID p_probe, float p_range) {}
  446. float gi_probe_get_bias(RID p_probe) const { return 0.0; }
  447. void gi_probe_set_normal_bias(RID p_probe, float p_range) {}
  448. float gi_probe_get_normal_bias(RID p_probe) const { return 0.0; }
  449. void gi_probe_set_propagation(RID p_probe, float p_range) {}
  450. float gi_probe_get_propagation(RID p_probe) const { return 0.0; }
  451. void gi_probe_set_interior(RID p_probe, bool p_enable) {}
  452. bool gi_probe_is_interior(RID p_probe) const { return false; }
  453. void gi_probe_set_compress(RID p_probe, bool p_enable) {}
  454. bool gi_probe_is_compressed(RID p_probe) const { return false; }
  455. uint32_t gi_probe_get_version(RID p_probe) { return 0; }
  456. GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const { return GI_PROBE_UNCOMPRESSED; }
  457. RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression) { return RID(); }
  458. void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data) {}
  459. /* LIGHTMAP CAPTURE */
  460. struct Instantiable : public RID_Data {
  461. SelfList<RasterizerScene::InstanceBase>::List instance_list;
  462. _FORCE_INLINE_ void instance_change_notify(bool p_aabb = true, bool p_materials = true) {
  463. SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
  464. while (instances) {
  465. instances->self()->base_changed(p_aabb, p_materials);
  466. instances = instances->next();
  467. }
  468. }
  469. _FORCE_INLINE_ void instance_remove_deps() {
  470. SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
  471. while (instances) {
  472. SelfList<RasterizerScene::InstanceBase> *next = instances->next();
  473. instances->self()->base_removed();
  474. instances = next;
  475. }
  476. }
  477. Instantiable() {}
  478. virtual ~Instantiable() {
  479. }
  480. };
  481. struct LightmapCapture : public Instantiable {
  482. PoolVector<LightmapCaptureOctree> octree;
  483. AABB bounds;
  484. Transform cell_xform;
  485. int cell_subdiv;
  486. float energy;
  487. LightmapCapture() {
  488. energy = 1.0;
  489. cell_subdiv = 1;
  490. }
  491. };
  492. mutable RID_Owner<LightmapCapture> lightmap_capture_data_owner;
  493. void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {}
  494. AABB lightmap_capture_get_bounds(RID p_capture) const { return AABB(); }
  495. void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) {}
  496. RID lightmap_capture_create() {
  497. LightmapCapture *capture = memnew(LightmapCapture);
  498. return lightmap_capture_data_owner.make_rid(capture);
  499. }
  500. PoolVector<uint8_t> lightmap_capture_get_octree(RID p_capture) const {
  501. const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
  502. ERR_FAIL_COND_V(!capture, PoolVector<uint8_t>());
  503. return PoolVector<uint8_t>();
  504. }
  505. void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform) {}
  506. Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const { return Transform(); }
  507. void lightmap_capture_set_octree_cell_subdiv(RID p_capture, int p_subdiv) {}
  508. int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const { return 0; }
  509. void lightmap_capture_set_energy(RID p_capture, float p_energy) {}
  510. float lightmap_capture_get_energy(RID p_capture) const { return 0.0; }
  511. const PoolVector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const {
  512. const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
  513. ERR_FAIL_COND_V(!capture, NULL);
  514. return &capture->octree;
  515. }
  516. /* PARTICLES */
  517. RID particles_create() { return RID(); }
  518. void particles_set_emitting(RID p_particles, bool p_emitting) {}
  519. void particles_set_amount(RID p_particles, int p_amount) {}
  520. void particles_set_lifetime(RID p_particles, float p_lifetime) {}
  521. void particles_set_one_shot(RID p_particles, bool p_one_shot) {}
  522. void particles_set_pre_process_time(RID p_particles, float p_time) {}
  523. void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) {}
  524. void particles_set_randomness_ratio(RID p_particles, float p_ratio) {}
  525. void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) {}
  526. void particles_set_speed_scale(RID p_particles, float p_scale) {}
  527. void particles_set_use_local_coordinates(RID p_particles, bool p_enable) {}
  528. void particles_set_process_material(RID p_particles, RID p_material) {}
  529. void particles_set_fixed_fps(RID p_particles, int p_fps) {}
  530. void particles_set_fractional_delta(RID p_particles, bool p_enable) {}
  531. void particles_restart(RID p_particles) {}
  532. void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) {}
  533. void particles_set_draw_passes(RID p_particles, int p_count) {}
  534. void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {}
  535. void particles_request_process(RID p_particles) {}
  536. AABB particles_get_current_aabb(RID p_particles) { return AABB(); }
  537. AABB particles_get_aabb(RID p_particles) const { return AABB(); }
  538. void particles_set_emission_transform(RID p_particles, const Transform &p_transform) {}
  539. bool particles_get_emitting(RID p_particles) { return false; }
  540. int particles_get_draw_passes(RID p_particles) const { return 0; }
  541. RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { return RID(); }
  542. virtual bool particles_is_inactive(RID p_particles) const { return false; }
  543. /* RENDER TARGET */
  544. RID render_target_create() { return RID(); }
  545. void render_target_set_size(RID p_render_target, int p_width, int p_height) {}
  546. RID render_target_get_texture(RID p_render_target) const { return RID(); }
  547. void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {}
  548. bool render_target_was_used(RID p_render_target) { return false; }
  549. void render_target_clear_used(RID p_render_target) {}
  550. void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {}
  551. /* CANVAS SHADOW */
  552. RID canvas_light_shadow_buffer_create(int p_width) { return RID(); }
  553. /* LIGHT SHADOW MAPPING */
  554. RID canvas_light_occluder_create() { return RID(); }
  555. void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {}
  556. VS::InstanceType get_base_type(RID p_rid) const {
  557. if (mesh_owner.owns(p_rid)) {
  558. return VS::INSTANCE_MESH;
  559. }
  560. return VS::INSTANCE_NONE;
  561. }
  562. bool free(RID p_rid) {
  563. if (texture_owner.owns(p_rid)) {
  564. // delete the texture
  565. DummyTexture *texture = texture_owner.get(p_rid);
  566. texture_owner.free(p_rid);
  567. memdelete(texture);
  568. }
  569. return true;
  570. }
  571. bool has_os_feature(const String &p_feature) const { return false; }
  572. void update_dirty_resources() {}
  573. void set_debug_generate_wireframes(bool p_generate) {}
  574. void render_info_begin_capture() {}
  575. void render_info_end_capture() {}
  576. int get_captured_render_info(VS::RenderInfo p_info) { return 0; }
  577. int get_render_info(VS::RenderInfo p_info) { return 0; }
  578. static RasterizerStorage *base_singleton;
  579. RasterizerStorageDummy(){};
  580. ~RasterizerStorageDummy() {}
  581. };
  582. class RasterizerCanvasDummy : public RasterizerCanvas {
  583. public:
  584. RID light_internal_create() { return RID(); }
  585. void light_internal_update(RID p_rid, Light *p_light) {}
  586. void light_internal_free(RID p_rid) {}
  587. void canvas_begin(){};
  588. void canvas_end(){};
  589. void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_transform){};
  590. void canvas_debug_viewport_shadows(Light *p_lights_with_shadow){};
  591. void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {}
  592. void reset_canvas() {}
  593. void draw_window_margins(int *p_margins, RID *p_margin_textures) {}
  594. RasterizerCanvasDummy() {}
  595. ~RasterizerCanvasDummy() {}
  596. };
  597. class RasterizerDummy : public Rasterizer {
  598. protected:
  599. RasterizerCanvasDummy canvas;
  600. RasterizerStorageDummy storage;
  601. RasterizerSceneDummy scene;
  602. public:
  603. RasterizerStorage *get_storage() { return &storage; }
  604. RasterizerCanvas *get_canvas() { return &canvas; }
  605. RasterizerScene *get_scene() { return &scene; }
  606. void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale) {}
  607. void initialize() {}
  608. void begin_frame(double frame_step) {}
  609. void set_current_render_target(RID p_render_target) {}
  610. void restore_render_target() {}
  611. void clear_render_target(const Color &p_color) {}
  612. void blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0) {}
  613. void output_lens_distorted_to_screen(RID p_render_target, const Rect2 &p_screen_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {}
  614. void end_frame(bool p_swap_buffers) {}
  615. void finalize() {}
  616. static Error is_viable() {
  617. return OK;
  618. }
  619. static Rasterizer *_create_current() {
  620. return memnew(RasterizerDummy);
  621. }
  622. static void make_current() {
  623. _create_func = _create_current;
  624. }
  625. virtual bool is_low_end() const { return true; }
  626. RasterizerDummy() {}
  627. ~RasterizerDummy() {}
  628. };
  629. #endif // RASTERIZER_DUMMY_H