Skip to content

Non POT ImageBitmap texture can be upside down #16144

@takahirox

Description

@takahirox
Description of the problem

Non POT ImageBitmap texture can be upside down.

Demo: https://jsfiddle.net/7do6um2f/ (Use Chrome)

Non POT image can be resized to POT canvas in WebGLRenderer(WebGLTexture). If original image is ImageBitmap and texture.flipY is true, texture will be upside down.

This is from the difference of ImageBitmap API from others. ImageBitmap requires flipY on bitmap creation while others requires on uploading data to GPU (= texture.flipY).

texture.flipY used on uploading data to GPU is ignored for ImageBItmap. But if non POT ImageBitmap is converted to canvas, texture.flipY will have an effect. So texture will be upside down.

texture.flipY has no effect for ImageBitmap so we should force it to false if texture's image is ImageBitmap?

API difference has another issue. (May be it isn't so serious tho.) FlipY and premultiplyAlpha is required on bitmap creation. texture.flipY/premultiplyAlpha used on uploading data to GPU are ignored for ImageBitmap.

So the following code has no effect for ImageBitmap, but the code has effect if ImageBitmap is resized and converted to canvas.

texture.premultiplyAlpha = ! texture.premultiplyAlpha;
texture.flipY = ! texture.flipY;
texture.needsUpdate = true;
Three.js version
  • Dev
  • r103
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions