2017-03-05 15:47:28 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* rasterizer_canvas_gles3.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2017-03-05 15:47:28 +01:00
|
|
|
/*************************************************************************/
|
2019-01-01 12:53:14 +01:00
|
|
|
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
2017-03-05 15:47:28 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
#ifndef RASTERIZERCANVASGLES3_H
|
|
|
|
#define RASTERIZERCANVASGLES3_H
|
|
|
|
|
|
|
|
#include "rasterizer_storage_gles3.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "servers/visual/rasterizer.h"
|
2018-09-11 18:13:45 +02:00
|
|
|
|
2017-06-23 17:03:41 +02:00
|
|
|
#include "shaders/canvas_shadow.glsl.gen.h"
|
2018-09-30 22:51:50 +02:00
|
|
|
#include "shaders/lens_distorted.glsl.gen.h"
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2017-06-27 03:58:03 +02:00
|
|
|
class RasterizerSceneGLES3;
|
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
class RasterizerCanvasGLES3 : public RasterizerCanvas {
|
|
|
|
public:
|
|
|
|
struct CanvasItemUBO {
|
|
|
|
|
|
|
|
float projection_matrix[16];
|
2017-06-16 13:29:43 +02:00
|
|
|
float time;
|
2017-08-11 19:09:55 +02:00
|
|
|
uint8_t padding[12];
|
2016-10-03 21:33:42 +02:00
|
|
|
};
|
|
|
|
|
2017-06-27 03:58:03 +02:00
|
|
|
RasterizerSceneGLES3 *scene_render;
|
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
struct Data {
|
|
|
|
|
|
|
|
GLuint canvas_quad_vertices;
|
|
|
|
GLuint canvas_quad_array;
|
|
|
|
|
2017-06-12 23:56:16 +02:00
|
|
|
GLuint polygon_buffer;
|
|
|
|
GLuint polygon_buffer_quad_arrays[4];
|
|
|
|
GLuint polygon_buffer_pointer_array;
|
|
|
|
GLuint polygon_index_buffer;
|
2017-06-21 21:25:45 +02:00
|
|
|
|
|
|
|
GLuint particle_quad_vertices;
|
|
|
|
GLuint particle_quad_array;
|
|
|
|
|
2017-06-12 23:56:16 +02:00
|
|
|
uint32_t polygon_buffer_size;
|
2016-11-23 00:51:56 +01:00
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
} data;
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
CanvasItemUBO canvas_item_ubo_data;
|
|
|
|
GLuint canvas_item_ubo;
|
|
|
|
bool canvas_texscreen_used;
|
|
|
|
CanvasShaderGLES3 canvas_shader;
|
|
|
|
CanvasShadowShaderGLES3 canvas_shadow_shader;
|
2018-09-30 22:51:50 +02:00
|
|
|
LensDistortedShaderGLES3 lens_shader;
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
bool using_texture_rect;
|
2017-06-22 04:37:25 +02:00
|
|
|
bool using_ninepatch;
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
RID current_tex;
|
2017-06-18 04:26:49 +02:00
|
|
|
RID current_normal;
|
2016-10-03 21:33:42 +02:00
|
|
|
RasterizerStorageGLES3::Texture *current_tex_ptr;
|
|
|
|
|
|
|
|
Transform vp;
|
|
|
|
|
|
|
|
Color canvas_item_modulate;
|
2017-01-11 04:52:51 +01:00
|
|
|
Transform2D extra_matrix;
|
|
|
|
Transform2D final_transform;
|
2018-05-03 22:29:15 +02:00
|
|
|
bool using_skeleton;
|
|
|
|
Transform2D skeleton_transform;
|
2018-05-04 14:32:40 +02:00
|
|
|
Transform2D skeleton_transform_inverse;
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
} state;
|
|
|
|
|
|
|
|
RasterizerStorageGLES3 *storage;
|
|
|
|
|
|
|
|
struct LightInternal : public RID_Data {
|
|
|
|
|
|
|
|
struct UBOData {
|
|
|
|
|
|
|
|
float light_matrix[16];
|
|
|
|
float local_matrix[16];
|
|
|
|
float shadow_matrix[16];
|
|
|
|
float color[4];
|
|
|
|
float shadow_color[4];
|
|
|
|
float light_pos[2];
|
|
|
|
float shadowpixel_size;
|
|
|
|
float shadow_gradient;
|
|
|
|
float light_height;
|
|
|
|
float light_outside_alpha;
|
|
|
|
float shadow_distance_mult;
|
2017-08-11 19:09:55 +02:00
|
|
|
uint8_t padding[4];
|
2016-10-03 21:33:42 +02:00
|
|
|
} ubo_data;
|
|
|
|
|
|
|
|
GLuint ubo;
|
|
|
|
};
|
|
|
|
|
|
|
|
RID_Owner<LightInternal> light_internal_owner;
|
|
|
|
|
|
|
|
virtual RID light_internal_create();
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void light_internal_update(RID p_rid, Light *p_light);
|
2016-10-03 21:33:42 +02:00
|
|
|
virtual void light_internal_free(RID p_rid);
|
|
|
|
|
|
|
|
virtual void canvas_begin();
|
|
|
|
virtual void canvas_end();
|
|
|
|
|
2017-06-22 04:37:25 +02:00
|
|
|
_FORCE_INLINE_ void _set_texture_rect_mode(bool p_enable, bool p_ninepatch = false);
|
2018-05-15 13:35:46 +02:00
|
|
|
_FORCE_INLINE_ RasterizerStorageGLES3::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map, bool p_force = false);
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
|
2018-05-03 22:29:15 +02:00
|
|
|
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const int *p_bones, const float *p_weights);
|
2017-07-01 02:30:17 +02:00
|
|
|
_FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_FORCE_INLINE_ void _canvas_item_render_commands(Item *p_item, Item *current_clip, bool &reclip);
|
2017-06-27 03:58:03 +02:00
|
|
|
_FORCE_INLINE_ void _copy_texscreen(const Rect2 &p_rect);
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2018-02-21 21:23:27 +01:00
|
|
|
virtual void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_transform);
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow);
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual 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);
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
virtual void reset_canvas();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src);
|
2018-09-30 22:51:50 +02:00
|
|
|
void draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample);
|
2016-10-03 21:33:42 +02:00
|
|
|
|
|
|
|
void initialize();
|
|
|
|
void finalize();
|
|
|
|
|
2017-08-07 23:06:57 +02:00
|
|
|
virtual void draw_window_margins(int *black_margin, RID *black_image);
|
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
RasterizerCanvasGLES3();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RASTERIZERCANVASGLES3_H
|