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: Generated Texture doesn't support scale mode since 8.1.0 #10440

Closed
stevenwithaph opened this issue Apr 11, 2024 · 2 comments
Closed

Bug: Generated Texture doesn't support scale mode since 8.1.0 #10440

stevenwithaph opened this issue Apr 11, 2024 · 2 comments
Assignees

Comments

@stevenwithaph
Copy link

stevenwithaph commented Apr 11, 2024

Current Behavior

Creating a texture through app.renderer.generateTexture, applying scale mode to nearest, and then scaling a sprite will result in a blurry sprite.

Expected Behavior

Scale mode to be applied.

Steps to Reproduce

Playground link

Change pixi version from 8.1.0 to 8.0.5 to see changes.

Environment

Possible Solution

No response

Additional Information

No response

@stevenwithaph
Copy link
Author

Looked into this more and it seems that the issue is with the webgl renderer.
Works fine with webgpu.

@GoodBoyDigital
Copy link
Member

GoodBoyDigital commented Apr 15, 2024

The reason this happens is that the texture style is set when its created to render the item. It kind of accidentally works in WebGPU :)

Here is the amended playground that shows how to set the scaling:

https://www.pixiplayground.com/#/edit/IhvqN3yIatrNlj_bwR6ET

There are two ways:

1 (preferred) When calling generate texture you can pass in texture options:

   const graphicsTexture = app.renderer.generateTexture({
        target: graphics,
        // set texture options at creation:
        textureSourceOptions:{
            scaleMode:'nearest'
        }
    });

2 The second is once a texture is created, the style can be modified, but update needs to be called to let the renderer know that the style has been updated:

    graphicsTexture.source.scaleMode = 'nearest';
    graphicsTexture.source.style.update();

Hope this helps!

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