gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
754 stars 175 forks source link

[Ancient IOS/WebGL Regression] Issues with Textures not being Pow2 #2712

Open m4xw opened 1 year ago

m4xw commented 1 year ago

Hello @gonetz After 2 years i finally tracked down the regression from late 2019/early 2020 for IOS. It seems that even with a GLES3 context, NPOT is not supported. It seems only to work with GL_LINEAR and CLAMP_TO_EDGE specifically (if mipmaps aren't used)

This was a hack i did for emscripten back then (which has simliar restrictions): image

However the texture size isn't available there so I cant do a explicit check without it getting refactored, but this catches most of the issues. I thought maybe i can peek into the unpack alignment since it already does some checks for it? Any idea to make this work while not breaking texture packs etc?

Without the hack: image

With the hack: image

gonetz commented 1 year ago

Hi,

If I understand you correctly, IOS can load NPOT textures, but can't wrap them. Wrapping parameter must be set to CLAMP_TO_EDGE.

I thought maybe i can peek into the unpack alignment since it already does some checks for it?

It won't help. Unpack alignment is changing for textures with odd width. If texture has even width, but the width is not a power of two (e.g. 12) unpack alignment won't change. May be you are wrong, and the problem is only with textures with odd dimensions, but textures with even npot dimensions can be processed? In that case knowing of unpack alignment can help.

Any idea to make this work while not breaking texture packs etc?

No. Most of N64 textures are NPOT. Since HD texture size should be power of two of the original size, it also is NPOT. Early versions of texturing code loaded all textures as POT OpenGL textures, but this code was dropped long ago.

If your hack helps in most situations and you can't find a better solution, you can add it as IOS-specific hack:

#ifndef OS_IOS
  current code
#else
  the hack