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 
33 #include "servers/visual/rasterizer.h"
34 
35 #include "camera_matrix.h"
36 #include "image.h"
37 #include "list.h"
38 #include "map.h"
39 #include "rid.h"
40 #include "servers/visual_server.h"
41 #include "sort.h"
42 
43 #include "servers/visual/particle_system_sw.h"
44 
45 /**
46 	@author Juan Linietsky <reduzio@gmail.com>
47 */
48 class RasterizerDummy : public Rasterizer {
49 
50 	struct Texture {
51 
52 		uint32_t flags;
53 		int width, height;
54 		Image::Format format;
55 		Image image[6];
TextureTexture56 		Texture() {
57 
58 			flags = width = height = 0;
59 			format = Image::FORMAT_GRAYSCALE;
60 		}
61 
~TextureTexture62 		~Texture() {
63 		}
64 	};
65 
66 	mutable RID_Owner<Texture> texture_owner;
67 
68 	struct Shader {
69 
70 		String vertex_code;
71 		String fragment_code;
72 		String light_code;
73 		VS::ShaderMode mode;
74 		Map<StringName, Variant> params;
75 		int fragment_line;
76 		int vertex_line;
77 		int light_line;
78 		bool valid;
79 		bool has_alpha;
80 		bool use_world_transform;
81 	};
82 
83 	mutable RID_Owner<Shader> shader_owner;
84 
85 	struct Material {
86 
87 		bool flags[VS::MATERIAL_FLAG_MAX];
88 
89 		VS::MaterialDepthDrawMode depth_draw_mode;
90 
91 		VS::MaterialBlendMode blend_mode;
92 
93 		float line_width;
94 		float point_size;
95 
96 		RID shader; // shader material
97 
98 		Map<StringName, Variant> shader_params;
99 
MaterialMaterial100 		Material() {
101 
102 			for (int i = 0; i < VS::MATERIAL_FLAG_MAX; i++)
103 				flags[i] = false;
104 			flags[VS::MATERIAL_FLAG_VISIBLE] = true;
105 
106 			depth_draw_mode = VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY;
107 			line_width = 1;
108 			blend_mode = VS::MATERIAL_BLEND_MODE_MIX;
109 			point_size = 1.0;
110 		}
111 	};
112 	mutable RID_Owner<Material> material_owner;
113 
114 	void _material_check_alpha(Material *p_material);
115 
116 	struct Geometry {
117 
118 		enum Type {
119 			GEOMETRY_INVALID,
120 			GEOMETRY_SURFACE,
121 			GEOMETRY_POLY,
122 			GEOMETRY_PARTICLES,
123 			GEOMETRY_MULTISURFACE,
124 		};
125 
126 		Type type;
127 		RID material;
128 		bool has_alpha;
129 		bool material_owned;
130 
GeometryGeometry131 		Geometry() {
132 			has_alpha = false;
133 			material_owned = false;
134 		}
~GeometryGeometry135 		virtual ~Geometry(){};
136 	};
137 
138 	struct GeometryOwner {
139 
~GeometryOwnerGeometryOwner140 		virtual ~GeometryOwner() {}
141 	};
142 
143 	class Mesh;
144 
145 	struct Surface : public Geometry {
146 
147 		Array data;
148 		Array morph_data;
149 
150 		bool packed;
151 		bool alpha_sort;
152 		int morph_target_count;
153 		AABB aabb;
154 
155 		VS::PrimitiveType primitive;
156 
157 		uint32_t format;
158 		uint32_t morph_format;
159 
SurfaceSurface160 		Surface() {
161 
162 			packed = false;
163 			morph_target_count = 0;
164 			material_owned = false;
165 			format = 0;
166 			morph_format = 0;
167 
168 			primitive = VS::PRIMITIVE_POINTS;
169 		}
170 
~SurfaceSurface171 		~Surface() {
172 		}
173 	};
174 
175 	struct Mesh {
176 
177 		bool active;
178 		Vector<Surface *> surfaces;
179 		int morph_target_count;
180 		VS::MorphTargetMode morph_target_mode;
181 		AABB custom_aabb;
182 
183 		mutable uint64_t last_pass;
MeshMesh184 		Mesh() {
185 			morph_target_mode = VS::MORPH_MODE_NORMALIZED;
186 			morph_target_count = 0;
187 			last_pass = 0;
188 			active = false;
189 		}
190 	};
191 	mutable RID_Owner<Mesh> mesh_owner;
192 
193 	struct MultiMesh;
194 
195 	struct MultiMeshSurface : public Geometry {
196 
197 		Surface *surface;
MultiMeshSurfaceMultiMeshSurface198 		MultiMeshSurface() { type = GEOMETRY_MULTISURFACE; }
199 	};
200 
201 	struct MultiMesh : public GeometryOwner {
202 
203 		struct Element {
204 
205 			Transform xform;
206 			Color color;
207 		};
208 
209 		AABB aabb;
210 		RID mesh;
211 		int visible;
212 
213 		//IDirect3DVertexBuffer9* instance_buffer;
214 		Vector<Element> elements;
215 
MultiMeshMultiMesh216 		MultiMesh() {
217 			visible = -1;
218 		}
219 	};
220 
221 	mutable RID_Owner<MultiMesh> multimesh_owner;
222 
223 	struct Immediate {
224 
225 		RID material;
226 		int empty;
227 	};
228 
229 	mutable RID_Owner<Immediate> immediate_owner;
230 
231 	struct Particles : public Geometry {
232 
233 		ParticleSystemSW data; // software particle system
234 
ParticlesParticles235 		Particles() {
236 			type = GEOMETRY_PARTICLES;
237 		}
238 	};
239 
240 	mutable RID_Owner<Particles> particles_owner;
241 
242 	struct ParticlesInstance : public GeometryOwner {
243 
244 		RID particles;
245 
246 		ParticleSystemProcessSW particles_process;
247 		Transform transform;
248 
ParticlesInstanceParticlesInstance249 		ParticlesInstance() {}
250 	};
251 
252 	mutable RID_Owner<ParticlesInstance> particles_instance_owner;
253 	ParticleSystemDrawInfoSW particle_draw_info;
254 
255 	struct Skeleton {
256 
257 		Vector<Transform> bones;
258 	};
259 
260 	mutable RID_Owner<Skeleton> skeleton_owner;
261 
262 	struct Light {
263 
264 		VS::LightType type;
265 		float vars[VS::LIGHT_PARAM_MAX];
266 		Color colors[3];
267 		bool shadow_enabled;
268 		RID projector;
269 		bool volumetric_enabled;
270 		Color volumetric_color;
271 
LightLight272 		Light() {
273 
274 			vars[VS::LIGHT_PARAM_SPOT_ATTENUATION] = 1;
275 			vars[VS::LIGHT_PARAM_SPOT_ANGLE] = 45;
276 			vars[VS::LIGHT_PARAM_ATTENUATION] = 1.0;
277 			vars[VS::LIGHT_PARAM_ENERGY] = 1.0;
278 			vars[VS::LIGHT_PARAM_RADIUS] = 1.0;
279 			vars[VS::LIGHT_PARAM_SHADOW_Z_OFFSET] = 0.05;
280 
281 			colors[VS::LIGHT_COLOR_DIFFUSE] = Color(1, 1, 1);
282 			colors[VS::LIGHT_COLOR_SPECULAR] = Color(1, 1, 1);
283 			shadow_enabled = false;
284 			volumetric_enabled = false;
285 		}
286 	};
287 
288 	struct Environment {
289 
290 		VS::EnvironmentBG bg_mode;
291 		Variant bg_param[VS::ENV_BG_PARAM_MAX];
292 		bool fx_enabled[VS::ENV_FX_MAX];
293 		Variant fx_param[VS::ENV_FX_PARAM_MAX];
294 
EnvironmentEnvironment295 		Environment() {
296 
297 			bg_mode = VS::ENV_BG_DEFAULT_COLOR;
298 			bg_param[VS::ENV_BG_PARAM_COLOR] = Color(0, 0, 0);
299 			bg_param[VS::ENV_BG_PARAM_TEXTURE] = RID();
300 			bg_param[VS::ENV_BG_PARAM_CUBEMAP] = RID();
301 			bg_param[VS::ENV_BG_PARAM_ENERGY] = 1.0;
302 
303 			for (int i = 0; i < VS::ENV_FX_MAX; i++)
304 				fx_enabled[i] = false;
305 
306 			fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES] = 1;
307 			fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM] = 0.0;
308 			fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD] = 0.5;
309 			fx_param[VS::ENV_FX_PARAM_DOF_BLUR_PASSES] = 1;
310 			fx_param[VS::ENV_FX_PARAM_DOF_BLUR_BEGIN] = 100.0;
311 			fx_param[VS::ENV_FX_PARAM_DOF_BLUR_RANGE] = 10.0;
312 			fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE] = 0.4;
313 			fx_param[VS::ENV_FX_PARAM_HDR_WHITE] = 1.0;
314 			fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD] = 0.95;
315 			fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE] = 0.2;
316 			fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE] = 0.4;
317 			fx_param[VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE] = 8.0;
318 			fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED] = 0.5;
319 			fx_param[VS::ENV_FX_PARAM_FOG_BEGIN] = 100.0;
320 			fx_param[VS::ENV_FX_PARAM_FOG_ATTENUATION] = 1.0;
321 			fx_param[VS::ENV_FX_PARAM_FOG_BEGIN_COLOR] = Color(0, 0, 0);
322 			fx_param[VS::ENV_FX_PARAM_FOG_END_COLOR] = Color(0, 0, 0);
323 			fx_param[VS::ENV_FX_PARAM_FOG_BG] = true;
324 			fx_param[VS::ENV_FX_PARAM_BCS_BRIGHTNESS] = 1.0;
325 			fx_param[VS::ENV_FX_PARAM_BCS_CONTRAST] = 1.0;
326 			fx_param[VS::ENV_FX_PARAM_BCS_SATURATION] = 1.0;
327 		}
328 	};
329 
330 	mutable RID_Owner<Environment> environment_owner;
331 
332 	struct SampledLight {
333 
334 		int w, h;
335 	};
336 
337 	mutable RID_Owner<SampledLight> sampled_light_owner;
338 
339 	struct ShadowBuffer;
340 
341 	struct LightInstance {
342 
343 		struct SplitInfo {
344 
345 			CameraMatrix camera;
346 			Transform transform;
347 			float near;
348 			float far;
349 		};
350 
351 		RID light;
352 		Light *base;
353 		Transform transform;
354 		CameraMatrix projection;
355 
356 		Transform custom_transform;
357 		CameraMatrix custom_projection;
358 
359 		Vector3 light_vector;
360 		Vector3 spot_vector;
361 		float linear_att;
362 
LightInstanceLightInstance363 		LightInstance() { linear_att = 1.0; }
364 	};
365 
366 	mutable RID_Owner<Light> light_owner;
367 	mutable RID_Owner<LightInstance> light_instance_owner;
368 
369 	RID default_material;
370 
371 public:
372 	/* TEXTURE API */
373 
374 	virtual RID texture_create();
375 	virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT);
376 	virtual void texture_set_data(RID p_texture, const Image &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT);
377 	virtual Image texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const;
378 	virtual void texture_set_flags(RID p_texture, uint32_t p_flags);
379 	virtual uint32_t texture_get_flags(RID p_texture) const;
380 	virtual Image::Format texture_get_format(RID p_texture) const;
381 	virtual uint32_t texture_get_width(RID p_texture) const;
382 	virtual uint32_t texture_get_height(RID p_texture) const;
383 	virtual bool texture_has_alpha(RID p_texture) const;
384 	virtual void texture_set_size_override(RID p_texture, int p_width, int p_height);
385 	virtual void texture_set_reload_hook(RID p_texture, ObjectID p_owner, const StringName &p_function) const;
386 
texture_set_path(RID p_texture,const String & p_path)387 	virtual void texture_set_path(RID p_texture, const String &p_path) {}
texture_get_path(RID p_texture)388 	virtual String texture_get_path(RID p_texture) const { return String(); }
texture_debug_usage(List<VS::TextureInfo> * r_info)389 	virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) {}
390 
texture_set_shrink_all_x2_on_set_data(bool p_enable)391 	virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable) {}
392 
393 	/* SHADER API */
394 
395 	virtual RID shader_create(VS::ShaderMode p_mode = VS::SHADER_MATERIAL);
396 
397 	virtual void shader_set_mode(RID p_shader, VS::ShaderMode p_mode);
398 	virtual VS::ShaderMode shader_get_mode(RID p_shader) const;
399 
400 	virtual void shader_set_code(RID p_shader, const String &p_vertex, const String &p_fragment, const String &p_light, int p_vertex_ofs = 0, int p_fragment_ofs = 0, int p_light_ofs = 0);
401 	virtual String shader_get_fragment_code(RID p_shader) const;
402 	virtual String shader_get_vertex_code(RID p_shader) const;
403 	virtual String shader_get_light_code(RID p_shader) const;
404 
405 	virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
406 
407 	virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture);
408 	virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const;
409 
410 	virtual Variant shader_get_default_param(RID p_shader, const StringName &p_name);
411 
412 	/* COMMON MATERIAL API */
413 
414 	virtual RID material_create();
415 
416 	virtual void material_set_shader(RID p_shader_material, RID p_shader);
417 	virtual RID material_get_shader(RID p_shader_material) const;
418 
419 	virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value);
420 	virtual Variant material_get_param(RID p_material, const StringName &p_param) const;
421 
422 	virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag, bool p_enabled);
423 	virtual bool material_get_flag(RID p_material, VS::MaterialFlag p_flag) const;
424 
425 	virtual void material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode);
426 	virtual VS::MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const;
427 
428 	virtual void material_set_blend_mode(RID p_material, VS::MaterialBlendMode p_mode);
429 	virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const;
430 
431 	virtual void material_set_line_width(RID p_material, float p_line_width);
432 	virtual float material_get_line_width(RID p_material) const;
433 
434 	/* MESH API */
435 
436 	virtual RID mesh_create();
437 
438 	virtual void mesh_add_surface(RID p_mesh, VS::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), bool p_alpha_sort = false);
439 	virtual Array mesh_get_surface_arrays(RID p_mesh, int p_surface) const;
440 	virtual Array mesh_get_surface_morph_arrays(RID p_mesh, int p_surface) const;
441 	virtual void mesh_add_custom_surface(RID p_mesh, const Variant &p_dat);
442 
443 	virtual void mesh_set_morph_target_count(RID p_mesh, int p_amount);
444 	virtual int mesh_get_morph_target_count(RID p_mesh) const;
445 
446 	virtual void mesh_set_morph_target_mode(RID p_mesh, VS::MorphTargetMode p_mode);
447 	virtual VS::MorphTargetMode mesh_get_morph_target_mode(RID p_mesh) const;
448 
449 	virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material, bool p_owned = false);
450 	virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const;
451 
452 	virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const;
453 	virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const;
454 	virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const;
455 	virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
456 
457 	virtual void mesh_remove_surface(RID p_mesh, int p_index);
458 	virtual int mesh_get_surface_count(RID p_mesh) const;
459 
460 	virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton = RID()) const;
461 
462 	virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb);
463 	virtual AABB mesh_get_custom_aabb(RID p_mesh) const;
464 
465 	/* MULTIMESH API */
466 
467 	virtual RID multimesh_create();
468 
469 	virtual void multimesh_set_instance_count(RID p_multimesh, int p_count);
470 	virtual int multimesh_get_instance_count(RID p_multimesh) const;
471 
472 	virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh);
473 	virtual void multimesh_set_aabb(RID p_multimesh, const AABB &p_aabb);
474 	virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform);
475 	virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color);
476 
477 	virtual RID multimesh_get_mesh(RID p_multimesh) const;
478 	virtual AABB multimesh_get_aabb(RID p_multimesh) const;
479 	;
480 
481 	virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const;
482 	virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const;
483 
484 	virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible);
485 	virtual int multimesh_get_visible_instances(RID p_multimesh) const;
486 
487 	/* IMMEDIATE API */
488 
489 	virtual RID immediate_create();
490 	virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID());
491 	virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex);
492 	virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal);
493 	virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent);
494 	virtual void immediate_color(RID p_immediate, const Color &p_color);
495 	virtual void immediate_uv(RID p_immediate, const Vector2 &tex_uv);
496 	virtual void immediate_uv2(RID p_immediate, const Vector2 &tex_uv);
497 	virtual void immediate_end(RID p_immediate);
498 	virtual void immediate_clear(RID p_immediate);
499 	virtual void immediate_set_material(RID p_immediate, RID p_material);
500 	virtual RID immediate_get_material(RID p_immediate) const;
501 
502 	virtual AABB immediate_get_aabb(RID p_mesh) const;
503 
504 	/* PARTICLES API */
505 
506 	virtual RID particles_create();
507 
508 	virtual void particles_set_amount(RID p_particles, int p_amount);
509 	virtual int particles_get_amount(RID p_particles) const;
510 
511 	virtual void particles_set_emitting(RID p_particles, bool p_emitting);
512 	virtual bool particles_is_emitting(RID p_particles) const;
513 
514 	virtual void particles_set_visibility_aabb(RID p_particles, const AABB &p_visibility);
515 	virtual AABB particles_get_visibility_aabb(RID p_particles) const;
516 
517 	virtual void particles_set_emission_half_extents(RID p_particles, const Vector3 &p_half_extents);
518 	virtual Vector3 particles_get_emission_half_extents(RID p_particles) const;
519 
520 	virtual void particles_set_emission_base_velocity(RID p_particles, const Vector3 &p_base_velocity);
521 	virtual Vector3 particles_get_emission_base_velocity(RID p_particles) const;
522 
523 	virtual void particles_set_emission_points(RID p_particles, const DVector<Vector3> &p_points);
524 	virtual DVector<Vector3> particles_get_emission_points(RID p_particles) const;
525 
526 	virtual void particles_set_gravity_normal(RID p_particles, const Vector3 &p_normal);
527 	virtual Vector3 particles_get_gravity_normal(RID p_particles) const;
528 
529 	virtual void particles_set_variable(RID p_particles, VS::ParticleVariable p_variable, float p_value);
530 	virtual float particles_get_variable(RID p_particles, VS::ParticleVariable p_variable) const;
531 
532 	virtual void particles_set_randomness(RID p_particles, VS::ParticleVariable p_variable, float p_randomness);
533 	virtual float particles_get_randomness(RID p_particles, VS::ParticleVariable p_variable) const;
534 
535 	virtual void particles_set_color_phase_pos(RID p_particles, int p_phase, float p_pos);
536 	virtual float particles_get_color_phase_pos(RID p_particles, int p_phase) const;
537 
538 	virtual void particles_set_color_phases(RID p_particles, int p_phases);
539 	virtual int particles_get_color_phases(RID p_particles) const;
540 
541 	virtual void particles_set_color_phase_color(RID p_particles, int p_phase, const Color &p_color);
542 	virtual Color particles_get_color_phase_color(RID p_particles, int p_phase) const;
543 
544 	virtual void particles_set_attractors(RID p_particles, int p_attractors);
545 	virtual int particles_get_attractors(RID p_particles) const;
546 
547 	virtual void particles_set_attractor_pos(RID p_particles, int p_attractor, const Vector3 &p_pos);
548 	virtual Vector3 particles_get_attractor_pos(RID p_particles, int p_attractor) const;
549 
550 	virtual void particles_set_attractor_strength(RID p_particles, int p_attractor, float p_force);
551 	virtual float particles_get_attractor_strength(RID p_particles, int p_attractor) const;
552 
553 	virtual void particles_set_material(RID p_particles, RID p_material, bool p_owned = false);
554 	virtual RID particles_get_material(RID p_particles) const;
555 
556 	virtual AABB particles_get_aabb(RID p_particles) const;
557 
558 	virtual void particles_set_height_from_velocity(RID p_particles, bool p_enable);
559 	virtual bool particles_has_height_from_velocity(RID p_particles) const;
560 
561 	virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable);
562 	virtual bool particles_is_using_local_coordinates(RID p_particles) const;
563 
564 	/* SKELETON API */
565 
566 	virtual RID skeleton_create();
567 	virtual void skeleton_resize(RID p_skeleton, int p_bones);
568 	virtual int skeleton_get_bone_count(RID p_skeleton) const;
569 	virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform);
570 	virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone);
571 
572 	/* LIGHT API */
573 
574 	virtual RID light_create(VS::LightType p_type);
575 	virtual VS::LightType light_get_type(RID p_light) const;
576 
577 	virtual void light_set_color(RID p_light, VS::LightColor p_type, const Color &p_color);
578 	virtual Color light_get_color(RID p_light, VS::LightColor p_type) const;
579 
580 	virtual void light_set_shadow(RID p_light, bool p_enabled);
581 	virtual bool light_has_shadow(RID p_light) const;
582 
583 	virtual void light_set_volumetric(RID p_light, bool p_enabled);
584 	virtual bool light_is_volumetric(RID p_light) const;
585 
586 	virtual void light_set_projector(RID p_light, RID p_texture);
587 	virtual RID light_get_projector(RID p_light) const;
588 
589 	virtual void light_set_var(RID p_light, VS::LightParam p_var, float p_value);
590 	virtual float light_get_var(RID p_light, VS::LightParam p_var) const;
591 
592 	virtual void light_set_operator(RID p_light, VS::LightOp p_op);
593 	virtual VS::LightOp light_get_operator(RID p_light) const;
594 
595 	virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode);
596 	virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) const;
597 
598 	virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode);
599 	virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) const;
600 	virtual void light_directional_set_shadow_param(RID p_light, VS::LightDirectionalShadowParam p_param, float p_value);
601 	virtual float light_directional_get_shadow_param(RID p_light, VS::LightDirectionalShadowParam p_param) const;
602 
603 	virtual AABB light_get_aabb(RID p_poly) const;
604 
605 	virtual RID light_instance_create(RID p_light);
606 	virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform);
607 
608 	virtual bool light_instance_has_shadow(RID p_light_instance) const;
609 	virtual bool light_instance_assign_shadow(RID p_light_instance);
610 	virtual ShadowType light_instance_get_shadow_type(RID p_light_instance) const;
611 	virtual int light_instance_get_shadow_passes(RID p_light_instance) const;
612 	virtual bool light_instance_get_pssm_shadow_overlap(RID p_light_instance) const;
613 	virtual void light_instance_set_custom_transform(RID p_light_instance, int p_index, const CameraMatrix &p_camera, const Transform &p_transform, float p_split_near = 0, float p_split_far = 0);
614 	virtual int light_instance_get_shadow_size(RID p_light_instance, int p_index = 0) const { return 1; }
615 
616 	virtual ShadowType light_instance_get_shadow_type(RID p_light_instance, bool p_far = false) const;
617 	virtual void light_instance_set_shadow_transform(RID p_light_instance, int p_index, const CameraMatrix &p_camera, const Transform &p_transform, float p_split_near = 0, float p_split_far = 0);
618 
619 	virtual void shadow_clear_near();
620 	virtual bool shadow_allocate_near(RID p_light);
621 	virtual bool shadow_allocate_far(RID p_light);
622 
623 	/* PARTICLES INSTANCE */
624 
625 	virtual RID particles_instance_create(RID p_particles);
626 	virtual void particles_instance_set_transform(RID p_particles_instance, const Transform &p_transform);
627 
628 	/* VIEWPORT */
629 
630 	virtual RID viewport_data_create();
631 
632 	virtual RID render_target_create();
633 	virtual void render_target_set_size(RID p_render_target, int p_width, int p_height);
634 	virtual RID render_target_get_texture(RID p_render_target) const;
635 	virtual bool render_target_renedered_in_frame(RID p_render_target);
636 
637 	/* RENDER API */
638 	/* all calls (inside begin/end shadow) are always warranted to be in the following order: */
639 
640 	virtual void begin_frame();
641 
642 	virtual void set_viewport(const VS::ViewportRect &p_viewport);
643 	virtual void set_render_target(RID p_render_target, bool p_transparent_bg = false, bool p_vflip = false);
644 	virtual void clear_viewport(const Color &p_color);
645 	virtual void capture_viewport(Image *r_capture);
646 
647 	virtual void begin_scene(RID p_viewport_data, RID p_env, VS::ScenarioDebugMode p_debug);
648 	virtual void begin_shadow_map(RID p_light_instance, int p_shadow_pass);
649 
650 	virtual void set_camera(const Transform &p_world, const CameraMatrix &p_projection, bool p_ortho_hint);
651 
652 	virtual void add_light(RID p_light_instance); ///< all "add_light" calls happen before add_geometry calls
653 
654 	virtual void add_mesh(const RID &p_mesh, const InstanceData *p_data);
655 	virtual void add_multimesh(const RID &p_multimesh, const InstanceData *p_data);
add_immediate(const RID & p_immediate,const InstanceData * p_data)656 	virtual void add_immediate(const RID &p_immediate, const InstanceData *p_data) {}
657 	virtual void add_particles(const RID &p_particle_instance, const InstanceData *p_data);
658 
659 	virtual void end_scene();
660 	virtual void end_shadow_map();
661 
662 	virtual void end_frame();
663 
664 	/* CANVAS API */
665 
666 	virtual void begin_canvas_bg();
667 	virtual void canvas_begin();
668 	virtual void canvas_disable_blending();
669 	virtual void canvas_set_opacity(float p_opacity);
670 	virtual void canvas_set_blend_mode(VS::MaterialBlendMode p_mode);
671 	virtual void canvas_begin_rect(const Matrix32 &p_transform);
672 	virtual void canvas_set_clip(bool p_clip, const Rect2 &p_rect);
673 	virtual void canvas_end_rect();
674 	virtual void canvas_draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width);
675 	virtual void canvas_draw_rect(const Rect2 &p_rect, int p_flags, const Rect2 &p_source, RID p_texture, const Color &p_modulate);
676 	virtual void canvas_draw_style_box(const Rect2 &p_rect, const Rect2 &p_src_region, RID p_texture, const float *p_margins, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1));
677 	virtual void canvas_draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width);
678 	virtual void canvas_draw_polygon(int p_vertex_count, const int *p_indices, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, const RID &p_texture, bool p_singlecolor);
679 	virtual void canvas_set_transform(const Matrix32 &p_transform);
680 
681 	virtual void canvas_render_items(CanvasItem *p_item_list, int p_z, const Color &p_modulate, CanvasLight *p_light);
682 
683 	virtual RID canvas_light_occluder_create();
684 	virtual void canvas_light_occluder_set_polylines(RID p_occluder, const DVector<Vector2> &p_lines);
685 
686 	virtual RID canvas_light_shadow_buffer_create(int p_width);
687 	virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Matrix32 &p_light_xform, int p_light_mask, float p_near, float p_far, CanvasLightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache);
688 
689 	virtual void canvas_debug_viewport_shadows(CanvasLight *p_lights_with_shadow);
690 
691 	/* ENVIRONMENT */
692 
693 	virtual RID environment_create();
694 
695 	virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg);
696 	virtual VS::EnvironmentBG environment_get_background(RID p_env) const;
697 
698 	virtual void environment_set_background_param(RID p_env, VS::EnvironmentBGParam p_param, const Variant &p_value);
699 	virtual Variant environment_get_background_param(RID p_env, VS::EnvironmentBGParam p_param) const;
700 
701 	virtual void environment_set_enable_fx(RID p_env, VS::EnvironmentFx p_effect, bool p_enabled);
702 	virtual bool environment_is_fx_enabled(RID p_env, VS::EnvironmentFx p_effect) const;
703 
704 	virtual void environment_fx_set_param(RID p_env, VS::EnvironmentFxParam p_param, const Variant &p_value);
705 	virtual Variant environment_fx_get_param(RID p_env, VS::EnvironmentFxParam p_param) const;
706 
707 	/* SAMPLED LIGHT */
708 	virtual RID sampled_light_dp_create(int p_width, int p_height);
709 	virtual void sampled_light_dp_update(RID p_sampled_light, const Color *p_data, float p_multiplier);
710 
711 	/*MISC*/
712 
713 	virtual bool is_texture(const RID &p_rid) const;
714 	virtual bool is_material(const RID &p_rid) const;
715 	virtual bool is_mesh(const RID &p_rid) const;
716 	virtual bool is_immediate(const RID &p_rid) const;
717 	virtual bool is_multimesh(const RID &p_rid) const;
718 	virtual bool is_particles(const RID &p_beam) const;
719 
720 	virtual bool is_light(const RID &p_rid) const;
721 	virtual bool is_light_instance(const RID &p_rid) const;
722 	virtual bool is_particles_instance(const RID &p_rid) const;
723 	virtual bool is_skeleton(const RID &p_rid) const;
724 	virtual bool is_environment(const RID &p_rid) const;
725 	virtual bool is_canvas_light_occluder(const RID &p_rid) const;
726 
727 	virtual bool is_shader(const RID &p_rid) const;
728 
729 	virtual void free(const RID &p_rid);
730 
731 	virtual void custom_shade_model_set_shader(int p_model, RID p_shader);
732 	virtual RID custom_shade_model_get_shader(int p_model) const;
733 	virtual void custom_shade_model_set_name(int p_model, const String &p_name);
734 	virtual String custom_shade_model_get_name(int p_model) const;
735 	virtual void custom_shade_model_set_param_info(int p_model, const List<PropertyInfo> &p_info);
736 	virtual void custom_shade_model_get_param_info(int p_model, List<PropertyInfo> *p_info) const;
737 
738 	virtual void set_time_scale(float p_scale);
739 	virtual void init();
740 	virtual void finish();
741 
742 	virtual int get_render_info(VS::RenderInfo p_info);
743 
744 	virtual bool needs_to_draw_next_frame() const;
745 
746 	virtual bool has_feature(VS::Features p_feature) const;
747 
748 	virtual void restore_framebuffer();
749 
750 	RasterizerDummy();
751 	virtual ~RasterizerDummy();
752 };
753 
754 #endif // RASTERIZER_DUMMY_H
755