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

Bug: [v8] Multiple issues with mipmaps #10424

Closed
ucarno opened this issue Apr 7, 2024 · 7 comments
Closed

Bug: [v8] Multiple issues with mipmaps #10424

ucarno opened this issue Apr 7, 2024 · 7 comments
Assignees

Comments

@ucarno
Copy link

ucarno commented Apr 7, 2024

Current Behavior

There are different results depending on the inputs:

  1. autoGenerateMipmaps: true and updateMipmaps() is called - mipmap works, but is inneficiently updated on every TextureSource update
  2. autoGenerateMipmaps: true and updateMipmaps() is not called - blank texture
  3. autoGenerateMipmaps: false and mipLevelCount: 12 and updateMipmaps() is not called - black square
  4. autoGenerateMipmaps: false and mipLevelCount: 12 and updateMipmaps() is called - also black square
  5. autoGenerateMipmaps: false and mipLevelCount: 1 and updateMipmaps() is called - there is no black square anymore, but mipmap does not work
  6. autoGenerateMipmaps: false and mipLevelCount: undefined and updateMipmaps() is called - behaves the same way as above, console.log(textureSource.mipLevelCount) produces undefined even after calling updateMipmaps()

Expected Behavior

  1. Works as expected
  2. Should produce texture without calling updateMipmaps()?
  3. Should render the actual thing instead of black square, without mipmaps
  4. Should render the actual thing instead of black square, with mipmaps
  5. Works as expected
  6. Should automatically set mipLevelCount based on texture dimensions and render the thing with mipmaps

Steps to Reproduce

Here is the playground:
https://www.pixiplayground.com/#/edit/bgHHESUn_pYGjja4WYr-Q

Uncomment desired situation to see results

Environment

  • pixi.js version: 8.0.5
  • Browser & Version: e.g. Chrome 123
  • OS & Version: Windows 11

Possible Solution

No response

Additional Information

For the context: I am rendering a lot of things onto a TextureSource just once on app launch and can't get mipmaps to work without passing autoGenerateMipmaps: true to new TextureSource.

@ucarno
Copy link
Author

ucarno commented Apr 9, 2024

Update: Also, when increasing the texture source size to 8192px, even the first method with autoGenerateMipmaps: true results in black square when run on my android phone (OnePlus 8 Pro):
https://www.pixiplayground.com/#/edit/dG5saDxVYtrFhywC7QAcd

And this happens only in mobile Google Chrome, it works fine in mobile Firefox on the same device. On v7 the same code worked fine in both browsers and with maximum texture source size.

@GoodBoyDigital
Copy link
Member

hey @ucarno , could you try forcing webgl? just keen to ascertain if this is a GPU issue or not. Thanks!

@GoodBoyDigital
Copy link
Member

oh, nevermind - i see its set to webgl!

@GoodBoyDigital
Copy link
Member

This was more of an optimisation that updateMipmaps() is something pixi users can have full control of.

// render something
renderer.render({container, target:renderTexture});
// render something else..
renderer.render({container, target:renderTexture});

// ready to update after multiple renderers..
renderTexture.source.updateMipmaps()

@GoodBoyDigital
Copy link
Member

autoGenerateMipmaps: false and mipLevelCount: 12 and updateMipmaps() is not called - black square

for this combo, the mipmaps are not created as autoGenerateMipmaps is false, but the levels are set to 12. This means Pixi is assuming the dev will handle rendering to the various mipmap levels.

@GoodBoyDigital
Copy link
Member

With RenderTextures - if it has mipmaps of any kind (auto generated, or specified via mipLevelCount).

Devs will need to call updateMipmaps() to ensure all mip levels are all updated.

I will have a think on how we could generate them 'just in time'. eg flag it as dirty and update it at the point of render.

You should be able to achieve your goals with the current set up though i hope!

Let me know! Cheers

@ucarno
Copy link
Author

ucarno commented Apr 10, 2024

Thanks!

@ucarno ucarno closed this as completed Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants