Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygon2D texture not displaying correctly. #25049

Open
ghost opened this issue Jan 16, 2019 · 15 comments
Open

Polygon2D texture not displaying correctly. #25049

ghost opened this issue Jan 16, 2019 · 15 comments

Comments

@ghost
Copy link

ghost commented Jan 16, 2019

Godot version:

9c17688

OS/device including version:

Win10 64bit

Issue description:

When using a atlas/region texture resource for the polygon texture, it works fine in the polygon editor, but shows the whole source texture in the canvas editor and in game.

From this:

godot_master_2019-01-17_01-21-26

To this:

godot_master_2019-01-17_01-21-40

Steps to reproduce:

  1. Create an atlas texture resource.
  2. Assign it to a Polygon2D's texture.
  3. Create the points of the polygon.

Minimal reproduction project:

3.1 Polygon Texture Issue.zip

@akien-mga akien-mga added this to the 3.1 milestone Jan 17, 2019
@reduz
Copy link
Member

reduz commented Jan 18, 2019

They are not really meant to work together. AtlasTexture only really works for sprites and UI, not meshes or polygon.

It could probably hacked in Polygon by detecting its an atlas and ajusting the UVs I guess...

@ghost
Copy link
Author

ghost commented Jan 18, 2019

Oh, wondering why the UV/Poly editor handles it. Thanks. It would be very useful if it works out.

The new 2D mesh invites texture parts over sprite sheets, and we use Texture Packer to try to make very tightly packed atlas textures.

I'm not sure of the backend rendering performance, but I'm only assuming that it would still be an issue to load thousands of little textures rather than a few dozen larger ones. We'd really like to make use of mesh warping on these atlas parts to solve very difficult and time consuming blending issues on our characters.

@reduz
Copy link
Member

reduz commented Jan 18, 2019

In any case, not urgent for 3.1

@reduz reduz modified the milestones: 3.1, 3.2 Jan 18, 2019
@reduz
Copy link
Member

reduz commented Jan 18, 2019

@avencherus you can now draw on a single image and then use the polygon drawn tool from the UV editor to make your character, no need for atlas

@ghost
Copy link
Author

ghost commented Jan 19, 2019

@reduz Thanks, had a blind spot there, hadn't actually considered that. XD I think since most the textures are intended to be assigned to Sprites. Should be able to re-organize parts into their own texture for polygons and maybe write an import tool.

@akien-mga
Copy link
Member

Still reproducible in the current master branch.

@jonbonazza
Copy link
Contributor

Radial TextureProgress still shows whole Atlas Texture instead of selected region, but only on values 100 > x > 0. if value is 100 or 0, it works fine.

@ghost
Copy link
Author

ghost commented Feb 2, 2020

Cannot think of a work around for when using Polygon2D as a seamless looping texture, other than not use an atlas for certain textures.

image

@KoBeWi
Copy link
Member

KoBeWi commented Dec 25, 2020

Still valid in 3.2.4 beta4

@mdarius31
Copy link

Still valid in 3.4.4

@Calinou Calinou modified the milestone: 3.x Jul 24, 2022
@Calinou
Copy link
Member

Calinou commented Jul 24, 2022

Related to #34837.

@aXu-AP
Copy link
Contributor

aXu-AP commented Oct 21, 2023

Should this be solved by adding support for AtlasTexture in CanvasItem.draw_polygon (or in RendererCanvasCull)? Code from #66352 could be moved into that class, enabling the fix on larger scale. Needs to check if there's other places where this was supported explicitly.

Other solution is to modify the editor to show the whole texture instead of the AtlasTexture part of it. Ie. what you
see is what you get, and polygons don't support AtlasTexture.

@arkology
Copy link
Contributor

Should this be solved by adding support for AtlasTexture in CanvasItem.draw_polygon (or in RendererCanvasCull)? Code from #66352 could be moved into that class, enabling the fix on larger scale.

As I see this is done in #91724 but issue is still there,

@aXu-AP
Copy link
Contributor

aXu-AP commented Nov 25, 2024

I see, I was wrong. Polygon2D constructs a mesh internally and draws it.

RS::get_singleton()->canvas_item_add_mesh(get_canvas_item(), mesh, Transform2D(), Color(1, 1, 1), texture.is_valid() ? texture->get_rid() : RID());

I think this is needed for multiple polygons and bone support, but it means that the support has to be explicit 👀

@arkology
Copy link
Contributor

arkology commented Dec 6, 2024

I think we could add uv remapping to CanvasItem::draw_mesh same way as it is done for CanvasItem::draw_polygon several lines of code above. This will be most universal and simple (in terms of code readability) way to implement it.
BUT it will be necessary to create a copy of entry mesh to keep original mesh unchanged.
So there's question. Is it OK to create a copy of mesh inside CanvasItem::draw_mesh?
Maybe someone from "mature" contributors could say is it a way to go)

Nevermind, I take a look at mesh creation function and it is as easy as engineering spaceship😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants