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

Sprite3D texture wrapping causing pixel lines on border #82044

Open
tenroseUK opened this issue Sep 21, 2023 · 7 comments · May be fixed by #86875 or #98122
Open

Sprite3D texture wrapping causing pixel lines on border #82044

tenroseUK opened this issue Sep 21, 2023 · 7 comments · May be fixed by #86875 or #98122

Comments

@tenroseUK
Copy link

Godot version

v4.1.1.stable.official [bd6af8e]

System information

Godot v4.1.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2080 Ti (NVIDIA; 31.0.15.3734) - Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (8 Threads)

Issue description

Sprite3D has pixel lines which appear to be the texture wrapping. There are no options on Sprite3D to disable wrapping.

image

Some troubleshooting for this issue has been carried out in my Reddit thread.

Tested on 4.1.1 and 4.2dev5

Steps to reproduce

  1. Create Sprite3D node
  2. Import texture with lossless compression (or any compression, nothing I tried made a difference)
  3. Apply texture to Sprite3D

Minimal reproduction project

Sprite3D_bug_21-09-23.zip

@tenroseUK
Copy link
Author

I've done some additional troubleshooting this afternoon for this.

As a workaround, I tried to create a InstanceMesh3D planeMesh instead, with the texture set as a material. The issue occurs here too, however luckily we have the option to disable Repeating textures in Sampling on the material. When disabling Repeat in this way, the issue goes away. It's definitively linked to the Repeat property, but we can't change that for Sprite3D.

@golddotasksquestions
Copy link

I have also tested this and can confirm on Win 10 Nvidea 765M on 4.1.1 stable and 4.2 dev5 with the same result as OP.
Another workaround is to enable "Region" in the Sprite3D properties and then move the boarders a tiny bit inward.

@clayjohn
Copy link
Member

The repeat setting should likely be set to REPEAT_DISABLED for all Sprite3Ds.

Sprite3D's get their material from Material.get_material_for_2d():

Ref<Material> BaseMaterial3D::get_material_for_2d(bool p_shaded, Transparency p_transparency, bool p_double_sided, bool p_billboard, bool p_billboard_y, bool p_msdf, bool p_no_depth, bool p_fixed_size, TextureFilter p_filter, AlphaAntiAliasing p_alpha_antialiasing_mode, RID *r_shader_rid) {

To fix this issue, we can just add a new parameter to get_material_for_2d() to enable/disable repeat (i.e. bool p_repeat = true).

Then call material->set_flag(FLAG_USE_TEXTURE_REPEAT, p_repeat);

And in Sprite3D ensure that you always disable p_repeat when creating a material

@Calinou
Copy link
Member

Calinou commented Sep 21, 2023

Note for those trying to reproduce this: this is more likely to be visible when MSAA is enabled.

@miv391
Copy link
Contributor

miv391 commented Sep 21, 2023

Could this be somehow related to #67164? Sprite2D has also problems displaying only the wanted pixels.

@golddotasksquestions
Copy link

The repeat setting should likely be set to REPEAT_DISABLED for all Sprite3Ds.

Can this be the default but an option? Sprite2D and Sprite3D also have the Region property, it's not uncommon to increase the region rect to tile the texture.

@clayjohn
Copy link
Member

The repeat setting should likely be set to REPEAT_DISABLED for all Sprite3Ds.

Can this be the default but an option? Sprite2D and Sprite3D also have the Region property, it's not uncommon to increase the region rect to tile the texture.

Sure, that makes sense

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