From 84d734da0e4dc4f0076c61a7178d8ad7b9f3b616 Mon Sep 17 00:00:00 2001 From: reduz Date: Sat, 24 Oct 2020 12:15:43 -0300 Subject: Refactored 2D shader and lighting system -Removed normal/specular properties from nodes -Create CanvasTexture, which can contain normal/specular channels -Refactored, optimized and simplified 2D shaders -Use atlas for light textures. -Use a shadow atlas for shadow textures. -Use both items aboves to make light rendering stateless (faster). -Reorganized uniform sets for more efficiency. --- servers/rendering/rendering_server_raster.h | 37 +++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'servers/rendering/rendering_server_raster.h') diff --git a/servers/rendering/rendering_server_raster.h b/servers/rendering/rendering_server_raster.h index 97477f1d3e..5744b40321 100644 --- a/servers/rendering/rendering_server_raster.h +++ b/servers/rendering/rendering_server_raster.h @@ -529,6 +529,9 @@ public: BIND3(viewport_set_canvas_transform, RID, RID, const Transform2D &) BIND2(viewport_set_transparent_background, RID, bool) + BIND2(viewport_set_default_canvas_item_texture_filter, RID, CanvasItemTextureFilter) + BIND2(viewport_set_default_canvas_item_texture_repeat, RID, CanvasItemTextureRepeat) + BIND2(viewport_set_global_canvas_transform, RID, const Transform2D &) BIND4(viewport_set_canvas_stacking, RID, RID, int, int) BIND2(viewport_set_shadow_atlas_size, RID, int) @@ -684,9 +687,19 @@ public: BIND3(canvas_set_parent, RID, RID, float) BIND1(canvas_set_disable_scale, bool) + BIND0R(RID, canvas_texture_create) + BIND3(canvas_texture_set_channel, RID, CanvasTextureChannel, RID) + BIND3(canvas_texture_set_shading_parameters, RID, const Color &, float) + + BIND2(canvas_texture_set_texture_filter, RID, CanvasItemTextureFilter) + BIND2(canvas_texture_set_texture_repeat, RID, CanvasItemTextureRepeat) + BIND0R(RID, canvas_item_create) BIND2(canvas_item_set_parent, RID, RID) + BIND2(canvas_item_set_default_texture_filter, RID, CanvasItemTextureFilter) + BIND2(canvas_item_set_default_texture_repeat, RID, CanvasItemTextureRepeat) + BIND2(canvas_item_set_visible, RID, bool) BIND2(canvas_item_set_light_mask, RID, int) @@ -701,23 +714,20 @@ public: BIND2(canvas_item_set_draw_behind_parent, RID, bool) - BIND2(canvas_item_set_default_texture_filter, RID, CanvasItemTextureFilter) - BIND2(canvas_item_set_default_texture_repeat, RID, CanvasItemTextureRepeat) - BIND5(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float) BIND4(canvas_item_add_polyline, RID, const Vector &, const Vector &, float) BIND4(canvas_item_add_multiline, RID, const Vector &, const Vector &, float) BIND3(canvas_item_add_rect, RID, const Rect2 &, const Color &) BIND4(canvas_item_add_circle, RID, const Point2 &, float, const Color &) - BIND11(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND12(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, RID, const Color &, bool, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND15(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND11(canvas_item_add_primitive, RID, const Vector &, const Vector &, const Vector &, RID, float, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND10(canvas_item_add_polygon, RID, const Vector &, const Vector &, const Vector &, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND14(canvas_item_add_triangle_array, RID, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, RID, int, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND10(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND8(canvas_item_add_multimesh, RID, RID, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) - BIND8(canvas_item_add_particles, RID, RID, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat) + BIND6(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool) + BIND7(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, bool) + BIND10(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &) + BIND6(canvas_item_add_primitive, RID, const Vector &, const Vector &, const Vector &, RID, float) + BIND5(canvas_item_add_polygon, RID, const Vector &, const Vector &, const Vector &, RID) + BIND9(canvas_item_add_triangle_array, RID, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, RID, int) + BIND5(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID) + BIND3(canvas_item_add_multimesh, RID, RID, RID) + BIND3(canvas_item_add_particles, RID, RID, RID) BIND2(canvas_item_add_set_transform, RID, const Transform2D &) BIND2(canvas_item_add_clip_ignore, RID, bool) BIND2(canvas_item_set_sort_children_by_y, RID, bool) @@ -751,7 +761,6 @@ public: BIND2(canvas_light_set_mode, RID, CanvasLightMode) BIND2(canvas_light_set_shadow_enabled, RID, bool) - BIND2(canvas_light_set_shadow_buffer_size, RID, int) BIND2(canvas_light_set_shadow_filter, RID, CanvasLightShadowFilter) BIND2(canvas_light_set_shadow_color, RID, const Color &) BIND2(canvas_light_set_shadow_smooth, RID, float) @@ -769,6 +778,8 @@ public: BIND2(canvas_occluder_polygon_set_cull_mode, RID, CanvasOccluderPolygonCullMode) + BIND1(canvas_set_shadow_texture_size, int) + /* GLOBAL VARIABLES */ #undef BINDBASE -- cgit v1.2.3