MZ WebGL: INVALID_VALUE: texImage2D: width or height out of range

Seems I've run into a small dilemma in making one of my latest plugins...

I'm using a bitmap of a spritesheet to create a bitmap that has multiple of the same part of the spritesheet, after the created bitmap is made then if the height of the source bitmap is 288px or larger then of course the created bitmap becomes too large and I receive the following error in the console and where the sprite is supposed to be drawn at it is then just black boxes

Code:
WebGL: INVALID_VALUE: texImage2D: width or height out of range

1665607217960.png


Never thought about this becoming an issue before but it does make perfect sense.. just was wondering if anyone had any tips of getting around this.

As I was typing this post I had just thought of a way around it by making the main sprite then just contain children sprites instead of creating one big bitmap, but doing that method to the existing code I already have is going to take a lot

sooo maybe there is another good way?
Do you have to use WebGL?
Do you have to use WebGL?

Pardon my ignorance but honestly I'm really not sure...
I do want it to run well on mobile and webpages though.

I'm willing to test out alternate methods with OpenGL & any other suggestions though.

Do I require to use WebGL if I want to host it on itch.io/websites and create mobile apps?

Is there a way to not use WebGL? Seems like rmmz just defaults to that? Idk honestly I'm just very confused now lol
Hmm, I'm not sure either. It's hard to say without knowing exactly what you're trying to do.
Hmm, I'm not sure either. It's hard to say without knowing exactly what you're trying to do.
Really plugin aside even parallaxes larger then 16384px in height or width result in the same error.
Not that I would ever need to have parallax that big but it was just another way to test without having anything to do with my plugin.

This is with attempting a parallax image with a height of 16386px:
1665612153623.png


Furthering to answer the question though from what I gathered I think RMMZ is forced to use WebGL?

Seen this posted on another thread:
MZ only has WebGL, while MV supports both WebGL and Canvas.

So I guess... yes? yes it seems I have to use WebGL?
Yea, MZ renders via WebGL. I believe it's a hardware limitation, based on the GPU's texture memory. A typical "safe" max texture size is 4096 px, but you could reel that back to 2048 px if you want to support older systems. Splitting large images into smaller ones is the standard approach.
Ok thanks for the replies everyone 🙂

Unfortunately not exactly what I was hoping for but I pretty much did figure that would really be the answer before posting. The simple answer is just don't create the bitmap like that and instead place children sprites into the main sprite.

...now my question is how to "setFrame" the group of children sprites... since before I was using "setFrame" from the created bitmap to limit the amount shown

This is proving to be somewhat tricky :blink:
...unless maybe someone has a good way to teach me?
(I'm not an expert on this stuff, but I know PIXI has batching support for sending more than one object's render data to the GPU at a time, and it will use up to 32 texture units for that, or 4 on on old iOS/Android platforms. However, I haven't found anything in PIXI 5.2.4 that suggests an ability to split oversized sources into manageable chunks. It might be there, but I don't see it. In case it helps: the blob -> image conversion seems to happen via autoDetectResource, line 13692 of libs/pixi.js?)

If you want to load a larger-than-usual image file, then you may have to split the image data (loaded from file) before assigning it as a texture. Maybe some kind of Bitmap.prototype._createBaseTexture patch/override? That'll probably require you to dive into the PNG file structure...not sure if there's any native methods to help there. 😴

I imagine it'd be much easier to set up something that loads multiple files: get the user to split up their image, then load and arrange those sub-images. You'd need to consider how to specify relative positioning of sub-images, maybe via the filename, e.g. X-Y grid coords: parallax_0-0, parallax_0-1, etc.

Original thread: https://forums.rpgmakerweb.com/threads/webgl-invalid_value-teximage2d-width-or-height-out-of-range.151933/