Godot version:
v3.2.3.stable.mono.official
OS/device including version:
Microsoft Windows 10 Pro, version 10.0.18363 Build 18363
Issue description:
It's all in the title: Line2D nodes don't make use of AtlasTexture Region and Margin properties and instead use the full texture.
This makes using them with sprite sheets a hassle as you can't specify what rect is visible.
It seems that this issue has existed for at least a couple years now, judging from this Q&A page.
Steps to reproduce:
Minimal reproduction project:
AtlasBug.zip
This issue has the same cause as the following areas of the engine:
get_data() will also return the whole texture, and get_rid() will give you the RID of the whole texture too.And the reason is simple: AtlasTexture is NOT a texture. It inherits Texture but that's only a facade. It barely just holds a reference to a real texture, with a rectangle, and just so happen to work if used on some simple 2D nodes because these nodes happen to generate their simple quads with special UVs. VisualServer doesnt even have a concept of it.
For anything more complex, it would be a shitshow of geometry workarounds to implement throughout the upper layer of the engine. Basically, it was never made to work together with other types of nodes. It's meant only for nodes that render simple, regular quads, which don't repeat.
I believe if we want to solve this, either we have to:
sampler2D would be bound to an image region (instead of the whole image), which would make things work naturally without any UV hacks, even with repeat or clamp flags on (does Vulkan allow to do this now?). This would make such texture behave like a regular full texture without having to break up vertices to account for repetition or clamping.In the case of Line2D specifically:
In the current state of the renderer, it would be possible to make the STRETCH texture mode work without much changes, by interpolating through the sub-rectangle of the texture instead of the full region, since the algorithm does that already. But TILE won't work for the reasons cited above, so you will need a dedicated texture or a shader.
Most helpful comment
This issue has the same cause as the following areas of the engine:
get_data()will also return the whole texture, andget_rid()will give you the RID of the whole texture too.And the reason is simple:
AtlasTextureis NOT a texture. It inheritsTexturebut that's only a facade. It barely just holds a reference to a real texture, with a rectangle, and just so happen to work if used on some simple 2D nodes because these nodes happen to generate their simple quads with special UVs.VisualServerdoesnt even have a concept of it.For anything more complex, it would be a shitshow of geometry workarounds to implement throughout the upper layer of the engine. Basically, it was never made to work together with other types of nodes. It's meant only for nodes that render simple, regular quads, which don't repeat.
I believe if we want to solve this, either we have to:
sampler2Dwould be bound to an image region (instead of the whole image), which would make things work naturally without any UV hacks, even with repeat or clamp flags on (does Vulkan allow to do this now?). This would make such texture behave like a regular full texture without having to break up vertices to account for repetition or clamping.In the case of
Line2Dspecifically:In the current state of the renderer, it would be possible to make the
STRETCHtexture mode work without much changes, by interpolating through the sub-rectangle of the texture instead of the full region, since the algorithm does that already. ButTILEwon't work for the reasons cited above, so you will need a dedicated texture or a shader.