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

HTML5: npot repeated texture nearest-neighbour interpolation is off #48807

Closed
snoopdouglas opened this issue May 18, 2021 · 8 comments
Closed

Comments

@snoopdouglas
Copy link
Contributor

snoopdouglas commented May 18, 2021

Godot version:
3.3.1-rc2, though also observed in 3.3

OS/device including version:
Ubuntu Linux 20.04, HTML5, checked in Chromium 90.0.4430.93, Firefox 88.0.1
GTX 1660 super
GLES 2

Issue description:
Specific to HTML5. This doesn't happen in desktop/mobile builds. Possibly related to #44379

Top texture has repetition enabled, bottom doesn't. They're both the same size (320x56):

2021-05-18T10:43:11+01:00

Steps to reproduce:
Seems as simple as importing a repeating npot texture and exporting to HTML5.

Minimal reproduction project:
bug.zip

@snoopdouglas
Copy link
Contributor Author

I've confirmed that this doesn't happen with GLES 3.

@lawnjelly
Copy link
Member

This is expected behaviour, although it may not be expected by users (we should probably have a warning to this effect). For hardware that doesn't support non-POT tiling on GLES2 (which includes HTML5, I think we always assume npot tiling not supported), if the texture is imported as repeat it gets resized to POT, as discussed in #44379.

With no filtering, that results in ugly aliasing / sampling error. If you turn filtering on at import you get a smoother result. If you reimport with wrapping off, you see it looks fine as no resize has taken place.

There is also a shader that will attempt to wrapping in the fragment shader as last ditch if the texture has been imported as non-wrapping, but a wrap flag is used at runtime. But this may have bad effects on some hardware (slowness, artifacts).

So really the general advice is, don't use npot textures for tiling on GLES2 or HTML5.

@snoopdouglas
Copy link
Contributor Author

Good to know. I generally don't build for HTML5, but was trying it out and noticed this artifacting, so thought it'd be worth reporting.

If you turn filtering on at import you get a smoother result.

I'm sure, though can be problematic for pixel art :p

So really the general advice is, don't use npot textures for tiling on GLES2 or HTML5.

FWIW the game I'm working on runs GLES2 on desktop and mobile, and doesn't have these problems - though maybe I just happen to have not tested on any problematic hardware yet.

@lawnjelly
Copy link
Member

FWIW the game I'm working on runs GLES2 on desktop and mobile, and doesn't have these problems - though maybe I just happen to have not tested on any problematic hardware yet.

Yes, it will potentially have problems if you run on hardware which doesn't support npot tiling, it checks for this capability at startup.

@snoopdouglas
Copy link
Contributor Author

snoopdouglas commented May 18, 2021

Do you reckon it's worth adding a gotcha to the docs, specifically HTML5 exports or GLES2 / 3 differences, or should this just be closed?

@lawnjelly
Copy link
Member

lawnjelly commented May 18, 2021

Yes certainly there should be something in the docs about it, and probably a warning too at runtime imo. I've changed the tags to reflect this, @clayjohn may chime in later as he's more familiar with this than me.

@Calinou
Copy link
Member

Calinou commented May 18, 2021

So really the general advice is, don't use npot textures for tiling on GLES2 or HTML5.

Can we print a warning every time such a texture is imported or used? This could be done both at import-time (when using GLES2 and the Repeat flag is enabled) and at run-time. The warning could be made disableable with a project setting for those who only intend to export to desktop platforms.

@akien-mga
Copy link
Member

Fixed by #48817.

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

4 participants