summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/CODEOWNERS11
-rw-r--r--core/io/image.cpp12
-rw-r--r--core/io/image.h4
-rw-r--r--doc/classes/ArrayMesh.xml2
-rw-r--r--doc/classes/Decal.xml2
-rw-r--r--doc/classes/Image.xml8
-rw-r--r--doc/classes/RichTextLabel.xml27
-rw-r--r--doc/classes/TextEdit.xml2
-rw-r--r--doc/classes/TextParagraph.xml90
-rw-r--r--doc/classes/VisualShaderNodeCubemap.xml2
-rw-r--r--doc/classes/VisualShaderNodeTexture.xml2
-rw-r--r--doc/classes/VisualShaderNodeTextureUniform.xml2
-rw-r--r--editor/debugger/editor_visual_profiler.cpp2
-rw-r--r--modules/basis_universal/register_types.cpp2
-rw-r--r--modules/cvtt/image_compress_cvtt.cpp2
-rw-r--r--modules/mono/mono_gd/support/android_support.cpp2
-rw-r--r--modules/mono/utils/mono_reg_utils.cpp2
-rw-r--r--modules/opensimplex/doc_classes/NoiseTexture.xml4
-rw-r--r--modules/opensimplex/noise_texture.cpp26
-rw-r--r--modules/opensimplex/noise_texture.h6
-rw-r--r--modules/text_server_fb/dynamic_font_fb.cpp2
-rw-r--r--modules/text_server_fb/text_server_fb.cpp4
-rw-r--r--platform/javascript/api/javascript_tools_editor_plugin.cpp2
-rw-r--r--platform/javascript/display_server_javascript.cpp2
-rw-r--r--platform/javascript/http_client_javascript.cpp10
-rw-r--r--scene/animation/animation_player.cpp4
-rw-r--r--scene/gui/rich_text_label.cpp113
-rw-r--r--scene/gui/rich_text_label.h17
-rw-r--r--scene/gui/scroll_container.cpp121
-rw-r--r--scene/gui/scroll_container.h1
-rw-r--r--scene/resources/material.cpp12
-rw-r--r--scene/resources/mesh.cpp6
-rw-r--r--scene/resources/mesh.h2
-rw-r--r--scene/resources/text_paragraph.cpp221
-rw-r--r--scene/resources/text_paragraph.h18
-rw-r--r--scene/resources/visual_shader.cpp8
-rw-r--r--scene/resources/visual_shader_nodes.cpp18
-rw-r--r--scene/resources/visual_shader_nodes.h6
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp6
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_forward.cpp10
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp4
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.h2
-rw-r--r--servers/rendering/renderer_rd/shader_compiler_rd.cpp8
-rw-r--r--servers/rendering/renderer_rd/shaders/canvas.glsl4
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward.glsl34
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_inc.glsl2
-rw-r--r--servers/rendering/shader_types.cpp8
47 files changed, 651 insertions, 204 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index e08c8bf9de..7ac70a4367 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -31,6 +31,7 @@ doc_classes/* @godotengine/documentation
/modules/csg/ @BastiaanOlij
/modules/enet/ @godotengine/network
/modules/gdnative/*arvr/ @BastiaanOlij
+/modules/gdnative/text/ @bruvzg
/modules/gdscript/ @vnen
/modules/mbedtls/ @godotengine/network
/modules/mobile_vr/ @BastiaanOlij
@@ -38,13 +39,19 @@ doc_classes/* @godotengine/documentation
/modules/mono/glue/GodotSharp @aaronfranke
/modules/opensimplex/ @JFonS
/modules/regex/ @LeeZH
+/modules/text_server_*/ @bruvzg
/modules/upnp/ @godotengine/network
/modules/websocket/ @godotengine/network
/platform/javascript/ @eska014
/platform/uwp/ @vnen
-/server/physics*/ @reduz @AndreaCatania
-/server/visual*/ @reduz
+/scene/resources/font.* @bruvzg
+/scene/resources/text_line.* @bruvzg
+/scene/resources/text_paragraph.* @bruvzg
+
+/servers/physics*/ @reduz @AndreaCatania
+/servers/text_server.* @bruvzg
+/servers/visual*/ @reduz
/thirdparty/ @akien-mga
diff --git a/core/io/image.cpp b/core/io/image.cpp
index fec7a6a0c5..b3dc835450 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -1753,10 +1753,10 @@ Error Image::generate_mipmaps(bool p_renormalize) {
Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, const Ref<Image> &p_normal_map) {
Vector<double> normal_sat_vec; //summed area table
- double *normal_sat = nullptr; //summed area table for normalmap
+ double *normal_sat = nullptr; //summed area table for normal map
int normal_w = 0, normal_h = 0;
- ERR_FAIL_COND_V_MSG(p_normal_map.is_null() || p_normal_map->is_empty(), ERR_INVALID_PARAMETER, "Must provide a valid normalmap for roughness mipmaps");
+ ERR_FAIL_COND_V_MSG(p_normal_map.is_null() || p_normal_map->is_empty(), ERR_INVALID_PARAMETER, "Must provide a valid normal map for roughness mipmaps");
Ref<Image> nm = p_normal_map->duplicate();
if (nm->is_compressed()) {
@@ -3109,9 +3109,9 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("fix_alpha_edges"), &Image::fix_alpha_edges);
ClassDB::bind_method(D_METHOD("premultiply_alpha"), &Image::premultiply_alpha);
ClassDB::bind_method(D_METHOD("srgb_to_linear"), &Image::srgb_to_linear);
- ClassDB::bind_method(D_METHOD("normalmap_to_xy"), &Image::normalmap_to_xy);
+ ClassDB::bind_method(D_METHOD("normal_map_to_xy"), &Image::normal_map_to_xy);
ClassDB::bind_method(D_METHOD("rgbe_to_srgb"), &Image::rgbe_to_srgb);
- ClassDB::bind_method(D_METHOD("bumpmap_to_normalmap", "bump_scale"), &Image::bumpmap_to_normalmap, DEFVAL(1.0));
+ ClassDB::bind_method(D_METHOD("bump_map_to_normal_map", "bump_scale"), &Image::bump_map_to_normal_map, DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("blit_rect", "src", "src_rect", "dst"), &Image::blit_rect);
ClassDB::bind_method(D_METHOD("blit_rect_mask", "src", "mask", "src_rect", "dst"), &Image::blit_rect_mask);
@@ -3220,7 +3220,7 @@ void Image::set_compress_bptc_func(void (*p_compress_func)(Image *, float, UsedC
_image_compress_bptc_func = p_compress_func;
}
-void Image::normalmap_to_xy() {
+void Image::normal_map_to_xy() {
convert(Image::FORMAT_RGBA8);
{
@@ -3285,7 +3285,7 @@ Ref<Image> Image::get_image_from_mipmap(int p_mipamp) const {
return image;
}
-void Image::bumpmap_to_normalmap(float bump_scale) {
+void Image::bump_map_to_normal_map(float bump_scale) {
ERR_FAIL_COND(!_can_modify(format));
convert(Image::FORMAT_RF);
diff --git a/core/io/image.h b/core/io/image.h
index 7280500c85..aba8f2b0a3 100644
--- a/core/io/image.h
+++ b/core/io/image.h
@@ -350,10 +350,10 @@ public:
void fix_alpha_edges();
void premultiply_alpha();
void srgb_to_linear();
- void normalmap_to_xy();
+ void normal_map_to_xy();
Ref<Image> rgbe_to_srgb();
Ref<Image> get_image_from_mipmap(int p_mipamp) const;
- void bumpmap_to_normalmap(float bump_scale = 1.0);
+ void bump_map_to_normal_map(float bump_scale = 1.0);
void blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest);
void blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest);
diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml
index ef33d7ea77..59502e7017 100644
--- a/doc/classes/ArrayMesh.xml
+++ b/doc/classes/ArrayMesh.xml
@@ -121,7 +121,7 @@
Will perform a UV unwrap on the [ArrayMesh] to prepare the mesh for lightmapping.
</description>
</method>
- <method name="regen_normalmaps">
+ <method name="regen_normal_maps">
<return type="void">
</return>
<description>
diff --git a/doc/classes/Decal.xml b/doc/classes/Decal.xml
index 8107d97b67..ca36b2400c 100644
--- a/doc/classes/Decal.xml
+++ b/doc/classes/Decal.xml
@@ -98,7 +98,7 @@
[Texture2D] with the emission [Color] of the Decal. Either this or the [member texture_emission] must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.
</member>
<member name="texture_normal" type="Texture2D" setter="set_texture" getter="get_texture">
- [Texture2D] with the per-pixel normalmap for the decal. Use this to add extra detail to decals.
+ [Texture2D] with the per-pixel normal map for the decal. Use this to add extra detail to decals.
</member>
<member name="texture_orm" type="Texture2D" setter="set_texture" getter="get_texture">
[Texture2D] storing ambient occlusion, roughness, and metallic for the decal. Use this to add extra detail to decals.
diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml
index 414249f110..3dba5d13aa 100644
--- a/doc/classes/Image.xml
+++ b/doc/classes/Image.xml
@@ -68,13 +68,13 @@
Blits [code]src_rect[/code] area from [code]src[/code] image to this image at the coordinates given by [code]dst[/code]. [code]src[/code] pixel is copied onto [code]dst[/code] if the corresponding [code]mask[/code] pixel's alpha value is not 0. [code]src[/code] image and [code]mask[/code] image [b]must[/b] have the same size (width and height) but they can have different formats.
</description>
</method>
- <method name="bumpmap_to_normalmap">
+ <method name="bump_map_to_normal_map">
<return type="void">
</return>
<argument index="0" name="bump_scale" type="float" default="1.0">
</argument>
<description>
- Converts a bumpmap to a normalmap. A bumpmap provides a height offset per-pixel, while a normalmap provides a normal direction per pixel.
+ Converts a bump map to a normal map. A bump map provides a height offset per-pixel, while a normal map provides a normal direction per pixel.
</description>
</method>
<method name="clear_mipmaps">
@@ -398,11 +398,11 @@
Loads an image from the binary contents of a WebP file.
</description>
</method>
- <method name="normalmap_to_xy">
+ <method name="normal_map_to_xy">
<return type="void">
</return>
<description>
- Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normalmap. A normalmap can add lots of detail to a 3D surface without increasing the polygon count.
+ Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normal map. A normal map can add lots of detail to a 3D surface without increasing the polygon count.
</description>
</method>
<method name="premultiply_alpha">
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index 0fd440fa75..10ee7a1b13 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -164,6 +164,27 @@
Adds a [code][color][/code] tag to the tag stack.
</description>
</method>
+ <method name="push_dropcap">
+ <return type="void">
+ </return>
+ <argument index="0" name="string" type="String">
+ </argument>
+ <argument index="1" name="font" type="Font">
+ </argument>
+ <argument index="2" name="size" type="int">
+ </argument>
+ <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2( 0, 0, 0, 0 )">
+ </argument>
+ <argument index="4" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ </argument>
+ <argument index="5" name="outline_size" type="int" default="0">
+ </argument>
+ <argument index="6" name="outline_color" type="Color" default="Color( 0, 0, 0, 0 )">
+ </argument>
+ <description>
+ Adds a [code][dropcap][/code] tag to the tag stack. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.
+ </description>
+ </method>
<method name="push_font">
<return type="void">
</return>
@@ -525,10 +546,12 @@
</constant>
<constant name="ITEM_RAINBOW" value="20" enum="ItemType">
</constant>
- <constant name="ITEM_CUSTOMFX" value="22" enum="ItemType">
- </constant>
<constant name="ITEM_META" value="21" enum="ItemType">
</constant>
+ <constant name="ITEM_DROPCAP" value="22" enum="ItemType">
+ </constant>
+ <constant name="ITEM_CUSTOMFX" value="23" enum="ItemType">
+ </constant>
</constants>
<theme_items>
<theme_item name="bold_font" type="Font">
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index eedf3b848f..e8a54c6c20 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -404,7 +404,7 @@
Returns an empty [code]Dictionary[/code] if no result was found. Otherwise, returns a [code]Dictionary[/code] containing [code]line[/code] and [code]column[/code] entries, e.g:
[codeblock]
var result = search(key, flags, line, column)
- if !result.empty():
+ if !result.is_empty():
# Result found.
var line_number = result.line
var column_number = result.column
diff --git a/doc/classes/TextParagraph.xml b/doc/classes/TextParagraph.xml
index fabf22eef7..99eb8b81d4 100644
--- a/doc/classes/TextParagraph.xml
+++ b/doc/classes/TextParagraph.xml
@@ -49,6 +49,13 @@
Clears text paragraph (removes text and inline objects).
</description>
</method>
+ <method name="clear_dropcap">
+ <return type="void">
+ </return>
+ <description>
+ Removes dropcap.
+ </description>
+ </method>
<method name="draw" qualifiers="const">
<return type="void">
</return>
@@ -58,8 +65,38 @@
</argument>
<argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
</argument>
+ <argument index="3" name="dc_color" type="Color" default="Color( 1, 1, 1, 1 )">
+ </argument>
<description>
- Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
+ Draw all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
+ </description>
+ </method>
+ <method name="draw_dropcap" qualifiers="const">
+ <return type="void">
+ </return>
+ <argument index="0" name="canvas" type="RID">
+ </argument>
+ <argument index="1" name="pos" type="Vector2">
+ </argument>
+ <argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ </argument>
+ <description>
+ Draw drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
+ </description>
+ </method>
+ <method name="draw_dropcap_outline" qualifiers="const">
+ <return type="void">
+ </return>
+ <argument index="0" name="canvas" type="RID">
+ </argument>
+ <argument index="1" name="pos" type="Vector2">
+ </argument>
+ <argument index="2" name="outline_size" type="int" default="1">
+ </argument>
+ <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
+ </argument>
+ <description>
+ Draw drop cap outline into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
</description>
</method>
<method name="draw_line" qualifiers="const">
@@ -99,14 +136,37 @@
</return>
<argument index="0" name="canvas" type="RID">
</argument>
- <argument index="1" name="outline_size" type="Vector2">
+ <argument index="1" name="pos" type="Vector2">
+ </argument>
+ <argument index="2" name="outline_size" type="int" default="1">
</argument>
- <argument index="2" name="color" type="int" default="1">
+ <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
</argument>
- <argument index="3" name="arg3" type="Color" default="Color( 1, 1, 1, 1 )">
+ <argument index="4" name="dc_color" type="Color" default="Color( 1, 1, 1, 1 )">
</argument>
<description>
- Draw outline of the text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
+ Draw outilines of all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box.
+ </description>
+ </method>
+ <method name="get_dropcap_lines" qualifiers="const">
+ <return type="int">
+ </return>
+ <description>
+ Returns number of lines used by dropcap.
+ </description>
+ </method>
+ <method name="get_dropcap_rid" qualifiers="const">
+ <return type="RID">
+ </return>
+ <description>
+ Return drop cap text buffer RID.
+ </description>
+ </method>
+ <method name="get_dropcap_size" qualifiers="const">
+ <return type="Vector2">
+ </return>
+ <description>
+ Returns drop cap bounding box size.
</description>
</method>
<method name="get_line_ascent" qualifiers="const">
@@ -261,6 +321,26 @@
Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
</description>
</method>
+ <method name="set_dropcap">
+ <return type="bool">
+ </return>
+ <argument index="0" name="text" type="String">
+ </argument>
+ <argument index="1" name="fonts" type="Font">
+ </argument>
+ <argument index="2" name="size" type="int">
+ </argument>
+ <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2( 0, 0, 0, 0 )">
+ </argument>
+ <argument index="4" name="opentype_features" type="Dictionary" default="{
+}">
+ </argument>
+ <argument index="5" name="language" type="String" default="&quot;&quot;">
+ </argument>
+ <description>
+ Sets drop cap, overrides previously set drop cap. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.
+ </description>
+ </method>
<method name="tab_align">
<return type="void">
</return>
diff --git a/doc/classes/VisualShaderNodeCubemap.xml b/doc/classes/VisualShaderNodeCubemap.xml
index b6813bdae8..13b367e8f2 100644
--- a/doc/classes/VisualShaderNodeCubemap.xml
+++ b/doc/classes/VisualShaderNodeCubemap.xml
@@ -34,7 +34,7 @@
<constant name="TYPE_COLOR" value="1" enum="TextureType">
Adds [code]hint_albedo[/code] as hint to the uniform declaration for proper sRGB to linear conversion.
</constant>
- <constant name="TYPE_NORMALMAP" value="2" enum="TextureType">
+ <constant name="TYPE_NORMAL_MAP" value="2" enum="TextureType">
Adds [code]hint_normal[/code] as hint to the uniform declaration, which internally converts the texture for proper usage as normal map.
</constant>
</constants>
diff --git a/doc/classes/VisualShaderNodeTexture.xml b/doc/classes/VisualShaderNodeTexture.xml
index 0c83ffffe4..8fa71b490d 100644
--- a/doc/classes/VisualShaderNodeTexture.xml
+++ b/doc/classes/VisualShaderNodeTexture.xml
@@ -46,7 +46,7 @@
<constant name="TYPE_COLOR" value="1" enum="TextureType">
Adds [code]hint_albedo[/code] as hint to the uniform declaration for proper sRGB to linear conversion.
</constant>
- <constant name="TYPE_NORMALMAP" value="2" enum="TextureType">
+ <constant name="TYPE_NORMAL_MAP" value="2" enum="TextureType">
Adds [code]hint_normal[/code] as hint to the uniform declaration, which internally converts the texture for proper usage as normal map.
</constant>
</constants>
diff --git a/doc/classes/VisualShaderNodeTextureUniform.xml b/doc/classes/VisualShaderNodeTextureUniform.xml
index 107f08ba28..5a7474cca1 100644
--- a/doc/classes/VisualShaderNodeTextureUniform.xml
+++ b/doc/classes/VisualShaderNodeTextureUniform.xml
@@ -25,7 +25,7 @@
<constant name="TYPE_COLOR" value="1" enum="TextureType">
Adds [code]hint_albedo[/code] as hint to the uniform declaration for proper sRGB to linear conversion.
</constant>
- <constant name="TYPE_NORMALMAP" value="2" enum="TextureType">
+ <constant name="TYPE_NORMAL_MAP" value="2" enum="TextureType">
Adds [code]hint_normal[/code] as hint to the uniform declaration, which internally converts the texture for proper usage as normal map.
</constant>
<constant name="TYPE_ANISO" value="3" enum="TextureType">
diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp
index d7a09d6b0c..8e8edbbe9a 100644
--- a/editor/debugger/editor_visual_profiler.cpp
+++ b/editor/debugger/editor_visual_profiler.cpp
@@ -666,7 +666,7 @@ bool EditorVisualProfiler::is_profiling() {
Vector<Vector<String>> EditorVisualProfiler::get_data_as_csv() const {
Vector<Vector<String>> res;
#if 0
- if (frame_metrics.empty()) {
+ if (frame_metrics.is_empty()) {
return res;
}
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
index 27b299a65d..dadcdabf03 100644
--- a/modules/basis_universal/register_types.cpp
+++ b/modules/basis_universal/register_types.cpp
@@ -216,7 +216,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
imgfmt = Image::FORMAT_ETC2_RGBA8;
} else {
- //gles2 most likely, bad for normalmaps, nothing to do about this.
+ //gles2 most likely, bad for normal maps, nothing to do about this.
format = basist::transcoder_texture_format::cTFRGBA32;
imgfmt = Image::FORMAT_RGBA8;
}
diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp
index 787b6dbf80..e34455bca2 100644
--- a/modules/cvtt/image_compress_cvtt.cpp
+++ b/modules/cvtt/image_compress_cvtt.cpp
@@ -168,7 +168,7 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::UsedChann
flags |= cvtt::Flags::BC7_RespectPunchThrough;
- if (p_channels == Image::USED_CHANNELS_RG) { //guessing this is a normalmap
+ if (p_channels == Image::USED_CHANNELS_RG) { //guessing this is a normal map
flags |= cvtt::Flags::Uniform;
}
options.flags = flags;
diff --git a/modules/mono/mono_gd/support/android_support.cpp b/modules/mono/mono_gd/support/android_support.cpp
index bc2ae03299..5bd70748c3 100644
--- a/modules/mono/mono_gd/support/android_support.cpp
+++ b/modules/mono/mono_gd/support/android_support.cpp
@@ -134,7 +134,7 @@ String determine_app_native_lib_dir() {
}
String get_app_native_lib_dir() {
- if (app_native_lib_dir_cache.empty())
+ if (app_native_lib_dir_cache.is_empty())
app_native_lib_dir_cache = determine_app_native_lib_dir();
return app_native_lib_dir_cache;
}
diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp
index 9902744743..52d3fa93be 100644
--- a/modules/mono/utils/mono_reg_utils.cpp
+++ b/modules/mono/utils/mono_reg_utils.cpp
@@ -188,7 +188,7 @@ String find_msbuild_tools_path() {
if (key == "installationPath") {
String val = line.substr(sep_idx + 1, line.length()).strip_edges();
- ERR_BREAK(val.empty());
+ ERR_BREAK(val.is_empty());
if (!val.ends_with("\\")) {
val += "\\";
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml
index c06f3096de..7df261d2ba 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/opensimplex/doc_classes/NoiseTexture.xml
@@ -5,7 +5,7 @@
</brief_description>
<description>
Uses an [OpenSimplexNoise] to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures.
- NoiseTexture can also generate normalmap textures.
+ NoiseTexture can also generate normal map textures.
The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_data] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data:
[codeblock]
var texture = preload("res://noise.tres")
@@ -18,7 +18,7 @@
<methods>
</methods>
<members>
- <member name="as_normalmap" type="bool" setter="set_as_normalmap" getter="is_normalmap" default="false">
+ <member name="as_normal_map" type="bool" setter="set_as_normal_map" getter="is_normal_map" default="false">
If [code]true[/code], the resulting texture contains a normal map created from the original noise interpreted as a bump map.
</member>
<member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength" default="8.0">
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp
index 1181e69cd3..b29c2f84ce 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/opensimplex/noise_texture.cpp
@@ -40,7 +40,7 @@ NoiseTexture::NoiseTexture() {
size = Vector2i(512, 512);
seamless = false;
- as_normalmap = false;
+ as_normal_map = false;
bump_strength = 8.0;
noise = Ref<OpenSimplexNoise>();
@@ -68,8 +68,8 @@ void NoiseTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_seamless", "seamless"), &NoiseTexture::set_seamless);
ClassDB::bind_method(D_METHOD("get_seamless"), &NoiseTexture::get_seamless);
- ClassDB::bind_method(D_METHOD("set_as_normalmap", "as_normalmap"), &NoiseTexture::set_as_normalmap);
- ClassDB::bind_method(D_METHOD("is_normalmap"), &NoiseTexture::is_normalmap);
+ ClassDB::bind_method(D_METHOD("set_as_normal_map", "as_normal_map"), &NoiseTexture::set_as_normal_map);
+ ClassDB::bind_method(D_METHOD("is_normal_map"), &NoiseTexture::is_normal_map);
ClassDB::bind_method(D_METHOD("set_bump_strength", "bump_strength"), &NoiseTexture::set_bump_strength);
ClassDB::bind_method(D_METHOD("get_bump_strength"), &NoiseTexture::get_bump_strength);
@@ -81,14 +81,14 @@ void NoiseTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::INT, "height", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "seamless"), "set_seamless", "get_seamless");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normalmap"), "set_as_normalmap", "is_normalmap");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normal_map"), "set_as_normal_map", "is_normal_map");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bump_strength", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater"), "set_bump_strength", "get_bump_strength");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "OpenSimplexNoise"), "set_noise", "get_noise");
}
void NoiseTexture::_validate_property(PropertyInfo &property) const {
if (property.name == "bump_strength") {
- if (!as_normalmap) {
+ if (!as_normal_map) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
}
}
@@ -148,8 +148,8 @@ Ref<Image> NoiseTexture::_generate_texture() {
image = ref_noise->get_image(size.x, size.y);
}
- if (as_normalmap) {
- image->bumpmap_to_normalmap(bump_strength);
+ if (as_normal_map) {
+ image->bump_map_to_normal_map(bump_strength);
}
return image;
@@ -225,17 +225,17 @@ bool NoiseTexture::get_seamless() {
return seamless;
}
-void NoiseTexture::set_as_normalmap(bool p_as_normalmap) {
- if (p_as_normalmap == as_normalmap) {
+void NoiseTexture::set_as_normal_map(bool p_as_normal_map) {
+ if (p_as_normal_map == as_normal_map) {
return;
}
- as_normalmap = p_as_normalmap;
+ as_normal_map = p_as_normal_map;
_queue_update();
_change_notify();
}
-bool NoiseTexture::is_normalmap() {
- return as_normalmap;
+bool NoiseTexture::is_normal_map() {
+ return as_normal_map;
}
void NoiseTexture::set_bump_strength(float p_bump_strength) {
@@ -243,7 +243,7 @@ void NoiseTexture::set_bump_strength(float p_bump_strength) {
return;
}
bump_strength = p_bump_strength;
- if (as_normalmap) {
+ if (as_normal_map) {
_queue_update();
}
}
diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h
index 73960ba85f..6f0d4aa5e1 100644
--- a/modules/opensimplex/noise_texture.h
+++ b/modules/opensimplex/noise_texture.h
@@ -57,7 +57,7 @@ private:
Ref<OpenSimplexNoise> noise;
Vector2i size;
bool seamless;
- bool as_normalmap;
+ bool as_normal_map;
float bump_strength;
void _thread_done(const Ref<Image> &p_image);
@@ -82,8 +82,8 @@ public:
void set_seamless(bool p_seamless);
bool get_seamless();
- void set_as_normalmap(bool p_as_normalmap);
- bool is_normalmap();
+ void set_as_normal_map(bool p_as_normal_map);
+ bool is_normal_map();
void set_bump_strength(float p_bump_strength);
float get_bump_strength();
diff --git a/modules/text_server_fb/dynamic_font_fb.cpp b/modules/text_server_fb/dynamic_font_fb.cpp
index ca9e5b580b..120774d8e7 100644
--- a/modules/text_server_fb/dynamic_font_fb.cpp
+++ b/modules/text_server_fb/dynamic_font_fb.cpp
@@ -54,7 +54,7 @@ DynamicFontDataFallback::DataAtSize *DynamicFontDataFallback::get_data_for_size(
fds = E->get();
} else {
if (font_mem == nullptr && font_path != String()) {
- if (!font_mem_cache.empty()) {
+ if (!font_mem_cache.is_empty()) {
font_mem = font_mem_cache.ptr();
font_mem_size = font_mem_cache.size();
} else {
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index 675d0e5d4d..0cc56a6735 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -550,7 +550,7 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te
ERR_FAIL_COND_V(!sd, false);
ERR_FAIL_COND_V(p_size <= 0, false);
- if (p_text.empty()) {
+ if (p_text.is_empty()) {
return true;
}
@@ -573,7 +573,7 @@ bool TextServerFallback::shaped_text_add_string(RID p_shaped, const String &p_te
span.fonts.push_back(p_fonts[i]);
}
}
- ERR_FAIL_COND_V(span.fonts.empty(), false);
+ ERR_FAIL_COND_V(span.fonts.is_empty(), false);
span.font_size = p_size;
span.language = p_language;
diff --git a/platform/javascript/api/javascript_tools_editor_plugin.cpp b/platform/javascript/api/javascript_tools_editor_plugin.cpp
index a063718a0c..2096dacdd8 100644
--- a/platform/javascript/api/javascript_tools_editor_plugin.cpp
+++ b/platform/javascript/api/javascript_tools_editor_plugin.cpp
@@ -108,7 +108,7 @@ void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_pa
}
dir->list_dir_begin();
String cur = dir->get_next();
- while (!cur.empty()) {
+ while (!cur.is_empty()) {
String cs = p_path.plus_file(cur);
if (cur == "." || cur == ".." || cur == ".import") {
// Skip
diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp
index 92e13553fc..643530541d 100644
--- a/platform/javascript/display_server_javascript.cpp
+++ b/platform/javascript/display_server_javascript.cpp
@@ -93,7 +93,7 @@ EM_BOOL DisplayServerJavaScript::fullscreen_change_callback(int p_event_type, co
DisplayServerJavaScript *display = get_singleton();
// Empty ID is canvas.
String target_id = String::utf8(p_event->id);
- if (target_id.empty() || target_id == String::utf8(display->canvas_id)) {
+ if (target_id.is_empty() || target_id == String::utf8(display->canvas_id)) {
// This event property is the only reliable data on
// browser fullscreen state.
if (p_event->isFullscreen) {
diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp
index cb0e48b8a9..b81de88fbf 100644
--- a/platform/javascript/http_client_javascript.cpp
+++ b/platform/javascript/http_client_javascript.cpp
@@ -78,15 +78,15 @@ Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Ve
ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(p_method == METHOD_TRACE || p_method == METHOD_CONNECT, ERR_UNAVAILABLE, "HTTP methods TRACE and CONNECT are not supported for the HTML5 platform.");
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(host.empty(), ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(host.is_empty(), ERR_UNCONFIGURED);
ERR_FAIL_COND_V(port < 0, ERR_UNCONFIGURED);
ERR_FAIL_COND_V(!p_url.begins_with("/"), ERR_INVALID_PARAMETER);
String url = (use_tls ? "https://" : "http://") + host + ":" + itos(port) + p_url;
godot_xhr_reset(xhr_id);
godot_xhr_open(xhr_id, _methods[p_method], url.utf8().get_data(),
- username.empty() ? nullptr : username.utf8().get_data(),
- password.empty() ? nullptr : password.utf8().get_data());
+ username.is_empty() ? nullptr : username.utf8().get_data(),
+ password.is_empty() ? nullptr : password.utf8().get_data());
for (int i = 0; i < p_headers.size(); i++) {
int header_separator = p_headers[i].find(": ");
@@ -132,7 +132,7 @@ HTTPClient::Status HTTPClient::get_status() const {
}
bool HTTPClient::has_response() const {
- return !polled_response_header.empty();
+ return !polled_response_header.is_empty();
}
bool HTTPClient::is_response_chunked() const {
@@ -145,7 +145,7 @@ int HTTPClient::get_response_code() const {
}
Error HTTPClient::get_response_headers(List<String> *r_response) {
- if (polled_response_header.empty())
+ if (polled_response_header.is_empty())
return ERR_INVALID_PARAMETER;
Vector<String> header_lines = polled_response_header.split("\r\n", false);
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 159ccae130..506106687b 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -782,13 +782,13 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
delta = next_pos - cd.pos; // Fix delta (after determination of backwards because negative zero is lost here)
if (&cd == &playback.current) {
- if (!backwards && cd.pos <= len && next_pos == len /*&& playback.blend.empty()*/) {
+ if (!backwards && cd.pos <= len && next_pos == len) {
//playback finished
end_reached = true;
end_notify = cd.pos < len; // Notify only if not already at the end
}
- if (backwards && cd.pos >= 0 && next_pos == 0 /*&& playback.blend.empty()*/) {
+ if (backwards && cd.pos >= 0 && next_pos == 0) {
//playback finished
end_reached = true;
end_notify = cd.pos > 0; // Notify only if not already at the beginning
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5258aae80c..82f2106432 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -404,6 +404,18 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
break;
}
switch (it->type) {
+ case ITEM_DROPCAP: {
+ // Add dropcap.
+ const ItemDropcap *dc = (ItemDropcap *)it;
+ if (dc != nullptr) {
+ l.text_buf->set_dropcap(dc->text, dc->font, dc->font_size, dc->dropcap_margins);
+ l.dc_color = dc->color;
+ l.dc_ol_size = dc->ol_size;
+ l.dc_ol_color = dc->ol_color;
+ } else {
+ l.text_buf->clear_dropcap();
+ }
+ } break;
case ITEM_NEWLINE: {
Ref<Font> font = _find_font(it);
if (font.is_null()) {
@@ -679,6 +691,14 @@ void RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_
}
}
+ // Draw dropcap.
+ int dc_lines = l.text_buf->get_dropcap_lines();
+ float h_off = l.text_buf->get_dropcap_size().x;
+ if (l.dc_ol_size > 0) {
+ l.text_buf->draw_dropcap_outline(ci, p_ofs + ((rtl) ? Vector2() : Vector2(l.offset.x, 0)), l.dc_ol_size, l.dc_ol_color);
+ }
+ l.text_buf->draw_dropcap(ci, p_ofs + ((rtl) ? Vector2() : Vector2(l.offset.x, 0)), l.dc_color);
+
// Draw text.
for (int line = 0; line < l.text_buf->get_line_count(); line++) {
RID rid = l.text_buf->get_line_rid(line);
@@ -718,6 +738,14 @@ void RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_
} break;
}
+ if (line <= dc_lines) {
+ if (rtl) {
+ off.x -= h_off;
+ } else {
+ off.x += h_off;
+ }
+ }
+
//draw_rect(Rect2(p_ofs + off, TS->shaped_text_get_size(rid)), Color(1,0,0), false, 2); //DEBUG_RECTS
off.y += TS->shaped_text_get_ascent(rid);
@@ -1742,6 +1770,19 @@ Dictionary RichTextLabel::_find_font_features(Item *p_item) {
return Dictionary();
}
+RichTextLabel::ItemDropcap *RichTextLabel::_find_dc_item(Item *p_item) {
+ Item *item = p_item;
+
+ while (item) {
+ if (item->type == ITEM_DROPCAP) {
+ return static_cast<ItemDropcap *>(item);
+ }
+ item = item->parent;
+ }
+
+ return nullptr;
+}
+
RichTextLabel::ItemList *RichTextLabel::_find_list_item(Item *p_item) {
Item *item = p_item;
@@ -2316,6 +2357,24 @@ bool RichTextLabel::remove_line(const int p_line) {
return true;
}
+void RichTextLabel::push_dropcap(const String &p_string, const Ref<Font> &p_font, int p_size, const Rect2 &p_dropcap_margins, const Color &p_color, int p_ol_size, const Color &p_ol_color) {
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ERR_FAIL_COND(p_string.is_empty());
+ ERR_FAIL_COND(p_font.is_null());
+ ERR_FAIL_COND(p_size <= 0);
+
+ ItemDropcap *item = memnew(ItemDropcap);
+
+ item->text = p_string;
+ item->font = p_font;
+ item->font_size = p_size;
+ item->color = p_color;
+ item->ol_size = p_ol_size;
+ item->ol_color = p_ol_color;
+ item->dropcap_margins = p_dropcap_margins;
+ _add_item(item, false);
+}
+
void RichTextLabel::push_font(const Ref<Font> &p_font) {
ERR_FAIL_COND(current->type == ITEM_TABLE);
ERR_FAIL_COND(p_font.is_null());
@@ -2765,7 +2824,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
tag_stack.pop_front();
pos = brk_end + 1;
- if (tag != "/img") {
+ if (tag != "/img" && tag != "/dropcap") {
pop();
}
@@ -3041,6 +3100,54 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
push_meta(url);
pos = brk_end + 1;
tag_stack.push_front("url");
+ } else if (tag.begins_with("dropcap")) {
+ Vector<String> subtag = tag.substr(5, tag.length()).split(" ");
+ Ref<Font> f = get_theme_font("normal_font");
+ int fs = get_theme_font_size("normal_font_size") * 3;
+ Color color = get_theme_color("default_color");
+ Color outline_color = get_theme_color("outline_color");
+ int outline_size = get_theme_constant("outline_size");
+ Rect2 dropcap_margins = Rect2();
+
+ for (int i = 0; i < subtag.size(); i++) {
+ Vector<String> subtag_a = subtag[i].split("=");
+ if (subtag_a.size() == 2) {
+ if (subtag_a[0] == "font" || subtag_a[0] == "f") {
+ String fnt = subtag_a[1];
+ Ref<Font> font = ResourceLoader::load(fnt, "Font");
+ if (font.is_valid()) {
+ f = font;
+ }
+ } else if (subtag_a[0] == "font_size") {
+ fs = subtag_a[1].to_int();
+ } else if (subtag_a[0] == "margins") {
+ Vector<String> subtag_b = subtag_a[1].split(",");
+ if (subtag_b.size() == 4) {
+ dropcap_margins.position.x = subtag_b[0].to_float();
+ dropcap_margins.position.y = subtag_b[1].to_float();
+ dropcap_margins.size.x = subtag_b[2].to_float();
+ dropcap_margins.size.y = subtag_b[3].to_float();
+ }
+ } else if (subtag_a[0] == "outline_size") {
+ outline_size = subtag_a[1].to_int();
+ } else if (subtag_a[0] == "color") {
+ color = _get_color_from_string(subtag_a[1], color);
+ } else if (subtag_a[0] == "outline_color") {
+ outline_color = _get_color_from_string(subtag_a[1], outline_color);
+ }
+ }
+ }
+ int end = p_bbcode.find("[", brk_end);
+ if (end == -1) {
+ end = p_bbcode.length();
+ }
+
+ String txt = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
+
+ push_dropcap(txt, f, fs, dropcap_margins, color, outline_size, outline_color);
+
+ pos = end;
+ tag_stack.push_front(bbcode_name);
} else if (tag.begins_with("img")) {
VAlign align = VALIGN_TOP;
if (tag.begins_with("img=")) {
@@ -3679,6 +3786,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("push_underline"), &RichTextLabel::push_underline);
ClassDB::bind_method(D_METHOD("push_strikethrough"), &RichTextLabel::push_strikethrough);
ClassDB::bind_method(D_METHOD("push_table", "columns", "inline_align"), &RichTextLabel::push_table, DEFVAL(VALIGN_TOP));
+ ClassDB::bind_method(D_METHOD("push_dropcap", "string", "font", "size", "dropcap_margins", "color", "outline_size", "outline_color"), &RichTextLabel::push_dropcap, DEFVAL(Rect2()), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(0, 0, 0, 0)));
ClassDB::bind_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand);
ClassDB::bind_method(D_METHOD("set_cell_row_background_color", "odd_row_bg", "even_row_bg"), &RichTextLabel::set_cell_row_background_color);
ClassDB::bind_method(D_METHOD("set_cell_border_color", "color"), &RichTextLabel::set_cell_border_color);
@@ -3814,8 +3922,9 @@ void RichTextLabel::_bind_methods() {
BIND_ENUM_CONSTANT(ITEM_WAVE);
BIND_ENUM_CONSTANT(ITEM_TORNADO);
BIND_ENUM_CONSTANT(ITEM_RAINBOW);
- BIND_ENUM_CONSTANT(ITEM_CUSTOMFX);
BIND_ENUM_CONSTANT(ITEM_META);
+ BIND_ENUM_CONSTANT(ITEM_DROPCAP);
+ BIND_ENUM_CONSTANT(ITEM_CUSTOMFX);
}
void RichTextLabel::set_visible_characters(int p_visible) {
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index f1dac69dce..99d8cb5863 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -76,6 +76,7 @@ public:
ITEM_TORNADO,
ITEM_RAINBOW,
ITEM_META,
+ ITEM_DROPCAP,
ITEM_CUSTOMFX
};
@@ -89,6 +90,9 @@ private:
Item *from = nullptr;
Ref<TextParagraph> text_buf;
+ Color dc_color;
+ int dc_ol_size = 0;
+ Color dc_ol_color;
Vector2 offset;
int char_offset = 0;
@@ -140,6 +144,17 @@ private:
ItemText() { type = ITEM_TEXT; }
};
+ struct ItemDropcap : public Item {
+ String text;
+ Ref<Font> font;
+ int font_size;
+ Color color;
+ int ol_size;
+ Color ol_color;
+ Rect2 dropcap_margins;
+ ItemDropcap() { type = ITEM_DROPCAP; }
+ };
+
struct ItemImage : public Item {
Ref<Texture2D> image;
VAlign inline_align = VALIGN_TOP;
@@ -391,6 +406,7 @@ private:
Dictionary _find_font_features(Item *p_item);
int _find_outline_size(Item *p_item);
ItemList *_find_list_item(Item *p_item);
+ ItemDropcap *_find_dc_item(Item *p_item);
int _find_list(Item *p_item, Vector<int> &r_index, Vector<ItemList *> &r_list);
int _find_margin(Item *p_item, const Ref<Font> &p_base_font, int p_base_font_size);
Align _find_align(Item *p_item);
@@ -435,6 +451,7 @@ public:
void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), VAlign p_align = VALIGN_TOP);
void add_newline();
bool remove_line(const int p_line);
+ void push_dropcap(const String &p_string, const Ref<Font> &p_font, int p_size, const Rect2 &p_dropcap_margins = Rect2(), const Color &p_color = Color(1, 1, 1), int p_ol_size = 0, const Color &p_ol_color = Color(0, 0, 0, 0));
void push_font(const Ref<Font> &p_font);
void push_font_size(int p_font_size);
void push_font_features(const Dictionary &p_features);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 35f504812d..af9c5cb0c5 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -264,6 +264,67 @@ void ScrollContainer::_ensure_focused_visible(Control *p_control) {
}
}
+void ScrollContainer::_update_dimensions() {
+ child_max_size = Size2(0, 0);
+ Size2 size = get_size();
+ Point2 ofs;
+
+ Ref<StyleBox> sb = get_theme_stylebox("bg");
+ size -= sb->get_minimum_size();
+ ofs += sb->get_offset();
+ bool rtl = is_layout_rtl();
+
+ if (h_scroll->is_visible_in_tree() && h_scroll->get_parent() == this) { //scrolls may have been moved out for reasons
+ size.y -= h_scroll->get_minimum_size().y;
+ }
+
+ if (v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) { //scrolls may have been moved out for reasons
+ size.x -= v_scroll->get_minimum_size().x;
+ }
+
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = Object::cast_to<Control>(get_child(i));
+ if (!c) {
+ continue;
+ }
+ if (c->is_set_as_top_level()) {
+ continue;
+ }
+ if (c == h_scroll || c == v_scroll) {
+ continue;
+ }
+ Size2 minsize = c->get_combined_minimum_size();
+ child_max_size.x = MAX(child_max_size.x, minsize.x);
+ child_max_size.y = MAX(child_max_size.y, minsize.y);
+
+ Rect2 r = Rect2(-scroll, minsize);
+ if (!scroll_h || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags() & SIZE_EXPAND)) {
+ r.position.x = 0;
+ if (c->get_h_size_flags() & SIZE_EXPAND) {
+ r.size.width = MAX(size.width, minsize.width);
+ } else {
+ r.size.width = minsize.width;
+ }
+ }
+ if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) {
+ r.position.y = 0;
+ if (c->get_v_size_flags() & SIZE_EXPAND) {
+ r.size.height = MAX(size.height, minsize.height);
+ } else {
+ r.size.height = minsize.height;
+ }
+ }
+ r.position += ofs;
+ if (rtl && v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) {
+ r.position.x += v_scroll->get_minimum_size().x;
+ }
+ r.position = r.position.floor();
+ fit_child_in_rect(c, r);
+ }
+
+ update();
+}
+
void ScrollContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
_updating_scrollbars = true;
@@ -272,67 +333,11 @@ void ScrollContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
get_viewport()->connect("gui_focus_changed", callable_mp(this, &ScrollContainer::_ensure_focused_visible));
+ _update_dimensions();
}
if (p_what == NOTIFICATION_SORT_CHILDREN) {
- child_max_size = Size2(0, 0);
- Size2 size = get_size();
- Point2 ofs;
-
- Ref<StyleBox> sb = get_theme_stylebox("bg");
- size -= sb->get_minimum_size();
- ofs += sb->get_offset();
- bool rtl = is_layout_rtl();
-
- if (h_scroll->is_visible_in_tree() && h_scroll->get_parent() == this) { //scrolls may have been moved out for reasons
- size.y -= h_scroll->get_minimum_size().y;
- }
-
- if (v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) { //scrolls may have been moved out for reasons
- size.x -= v_scroll->get_minimum_size().x;
- }
-
- for (int i = 0; i < get_child_count(); i++) {
- Control *c = Object::cast_to<Control>(get_child(i));
- if (!c) {
- continue;
- }
- if (c->is_set_as_top_level()) {
- continue;
- }
- if (c == h_scroll || c == v_scroll) {
- continue;
- }
- Size2 minsize = c->get_combined_minimum_size();
- child_max_size.x = MAX(child_max_size.x, minsize.x);
- child_max_size.y = MAX(child_max_size.y, minsize.y);
-
- Rect2 r = Rect2(-scroll, minsize);
- if (!scroll_h || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags() & SIZE_EXPAND)) {
- r.position.x = 0;
- if (c->get_h_size_flags() & SIZE_EXPAND) {
- r.size.width = MAX(size.width, minsize.width);
- } else {
- r.size.width = minsize.width;
- }
- }
- if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) {
- r.position.y = 0;
- if (c->get_v_size_flags() & SIZE_EXPAND) {
- r.size.height = MAX(size.height, minsize.height);
- } else {
- r.size.height = minsize.height;
- }
- }
- r.position += ofs;
- if (rtl && v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) {
- r.position.x += v_scroll->get_minimum_size().x;
- }
- r.position = r.position.floor();
- fit_child_in_rect(c, r);
- }
-
- update();
+ _update_dimensions();
};
if (p_what == NOTIFICATION_DRAW) {
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 4bf200009e..d2f5e87822 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -69,6 +69,7 @@ protected:
Size2 get_minimum_size() const override;
void _gui_input(const Ref<InputEvent> &p_gui_input);
+ void _update_dimensions();
void _notification(int p_what);
void _scroll_moved(float);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 6e08af23f5..ceb2a708dd 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -969,11 +969,11 @@ void BaseMaterial3D::_update_shader() {
if (features[FEATURE_NORMAL_MAPPING]) {
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
- code += "\tNORMALMAP = triplanar_texture(texture_normal,uv1_power_normal,uv1_triplanar_pos).rgb;\n";
+ code += "\tNORMAL_MAP = triplanar_texture(texture_normal,uv1_power_normal,uv1_triplanar_pos).rgb;\n";
} else {
- code += "\tNORMALMAP = texture(texture_normal,base_uv).rgb;\n";
+ code += "\tNORMAL_MAP = texture(texture_normal,base_uv).rgb;\n";
}
- code += "\tNORMALMAP_DEPTH = normal_scale;\n";
+ code += "\tNORMAL_MAP_DEPTH = normal_scale;\n";
}
if (features[FEATURE_EMISSION]) {
@@ -1000,7 +1000,7 @@ void BaseMaterial3D::_update_shader() {
if (features[FEATURE_REFRACTION]) {
if (features[FEATURE_NORMAL_MAPPING]) {
- code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) );\n";
+ code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMAL_MAP.x + BINORMAL * NORMAL_MAP.y + NORMAL * NORMAL_MAP.z,NORMAL_MAP_DEPTH) );\n";
} else {
code += "\tvec3 ref_normal = NORMAL;\n";
}
@@ -1198,8 +1198,8 @@ void BaseMaterial3D::_update_shader() {
break; // Internal value, skip.
}
- code += "\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n";
- code += "\tNORMALMAP = mix(NORMALMAP,detail_norm,detail_mask_tex.r);\n";
+ code += "\tvec3 detail_norm = mix(NORMAL_MAP,detail_norm_tex.rgb,detail_tex.a);\n";
+ code += "\tNORMAL_MAP = mix(NORMAL_MAP,detail_norm,detail_mask_tex.r);\n";
code += "\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n";
}
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 8d101aa8d3..d7a33a87d9 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -1350,7 +1350,7 @@ AABB ArrayMesh::get_custom_aabb() const {
return custom_aabb;
}
-void ArrayMesh::regen_normalmaps() {
+void ArrayMesh::regen_normal_maps() {
if (surfaces.size() == 0) {
return;
}
@@ -1586,8 +1586,8 @@ void ArrayMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_trimesh_shape"), &ArrayMesh::create_trimesh_shape);
ClassDB::bind_method(D_METHOD("create_convex_shape"), &ArrayMesh::create_convex_shape);
ClassDB::bind_method(D_METHOD("create_outline", "margin"), &ArrayMesh::create_outline);
- ClassDB::bind_method(D_METHOD("regen_normalmaps"), &ArrayMesh::regen_normalmaps);
- ClassDB::set_method_flags(get_class_static(), _scs_create("regen_normalmaps"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ClassDB::bind_method(D_METHOD("regen_normal_maps"), &ArrayMesh::regen_normal_maps);
+ ClassDB::set_method_flags(get_class_static(), _scs_create("regen_normal_maps"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
ClassDB::bind_method(D_METHOD("lightmap_unwrap", "transform", "texel_size"), &ArrayMesh::lightmap_unwrap);
ClassDB::set_method_flags(get_class_static(), _scs_create("lightmap_unwrap"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
ClassDB::bind_method(D_METHOD("get_faces"), &ArrayMesh::get_faces);
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index b7f60bf814..32d071199b 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -252,7 +252,7 @@ public:
AABB get_aabb() const override;
virtual RID get_rid() const override;
- void regen_normalmaps();
+ void regen_normal_maps();
Error lightmap_unwrap(const Transform &p_base_transform = Transform(), float p_texel_size = 0.05);
Error lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache, const Transform &p_base_transform = Transform(), float p_texel_size = 0.05);
diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp
index 2624cc8b0b..60e86e95db 100644
--- a/scene/resources/text_paragraph.cpp
+++ b/scene/resources/text_paragraph.cpp
@@ -55,6 +55,9 @@ void TextParagraph::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bidi_override", "override"), &TextParagraph::_set_bidi_override);
+ ClassDB::bind_method(D_METHOD("set_dropcap", "text", "fonts", "size", "dropcap_margins", "opentype_features", "language"), &TextParagraph::set_dropcap, DEFVAL(Rect2()), DEFVAL(Dictionary()), DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("clear_dropcap"), &TextParagraph::clear_dropcap);
+
ClassDB::bind_method(D_METHOD("add_string", "text", "fonts", "size", "opentype_features", "language"), &TextParagraph::add_string, DEFVAL(Dictionary()), DEFVAL(""));
ClassDB::bind_method(D_METHOD("add_object", "key", "size", "inline_align", "length"), &TextParagraph::add_object, DEFVAL(VALIGN_CENTER), DEFVAL(1));
ClassDB::bind_method(D_METHOD("resize_object", "key", "size", "inline_align"), &TextParagraph::resize_object, DEFVAL(VALIGN_CENTER));
@@ -81,6 +84,7 @@ void TextParagraph::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &TextParagraph::get_rid);
ClassDB::bind_method(D_METHOD("get_line_rid", "line"), &TextParagraph::get_line_rid);
+ ClassDB::bind_method(D_METHOD("get_dropcap_rid"), &TextParagraph::get_dropcap_rid);
ClassDB::bind_method(D_METHOD("get_line_count"), &TextParagraph::get_line_count);
@@ -94,12 +98,18 @@ void TextParagraph::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_line_underline_position", "line"), &TextParagraph::get_line_underline_position);
ClassDB::bind_method(D_METHOD("get_line_underline_thickness", "line"), &TextParagraph::get_line_underline_thickness);
- ClassDB::bind_method(D_METHOD("draw", "canvas", "pos", "color"), &TextParagraph::draw, DEFVAL(Color(1, 1, 1)));
- ClassDB::bind_method(D_METHOD("draw_outline", "canvas", "outline_size", "color"), &TextParagraph::draw_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1)));
+ ClassDB::bind_method(D_METHOD("get_dropcap_size"), &TextParagraph::get_dropcap_size);
+ ClassDB::bind_method(D_METHOD("get_dropcap_lines"), &TextParagraph::get_dropcap_lines);
+
+ ClassDB::bind_method(D_METHOD("draw", "canvas", "pos", "color", "dc_color"), &TextParagraph::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(Color(1, 1, 1)));
+ ClassDB::bind_method(D_METHOD("draw_outline", "canvas", "pos", "outline_size", "color", "dc_color"), &TextParagraph::draw_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1)), DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("draw_line", "canvas", "pos", "line", "color"), &TextParagraph::draw_line, DEFVAL(Color(1, 1, 1)));
ClassDB::bind_method(D_METHOD("draw_line_outline", "canvas", "pos", "line", "outline_size", "color"), &TextParagraph::draw_line_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1)));
+ ClassDB::bind_method(D_METHOD("draw_dropcap", "canvas", "pos", "color"), &TextParagraph::draw_dropcap, DEFVAL(Color(1, 1, 1)));
+ ClassDB::bind_method(D_METHOD("draw_dropcap_outline", "canvas", "pos", "outline_size", "color"), &TextParagraph::draw_dropcap_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1)));
+
ClassDB::bind_method(D_METHOD("hit_test", "coords"), &TextParagraph::hit_test);
}
@@ -114,7 +124,43 @@ void TextParagraph::_shape_lines() {
TS->shaped_text_tab_align(rid, tab_stops);
}
- Vector<Vector2i> line_breaks = TS->shaped_text_get_line_breaks(rid, width, 0, flags);
+ float h_offset = 0.f;
+ float v_offset = 0.f;
+ int start = 0;
+ dropcap_lines = 0;
+
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).x + dropcap_margins.size.x + dropcap_margins.position.x;
+ v_offset = TS->shaped_text_get_size(dropcap_rid).y + dropcap_margins.size.y + dropcap_margins.position.y;
+ } else {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).y + dropcap_margins.size.y + dropcap_margins.position.y;
+ v_offset = TS->shaped_text_get_size(dropcap_rid).x + dropcap_margins.size.x + dropcap_margins.position.x;
+ }
+
+ if (h_offset > 0) {
+ // Dropcap, flow around.
+ Vector<Vector2i> line_breaks = TS->shaped_text_get_line_breaks(rid, width - h_offset, 0, flags);
+ for (int i = 0; i < line_breaks.size(); i++) {
+ RID line = TS->shaped_text_substr(rid, line_breaks[i].x, line_breaks[i].y - line_breaks[i].x);
+ float h = (TS->shaped_text_get_orientation(line) == TextServer::ORIENTATION_HORIZONTAL) ? TS->shaped_text_get_size(line).y : TS->shaped_text_get_size(line).x;
+ if (v_offset < h) {
+ TS->free(line);
+ break;
+ }
+ if (!tab_stops.is_empty()) {
+ TS->shaped_text_tab_align(line, tab_stops);
+ }
+ if (align == HALIGN_FILL && (line_breaks.size() == 1 || i < line_breaks.size() - 1)) {
+ TS->shaped_text_fit_to_width(line, width - h_offset, flags);
+ }
+ dropcap_lines++;
+ v_offset -= h;
+ start = line_breaks[i].y;
+ lines.push_back(line);
+ }
+ }
+ // Use fixed for the rest of lines.
+ Vector<Vector2i> line_breaks = TS->shaped_text_get_line_breaks(rid, width, start, flags);
for (int i = 0; i < line_breaks.size(); i++) {
RID line = TS->shaped_text_substr(rid, line_breaks[i].x, line_breaks[i].y - line_breaks[i].x);
if (!tab_stops.is_empty()) {
@@ -139,6 +185,10 @@ RID TextParagraph::get_line_rid(int p_line) const {
return lines[p_line];
}
+RID TextParagraph::get_dropcap_rid() const {
+ return dropcap_rid;
+}
+
void TextParagraph::clear() {
spacing_top = 0;
spacing_bottom = 0;
@@ -147,10 +197,12 @@ void TextParagraph::clear() {
}
lines.clear();
TS->shaped_text_clear(rid);
+ TS->shaped_text_clear(dropcap_rid);
}
void TextParagraph::set_preserve_invalid(bool p_enabled) {
TS->shaped_text_set_preserve_invalid(rid, p_enabled);
+ TS->shaped_text_set_preserve_invalid(dropcap_rid, p_enabled);
dirty_lines = true;
}
@@ -160,6 +212,7 @@ bool TextParagraph::get_preserve_invalid() const {
void TextParagraph::set_preserve_control(bool p_enabled) {
TS->shaped_text_set_preserve_control(rid, p_enabled);
+ TS->shaped_text_set_preserve_control(dropcap_rid, p_enabled);
dirty_lines = true;
}
@@ -169,6 +222,7 @@ bool TextParagraph::get_preserve_control() const {
void TextParagraph::set_direction(TextServer::Direction p_direction) {
TS->shaped_text_set_direction(rid, p_direction);
+ TS->shaped_text_set_direction(dropcap_rid, p_direction);
dirty_lines = true;
}
@@ -179,6 +233,7 @@ TextServer::Direction TextParagraph::get_direction() const {
void TextParagraph::set_orientation(TextServer::Orientation p_orientation) {
TS->shaped_text_set_orientation(rid, p_orientation);
+ TS->shaped_text_set_orientation(dropcap_rid, p_orientation);
dirty_lines = true;
}
@@ -187,6 +242,20 @@ TextServer::Orientation TextParagraph::get_orientation() const {
return TS->shaped_text_get_orientation(rid);
}
+bool TextParagraph::set_dropcap(const String &p_text, const Ref<Font> &p_fonts, int p_size, const Rect2 &p_dropcap_margins, const Dictionary &p_opentype_features, const String &p_language) {
+ TS->shaped_text_clear(dropcap_rid);
+ dropcap_margins = p_dropcap_margins;
+ bool res = TS->shaped_text_add_string(dropcap_rid, p_text, p_fonts->get_rids(), p_size, p_opentype_features, p_language);
+ dirty_lines = true;
+ return res;
+}
+
+void TextParagraph::clear_dropcap() {
+ dropcap_margins = Rect2();
+ TS->shaped_text_clear(dropcap_rid);
+ dirty_lines = true;
+}
+
bool TextParagraph::add_string(const String &p_text, const Ref<Font> &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language) {
bool res = TS->shaped_text_add_string(rid, p_text, p_fonts->get_rids(), p_size, p_opentype_features, p_language);
spacing_top = p_fonts->get_spacing(Font::SPACING_TOP);
@@ -359,16 +428,57 @@ float TextParagraph::get_line_underline_thickness(int p_line) const {
return TS->shaped_text_get_underline_thickness(lines[p_line]);
}
-void TextParagraph::draw(RID p_canvas, const Vector2 &p_pos, const Color &p_color) const {
+Size2 TextParagraph::get_dropcap_size() const {
+ return TS->shaped_text_get_size(dropcap_rid) + dropcap_margins.size + dropcap_margins.position;
+}
+
+int TextParagraph::get_dropcap_lines() const {
+ return dropcap_lines;
+}
+
+void TextParagraph::draw(RID p_canvas, const Vector2 &p_pos, const Color &p_color, const Color &p_dc_color) const {
const_cast<TextParagraph *>(this)->_shape_lines();
Vector2 ofs = p_pos;
+ float h_offset = 0.f;
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).x + dropcap_margins.size.x + dropcap_margins.position.x;
+ } else {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).y + dropcap_margins.size.y + dropcap_margins.position.y;
+ }
+
+ if (h_offset > 0) {
+ // Draw dropcap.
+ Vector2 dc_off = ofs;
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_RTL) {
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ dc_off.x += width - h_offset;
+ } else {
+ dc_off.y += width - h_offset;
+ }
+ }
+ TS->shaped_text_draw(dropcap_rid, p_canvas, dc_off + Vector2(0, TS->shaped_text_get_ascent(dropcap_rid) + dropcap_margins.size.y + dropcap_margins.position.y / 2), -1, -1, p_dc_color);
+ }
+
for (int i = 0; i < lines.size(); i++) {
+ float l_width = width;
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
ofs.x = p_pos.x;
ofs.y += TS->shaped_text_get_ascent(lines[i]) + spacing_top;
+ if (i <= dropcap_lines) {
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_LTR) {
+ ofs.x -= h_offset;
+ }
+ l_width -= h_offset;
+ }
} else {
ofs.y = p_pos.y;
ofs.x += TS->shaped_text_get_ascent(lines[i]) + spacing_top;
+ if (i <= dropcap_lines) {
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_LTR) {
+ ofs.x -= h_offset;
+ }
+ l_width -= h_offset;
+ }
}
float length = TS->shaped_text_get_width(lines[i]);
if (width > 0) {
@@ -378,16 +488,16 @@ void TextParagraph::draw(RID p_canvas, const Vector2 &p_pos, const Color &p_colo
break;
case HALIGN_CENTER: {
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
- ofs.x += Math::floor((width - length) / 2.0);
+ ofs.x += Math::floor((l_width - length) / 2.0);
} else {
- ofs.y += Math::floor((width - length) / 2.0);
+ ofs.y += Math::floor((l_width - length) / 2.0);
}
} break;
case HALIGN_RIGHT: {
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
- ofs.x += width - length;
+ ofs.x += l_width - length;
} else {
- ofs.y += width - length;
+ ofs.y += l_width - length;
}
} break;
}
@@ -398,7 +508,7 @@ void TextParagraph::draw(RID p_canvas, const Vector2 &p_pos, const Color &p_colo
} else {
clip_l = MAX(0, p_pos.y - ofs.y);
}
- TS->shaped_text_draw(lines[i], p_canvas, ofs, clip_l, clip_l + width, p_color);
+ TS->shaped_text_draw(lines[i], p_canvas, ofs, clip_l, clip_l + l_width, p_color);
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
ofs.x = p_pos.x;
ofs.y += TS->shaped_text_get_descent(lines[i]) + spacing_bottom;
@@ -409,16 +519,50 @@ void TextParagraph::draw(RID p_canvas, const Vector2 &p_pos, const Color &p_colo
}
}
-void TextParagraph::draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size, const Color &p_color) const {
+void TextParagraph::draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size, const Color &p_color, const Color &p_dc_color) const {
const_cast<TextParagraph *>(this)->_shape_lines();
Vector2 ofs = p_pos;
+
+ float h_offset = 0.f;
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).x + dropcap_margins.size.x + dropcap_margins.position.x;
+ } else {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).y + dropcap_margins.size.y + dropcap_margins.position.y;
+ }
+
+ if (h_offset > 0) {
+ // Draw dropcap.
+ Vector2 dc_off = ofs;
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_RTL) {
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ dc_off.x += width - h_offset;
+ } else {
+ dc_off.y += width - h_offset;
+ }
+ }
+ TS->shaped_text_draw_outline(dropcap_rid, p_canvas, dc_off + Vector2(dropcap_margins.position.x, TS->shaped_text_get_ascent(dropcap_rid) + dropcap_margins.position.y), -1, -1, p_outline_size, p_dc_color);
+ }
+
for (int i = 0; i < lines.size(); i++) {
+ float l_width = width;
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
ofs.x = p_pos.x;
ofs.y += TS->shaped_text_get_ascent(lines[i]) + spacing_top;
+ if (i <= dropcap_lines) {
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_LTR) {
+ ofs.x -= h_offset;
+ }
+ l_width -= h_offset;
+ }
} else {
ofs.y = p_pos.y;
ofs.x += TS->shaped_text_get_ascent(lines[i]) + spacing_top;
+ if (i <= dropcap_lines) {
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_LTR) {
+ ofs.x -= h_offset;
+ }
+ l_width -= h_offset;
+ }
}
float length = TS->shaped_text_get_width(lines[i]);
if (width > 0) {
@@ -428,16 +572,16 @@ void TextParagraph::draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outli
break;
case HALIGN_CENTER: {
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
- ofs.x += Math::floor((width - length) / 2.0);
+ ofs.x += Math::floor((l_width - length) / 2.0);
} else {
- ofs.y += Math::floor((width - length) / 2.0);
+ ofs.y += Math::floor((l_width - length) / 2.0);
}
} break;
case HALIGN_RIGHT: {
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
- ofs.x += width - length;
+ ofs.x += l_width - length;
} else {
- ofs.y += width - length;
+ ofs.y += l_width - length;
}
} break;
}
@@ -448,7 +592,7 @@ void TextParagraph::draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outli
} else {
clip_l = MAX(0, p_pos.y - ofs.y);
}
- TS->shaped_text_draw_outline(lines[i], p_canvas, ofs, clip_l, clip_l + width, p_outline_size, p_color);
+ TS->shaped_text_draw_outline(lines[i], p_canvas, ofs, clip_l, clip_l + l_width, p_outline_size, p_color);
if (TS->shaped_text_get_orientation(lines[i]) == TextServer::ORIENTATION_HORIZONTAL) {
ofs.x = p_pos.x;
ofs.y += TS->shaped_text_get_descent(lines[i]) + spacing_bottom;
@@ -485,11 +629,56 @@ int TextParagraph::hit_test(const Point2 &p_coords) const {
return TS->shaped_text_get_range(rid).y;
}
+void TextParagraph::draw_dropcap(RID p_canvas, const Vector2 &p_pos, const Color &p_color) const {
+ Vector2 ofs = p_pos;
+ float h_offset = 0.f;
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).x + dropcap_margins.size.x + dropcap_margins.position.x;
+ } else {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).y + dropcap_margins.size.y + dropcap_margins.position.y;
+ }
+
+ if (h_offset > 0) {
+ // Draw dropcap.
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_RTL) {
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ ofs.x += width - h_offset;
+ } else {
+ ofs.y += width - h_offset;
+ }
+ }
+ TS->shaped_text_draw(dropcap_rid, p_canvas, ofs + Vector2(dropcap_margins.position.x, TS->shaped_text_get_ascent(dropcap_rid) + dropcap_margins.position.y), -1, -1, p_color);
+ }
+}
+
+void TextParagraph::draw_dropcap_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size, const Color &p_color) const {
+ Vector2 ofs = p_pos;
+ float h_offset = 0.f;
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).x + dropcap_margins.size.x + dropcap_margins.position.x;
+ } else {
+ h_offset = TS->shaped_text_get_size(dropcap_rid).y + dropcap_margins.size.y + dropcap_margins.position.y;
+ }
+
+ if (h_offset > 0) {
+ // Draw dropcap.
+ if (TS->shaped_text_get_direction(dropcap_rid) == TextServer::DIRECTION_RTL) {
+ if (TS->shaped_text_get_orientation(dropcap_rid) == TextServer::ORIENTATION_HORIZONTAL) {
+ ofs.x += width - h_offset;
+ } else {
+ ofs.y += width - h_offset;
+ }
+ }
+ TS->shaped_text_draw_outline(dropcap_rid, p_canvas, ofs + Vector2(dropcap_margins.position.x, TS->shaped_text_get_ascent(dropcap_rid) + dropcap_margins.position.y), -1, -1, p_outline_size, p_color);
+ }
+}
+
void TextParagraph::draw_line(RID p_canvas, const Vector2 &p_pos, int p_line, const Color &p_color) const {
const_cast<TextParagraph *>(this)->_shape_lines();
ERR_FAIL_COND(p_line < 0 || p_line >= lines.size());
Vector2 ofs = p_pos;
+
if (TS->shaped_text_get_orientation(lines[p_line]) == TextServer::ORIENTATION_HORIZONTAL) {
ofs.y += TS->shaped_text_get_ascent(lines[p_line]) + spacing_top;
} else {
@@ -521,6 +710,7 @@ TextParagraph::TextParagraph(const String &p_text, const Ref<Font> &p_fonts, int
TextParagraph::TextParagraph() {
rid = TS->create_shaped_text();
+ dropcap_rid = TS->create_shaped_text();
}
TextParagraph::~TextParagraph() {
@@ -529,4 +719,5 @@ TextParagraph::~TextParagraph() {
}
lines.clear();
TS->free(rid);
+ TS->free(dropcap_rid);
}
diff --git a/scene/resources/text_paragraph.h b/scene/resources/text_paragraph.h
index f7f49e9058..38b2bd9a1d 100644
--- a/scene/resources/text_paragraph.h
+++ b/scene/resources/text_paragraph.h
@@ -39,6 +39,10 @@
class TextParagraph : public Reference {
GDCLASS(TextParagraph, Reference);
+ RID dropcap_rid;
+ int dropcap_lines = 0;
+ Rect2 dropcap_margins;
+
RID rid;
Vector<RID> lines;
int spacing_top = 0;
@@ -60,6 +64,7 @@ protected:
public:
RID get_rid() const;
RID get_line_rid(int p_line) const;
+ RID get_dropcap_rid() const;
void clear();
@@ -77,6 +82,9 @@ public:
void set_bidi_override(const Vector<Vector2i> &p_override);
+ bool set_dropcap(const String &p_text, const Ref<Font> &p_fonts, int p_size, const Rect2 &p_dropcap_margins = Rect2(), const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "");
+ void clear_dropcap();
+
bool add_string(const String &p_text, const Ref<Font> &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "");
bool add_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER, int p_length = 1);
bool resize_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER);
@@ -108,12 +116,18 @@ public:
float get_line_underline_position(int p_line) const;
float get_line_underline_thickness(int p_line) const;
- void draw(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1)) const;
- void draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const;
+ Size2 get_dropcap_size() const;
+ int get_dropcap_lines() const;
+
+ void draw(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1), const Color &p_dc_color = Color(1, 1, 1)) const;
+ void draw_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1), const Color &p_dc_color = Color(1, 1, 1)) const;
void draw_line(RID p_canvas, const Vector2 &p_pos, int p_line, const Color &p_color = Color(1, 1, 1)) const;
void draw_line_outline(RID p_canvas, const Vector2 &p_pos, int p_line, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const;
+ void draw_dropcap(RID p_canvas, const Vector2 &p_pos, const Color &p_color = Color(1, 1, 1)) const;
+ void draw_dropcap_outline(RID p_canvas, const Vector2 &p_pos, int p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const;
+
int hit_test(const Point2 &p_coords) const;
void _set_bidi_override(const Array &p_override);
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 50f456bc59..e519647504 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -2359,8 +2359,8 @@ const VisualShaderNodeOutput::Port VisualShaderNodeOutput::ports[] = {
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "ao", "AO" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "NORMAL" },
- { Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normalmap", "NORMALMAP" },
- { Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "normalmap_depth", "NORMALMAP_DEPTH" },
+ { Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal_map", "NORMAL_MAP" },
+ { Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "normal_map_depth", "NORMAL_MAP_DEPTH" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "rim", "RIM" },
{ Shader::MODE_SPATIAL, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "rim_tint", "RIM_TINT" },
@@ -2386,8 +2386,8 @@ const VisualShaderNodeOutput::Port VisualShaderNodeOutput::ports[] = {
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "color", "COLOR.rgb" },
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "COLOR.a" },
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal", "NORMAL" },
- { Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normalmap", "NORMALMAP" },
- { Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "normalmap_depth", "NORMALMAP_DEPTH" },
+ { Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_VECTOR, "normal_map", "NORMAL_MAP" },
+ { Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_FRAGMENT, VisualShaderNode::PORT_TYPE_SCALAR, "normal_map_depth", "NORMAL_MAP_DEPTH" },
// Canvas Item, Light
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR, "light", "LIGHT.rgb" },
{ Shader::MODE_CANVAS_ITEM, VisualShader::TYPE_LIGHT, VisualShaderNode::PORT_TYPE_SCALAR, "light_alpha", "LIGHT.a" },
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index a3358ea8c7..0550059c8b 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -480,7 +480,7 @@ String VisualShaderNodeTexture::generate_global(Shader::Mode p_mode, VisualShade
case TYPE_COLOR:
u += " : hint_albedo";
break;
- case TYPE_NORMALMAP:
+ case TYPE_NORMAL_MAP:
u += " : hint_normal";
break;
}
@@ -780,7 +780,7 @@ void VisualShaderNodeTexture::_bind_methods() {
BIND_ENUM_CONSTANT(SOURCE_PORT);
BIND_ENUM_CONSTANT(TYPE_DATA);
BIND_ENUM_CONSTANT(TYPE_COLOR);
- BIND_ENUM_CONSTANT(TYPE_NORMALMAP);
+ BIND_ENUM_CONSTANT(TYPE_NORMAL_MAP);
}
VisualShaderNodeTexture::VisualShaderNodeTexture() {
@@ -1181,7 +1181,7 @@ String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShade
case TYPE_COLOR:
u += " : hint_albedo";
break;
- case TYPE_NORMALMAP:
+ case TYPE_NORMAL_MAP:
u += " : hint_normal";
break;
}
@@ -1310,7 +1310,7 @@ void VisualShaderNodeCubemap::_bind_methods() {
BIND_ENUM_CONSTANT(TYPE_DATA);
BIND_ENUM_CONSTANT(TYPE_COLOR);
- BIND_ENUM_CONSTANT(TYPE_NORMALMAP);
+ BIND_ENUM_CONSTANT(TYPE_NORMAL_MAP);
}
VisualShaderNodeCubemap::VisualShaderNodeCubemap() {
@@ -4350,7 +4350,7 @@ String VisualShaderNodeTextureUniform::generate_global(Shader::Mode p_mode, Visu
code += " : hint_albedo;\n";
}
break;
- case TYPE_NORMALMAP:
+ case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
case TYPE_ANISO:
@@ -4431,7 +4431,7 @@ void VisualShaderNodeTextureUniform::_bind_methods() {
BIND_ENUM_CONSTANT(TYPE_DATA);
BIND_ENUM_CONSTANT(TYPE_COLOR);
- BIND_ENUM_CONSTANT(TYPE_NORMALMAP);
+ BIND_ENUM_CONSTANT(TYPE_NORMAL_MAP);
BIND_ENUM_CONSTANT(TYPE_ANISO);
BIND_ENUM_CONSTANT(COLOR_DEFAULT_WHITE);
@@ -4608,7 +4608,7 @@ String VisualShaderNodeTexture2DArrayUniform::generate_global(Shader::Mode p_mod
else
code += " : hint_albedo;\n";
break;
- case TYPE_NORMALMAP:
+ case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
case TYPE_ANISO:
@@ -4676,7 +4676,7 @@ String VisualShaderNodeTexture3DUniform::generate_global(Shader::Mode p_mode, Vi
else
code += " : hint_albedo;\n";
break;
- case TYPE_NORMALMAP:
+ case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
case TYPE_ANISO:
@@ -4746,7 +4746,7 @@ String VisualShaderNodeCubemapUniform::generate_global(Shader::Mode p_mode, Visu
code += " : hint_albedo;\n";
}
break;
- case TYPE_NORMALMAP:
+ case TYPE_NORMAL_MAP:
code += " : hint_normal;\n";
break;
case TYPE_ANISO:
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 4b39c76388..39f463e1ef 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -236,7 +236,7 @@ public:
enum TextureType {
TYPE_DATA,
TYPE_COLOR,
- TYPE_NORMALMAP,
+ TYPE_NORMAL_MAP,
};
private:
@@ -412,7 +412,7 @@ public:
enum TextureType {
TYPE_DATA,
TYPE_COLOR,
- TYPE_NORMALMAP
+ TYPE_NORMAL_MAP
};
private:
@@ -1834,7 +1834,7 @@ public:
enum TextureType {
TYPE_DATA,
TYPE_COLOR,
- TYPE_NORMALMAP,
+ TYPE_NORMAL_MAP,
TYPE_ANISO,
};
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index 415dfcc5f1..8efd7b2dca 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -2488,8 +2488,8 @@ RendererCanvasRenderRD::RendererCanvasRenderRD(RendererStorageRD *p_storage) {
actions.renames["COLOR"] = "color";
actions.renames["NORMAL"] = "normal";
- actions.renames["NORMALMAP"] = "normal_map";
- actions.renames["NORMALMAP_DEPTH"] = "normal_depth";
+ actions.renames["NORMAL_MAP"] = "normal_map";
+ actions.renames["NORMAL_MAP_DEPTH"] = "normal_depth";
actions.renames["TEXTURE"] = "color_texture";
actions.renames["TEXTURE_PIXEL_SIZE"] = "draw_data.color_texture_pixel_size";
actions.renames["NORMAL_TEXTURE"] = "normal_texture";
@@ -2517,7 +2517,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD(RendererStorageRD *p_storage) {
actions.usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
actions.usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
actions.usage_defines["NORMAL"] = "#define NORMAL_USED\n";
- actions.usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
+ actions.usage_defines["NORMAL_MAP"] = "#define NORMAL_MAP_USED\n";
actions.usage_defines["LIGHT"] = "#define LIGHT_SHADER_CODE_USED\n";
actions.render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_forward.cpp b/servers/rendering/renderer_rd/renderer_scene_render_forward.cpp
index 80bd429f2f..e4f418bdb3 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_forward.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_forward.cpp
@@ -112,7 +112,7 @@ void RendererSceneRenderForward::ShaderData::set_code(const String &p_code) {
actions.usage_flag_pointers["TIME"] = &uses_time;
actions.usage_flag_pointers["ROUGHNESS"] = &uses_roughness;
actions.usage_flag_pointers["NORMAL"] = &uses_normal;
- actions.usage_flag_pointers["NORMALMAP"] = &uses_normal;
+ actions.usage_flag_pointers["NORMAL_MAP"] = &uses_normal;
actions.usage_flag_pointers["POINT_SIZE"] = &uses_point_size;
actions.usage_flag_pointers["POINT_COORD"] = &uses_point_size;
@@ -2867,8 +2867,8 @@ RendererSceneRenderForward::RendererSceneRenderForward(RendererStorageRD *p_stor
actions.renames["FRAGCOORD"] = "gl_FragCoord";
actions.renames["FRONT_FACING"] = "gl_FrontFacing";
- actions.renames["NORMALMAP"] = "normalmap";
- actions.renames["NORMALMAP_DEPTH"] = "normaldepth";
+ actions.renames["NORMAL_MAP"] = "normal_map";
+ actions.renames["NORMAL_MAP_DEPTH"] = "normal_map_depth";
actions.renames["ALBEDO"] = "albedo";
actions.renames["ALPHA"] = "alpha";
actions.renames["METALLIC"] = "metallic";
@@ -2935,8 +2935,8 @@ RendererSceneRenderForward::RendererSceneRenderForward(RendererStorageRD *p_stor
actions.usage_defines["CUSTOM1"] = "#define CUSTOM1\n";
actions.usage_defines["CUSTOM2"] = "#define CUSTOM2\n";
actions.usage_defines["CUSTOM3"] = "#define CUSTOM3\n";
- actions.usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
- actions.usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
+ actions.usage_defines["NORMAL_MAP"] = "#define NORMAL_MAP_USED\n";
+ actions.usage_defines["NORMAL_MAP_DEPTH"] = "@NORMAL_MAP";
actions.usage_defines["COLOR"] = "#define COLOR_USED\n";
actions.usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
actions.usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index 9da4fab75d..4e4c941431 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -1234,7 +1234,7 @@ void RendererStorageRD::canvas_texture_set_channel(RID p_canvas_texture, RS::Can
ct->diffuse = p_texture;
} break;
case RS::CANVAS_TEXTURE_CHANNEL_NORMAL: {
- ct->normalmap = p_texture;
+ ct->normal_map = p_texture;
} break;
case RS::CANVAS_TEXTURE_CHANNEL_SPECULAR: {
ct->specular = p_texture;
@@ -1316,7 +1316,7 @@ bool RendererStorageRD::canvas_texture_get_uniform_set(RID p_texture, RS::Canvas
u.uniform_type = RD::UNIFORM_TYPE_TEXTURE;
u.binding = 1;
- t = texture_owner.getornull(ct->normalmap);
+ t = texture_owner.getornull(ct->normal_map);
if (!t) {
u.ids.push_back(texture_rd_get_default(DEFAULT_RD_TEXTURE_NORMAL));
ct->use_normal_cache = false;
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h
index 328e4d4999..8cc33f0880 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.h
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.h
@@ -187,7 +187,7 @@ private:
struct CanvasTexture {
RID diffuse;
- RID normalmap;
+ RID normal_map;
RID specular;
Color specular_color = Color(1, 1, 1, 1);
float shininess = 1.0;
diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp
index ae392b7586..e6b6bf26b3 100644
--- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp
+++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp
@@ -1340,8 +1340,8 @@ ShaderCompilerRD::ShaderCompilerRD() {
actions[RS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
actions[RS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
- actions[RS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
- actions[RS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
+ actions[RS::SHADER_SPATIAL].renames["NORMAL_MAP"] = "normal_map";
+ actions[RS::SHADER_SPATIAL].renames["NORMAL_MAP_DEPTH"] = "normal_map_depth";
actions[RS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
actions[RS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
actions[RS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
@@ -1387,8 +1387,8 @@ ShaderCompilerRD::ShaderCompilerRD() {
actions[RS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
actions[RS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
actions[RS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
- actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
- actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
+ actions[RS::SHADER_SPATIAL].usage_defines["NORMAL_MAP"] = "#define ENABLE_NORMAL_MAP\n";
+ actions[RS::SHADER_SPATIAL].usage_defines["NORMAL_MAP_DEPTH"] = "@NORMAL_MAP";
actions[RS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
actions[RS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
actions[RS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
diff --git a/servers/rendering/renderer_rd/shaders/canvas.glsl b/servers/rendering/renderer_rd/shaders/canvas.glsl
index 7808e7ed52..2a7cae3b4c 100644
--- a/servers/rendering/renderer_rd/shaders/canvas.glsl
+++ b/servers/rendering/renderer_rd/shaders/canvas.glsl
@@ -499,7 +499,7 @@ void main() {
{
float normal_depth = 1.0;
-#if defined(NORMALMAP_USED)
+#if defined(NORMAL_MAP_USED)
vec3 normal_map = vec3(0.0, 0.0, 1.0);
normal_used = true;
#endif
@@ -510,7 +510,7 @@ FRAGMENT_SHADER_CODE
/* clang-format on */
-#if defined(NORMALMAP_USED)
+#if defined(NORMAL_MAP_USED)
normal = mix(vec3(0.0, 0.0, 1.0), normal_map * vec3(2.0, -2.0, 1.0) - vec3(1.0, -1.0, 0.0), normal_depth);
#endif
}
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward.glsl b/servers/rendering/renderer_rd/shaders/scene_forward.glsl
index a7fe86b029..05f7637478 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward.glsl
@@ -16,7 +16,7 @@ layout(location = 0) in vec3 vertex_attrib;
layout(location = 1) in vec3 normal_attrib;
#endif
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
layout(location = 2) in vec4 tangent_attrib;
#endif
@@ -76,7 +76,7 @@ layout(location = 3) out vec2 uv_interp;
layout(location = 4) out vec2 uv2_interp;
#endif
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
layout(location = 5) out vec3 tangent_interp;
layout(location = 6) out vec3 binormal_interp;
#endif
@@ -155,7 +155,7 @@ void main() {
vec3 normal = normal_attrib * 2.0 - 1.0;
#endif
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
vec3 tangent = tangent_attrib.xyz * 2.0 - 1.0;
float binormalf = tangent_attrib.a * 2.0 - 1.0;
vec3 binormal = normalize(cross(normal, tangent) * binormalf);
@@ -179,7 +179,7 @@ void main() {
vertex = (vec4(vertex, 1.0) * m).xyz;
normal = (vec4(normal, 0.0) * m).xyz;
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
tangent = (vec4(tangent, 0.0) * m).xyz;
binormal = (vec4(binormal, 0.0) * m).xyz;
@@ -208,7 +208,7 @@ void main() {
normal = world_normal_matrix * normal;
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
tangent = world_normal_matrix * tangent;
binormal = world_normal_matrix * binormal;
@@ -239,7 +239,7 @@ VERTEX_SHADER_CODE
#endif
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
binormal = modelview_normal * binormal;
tangent = modelview_normal * tangent;
@@ -251,7 +251,7 @@ VERTEX_SHADER_CODE
vertex = (scene_data.inv_camera_matrix * vec4(vertex, 1.0)).xyz;
normal = mat3(scene_data.inverse_normal_matrix) * normal;
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
binormal = mat3(scene_data.camera_inverse_binormal_matrix) * binormal;
tangent = mat3(scene_data.camera_inverse_tangent_matrix) * tangent;
@@ -263,7 +263,7 @@ VERTEX_SHADER_CODE
normal_interp = normal;
#endif
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
tangent_interp = tangent;
binormal_interp = binormal;
#endif
@@ -340,7 +340,7 @@ layout(location = 3) in vec2 uv_interp;
layout(location = 4) in vec2 uv2_interp;
#endif
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
layout(location = 5) in vec3 tangent_interp;
layout(location = 6) in vec3 binormal_interp;
#endif
@@ -1819,7 +1819,7 @@ void main() {
float alpha = 1.0;
-#if defined(TANGENT_USED) || defined(NORMALMAP_USED) || defined(LIGHT_ANISOTROPY_USED)
+#if defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED)
vec3 binormal = normalize(binormal_interp);
vec3 tangent = normalize(tangent_interp);
#else
@@ -1850,12 +1850,12 @@ void main() {
vec4 color = color_interp;
#endif
-#if defined(NORMALMAP_USED)
+#if defined(NORMAL_MAP_USED)
- vec3 normalmap = vec3(0.5);
+ vec3 normal_map = vec3(0.5);
#endif
- float normaldepth = 1.0;
+ float normal_depth = 1.0;
vec2 screen_uv = gl_FragCoord.xy * scene_data.screen_pixel_size + scene_data.screen_pixel_size * 0.5; //account for center
@@ -1926,12 +1926,12 @@ FRAGMENT_SHADER_CODE
#endif // !USE_SHADOW_TO_OPACITY
-#ifdef NORMALMAP_USED
+#ifdef NORMAL_MAP_USED
- normalmap.xy = normalmap.xy * 2.0 - 1.0;
- normalmap.z = sqrt(max(0.0, 1.0 - dot(normalmap.xy, normalmap.xy))); //always ignore Z, as it can be RG packed, Z may be pos/neg, etc.
+ normal_map.xy = normal_map.xy * 2.0 - 1.0;
+ normal_map.z = sqrt(max(0.0, 1.0 - dot(normal_map.xy, normal_map.xy))); //always ignore Z, as it can be RG packed, Z may be pos/neg, etc.
- normal = normalize(mix(normal, tangent * normalmap.x + binormal * normalmap.y + normal * normalmap.z, normaldepth));
+ normal = normalize(mix(normal, tangent * normal_map.x + binormal * normal_map.y + normal * normal_map.z, normal_depth));
#endif
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_inc.glsl
index fdc9941bba..17ed22f58a 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_inc.glsl
@@ -5,7 +5,7 @@
#include "cluster_data_inc.glsl"
-#if !defined(MODE_RENDER_DEPTH) || defined(MODE_RENDER_MATERIAL) || defined(MODE_RENDER_SDF) || defined(MODE_RENDER_NORMAL_ROUGHNESS) || defined(MODE_RENDER_GIPROBE) || defined(TANGENT_USED) || defined(NORMALMAP_USED)
+#if !defined(MODE_RENDER_DEPTH) || defined(MODE_RENDER_MATERIAL) || defined(MODE_RENDER_SDF) || defined(MODE_RENDER_NORMAL_ROUGHNESS) || defined(MODE_RENDER_GIPROBE) || defined(TANGENT_USED) || defined(NORMAL_MAP_USED)
#ifndef NORMAL_USED
#define NORMAL_USED
#endif
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
index 0c9b2ddf2f..e7ab758192 100644
--- a/servers/rendering/shader_types.cpp
+++ b/servers/rendering/shader_types.cpp
@@ -94,8 +94,8 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3;
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3;
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3);
- shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL_MAP"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL_MAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);
@@ -242,8 +242,8 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["LIGHT_VERTEX"] = ShaderLanguage::TYPE_VEC3;
shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3;
- shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL_MAP"] = ShaderLanguage::TYPE_VEC3;
+ shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL_MAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4;
shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);