Skip to content

Conversation

GoodBoyDigital
Copy link
Member

@GoodBoyDigital GoodBoyDigital commented Apr 22, 2025

Description of change
  • Fixed generateTextureMatrix to give correct translation calculations for texture mapping when a shape is drawn with a grapchis object that s not at 0,0.
  • Introduced a new test scene for rendering various gradient fills with different configurations.
  • Updated snapshot tests for gradient rendering across multiple WebGL contexts.

fixes #11379

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

- Updated `generateTextureMatrix` to improve translation calculations for texture mapping.
- Introduced a new test scene for rendering various gradient fills with different configurations.
- Added snapshot tests for gradient rendering across multiple WebGL contexts.
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a gradient translation issue in graphics and enhances gradient testing across various WebGL contexts.

  • Fixed translation calculations in generateTextureMatrix when shape coordinates are non-zero.
  • Introduced a new test scene for gradient rendering.
  • Updated snapshot tests for gradient effects across multiple WebGL contexts.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

File Description
tests/visual/scenes/graphics/graphics-gradients.scene.ts Adds a detailed scene to test different gradient configurations.
src/scene/graphics/shared/utils/generateTextureFillMatrix.ts Refines translation calculations and conditionally updates texture addressing.

Copy link

codesandbox-ci bot commented Apr 22, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b90c460:

Sandbox Source
pixi.js-sandbox Configuration

GoodBoyDigital and others added 2 commits April 22, 2025 15:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bigtimebuddy
Copy link
Member

bigtimebuddy commented Apr 22, 2025

Nice. Here's an updated version:

Screenshot 2025-04-22 at 10 37 25 AM

I think the math is wrong on the vertical layout. It should be black to transparency, but you can see it's clipped. Trying some different aspect ratio for the rect changes how the gradient fill appears. Here's another example with a different aspect ratio:

Screenshot 2025-04-22 at 10 41 53 AM

@GoodBoyDigital
Copy link
Member Author

thanks @bigtimebuddy - will take another look!

… scaling

- Added a small offset to prevent UVs from flowing over the edge in `FillGradient`.
- Enhanced texture matrix generation by refining translation and scaling calculations in `generateTextureMatrix`.
- Adjusted handling of texture bounds to ensure proper scaling based on shape dimensions.
@bigtimebuddy
Copy link
Member

bigtimebuddy commented Apr 22, 2025

Looking better. Still some issues with, the top-right example. Also, still seeing the hairline

Screenshot 2025-04-22 at 1 27 38 PM

Screenshot 2025-04-22 at 1 27 26 PM

I'm also seeing some bleeding with a lower textureSize

Screenshot 2025-04-22 at 1 30 38 PM

https://pixiplayground.com/#/edit/JdjEuJMOYyQ8jE0lqodEG

- Adjusted the scaling calculation in `generateTextureMatrix` to use a smaller offset, improving UV handling.
- Removed unnecessary translation adjustments to streamline the transformation process.
- Introduced a `wrapMode` property to `FillGradient` for controlling texture wrapping behavior, with options for 'clamp-to-edge' and 'repeat'.
- Updated default gradient options to include `wrapMode`.
- Modified texture generation logic to respect the specified wrap mode.
- Adjusted tests to utilize the new `wrapMode` feature for gradient fills.
@GoodBoyDigital
Copy link
Member Author

heya @bigtimebuddy - should be all good now!
quite tricky wrestling uvs clamping!

Copy link
Member

@bigtimebuddy bigtimebuddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work @GoodBoyDigital. Thank you for sorting all these details.

@bigtimebuddy bigtimebuddy added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Apr 22, 2025
@Zyie Zyie added this pull request to the merge queue Apr 29, 2025
Merged via the queue into dev with commit 6b5a573 Apr 29, 2025
5 checks passed
@Zyie Zyie deleted the fix/shape-gradient branch April 29, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: FillGradient issues
3 participants