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

Clipping issue with different child stencils #1956

Closed
rh101 opened this issue Jun 3, 2024 · 2 comments
Closed

Clipping issue with different child stencils #1956

rh101 opened this issue Jun 3, 2024 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@rh101
Copy link
Contributor

rh101 commented Jun 3, 2024

  • axmol version:
  • devices test on: Windows 10
  • developing environments
    • NDK version: r23c
    • Xcode version: 14.2+
    • Visual Studio:
      • VS version: 2022 (17.9+)
      • MSVC version: 19.39+
      • Windows SDK version: 10.0.22621.0+
    • cmake version:
      Steps to Reproduce:

If different stencils are added as children of a parent stencil, then the last child stencil added is applied to all other stencil positions.

For example, in the cpp-tests void HoleDemo::pokeHoleAtPoint(Vec2 point), change this line:

auto holeStencil = Sprite::create("Images/hole_stencil.png");

to this:
auto holeStencil = RandomHelper::random_int(0, 1) == 0 ? Sprite::create("Images/hole_stencil.png") : Sprite::create("Images/hole_stencil2.png");

Add this hole_stencil2.png image to the to the axmol\tests\cpp-tests\Content\Images folder:
hole_stencil2

Run cpp-tests, then click on "29:Node: Clipping" test. Then navigate to "2:Hole Demo". Click on the spinning square image, and you will see the following:
image
image

MP4 video of issue:
https://github.com/axmolengine/axmol/assets/8603230/5c82dd9a-be6d-4246-8193-9b0217f3329e

The problem is that the last image used as a stencil is applied to all other existing stencils.

The expected output is that each new stencil would not affect the previous stencils applied, so there should be a mix of round and square holes in that image.

Is this a limitation of the ClippingNode, or is this a bug?

@rh101
Copy link
Contributor Author

rh101 commented Jun 3, 2024

I think this has something to do with the ProgramState being set on all child stencil nodes. They are all being set to the same ProgramState instance, but if this is changed to be a unique instance per child, then the problem is fixed, but memory usage goes up because of some other issue that I'm trying to track down.

@rh101
Copy link
Contributor Author

rh101 commented Jun 3, 2024

Issue should now be fixed in PR #1957

The resulting output is now this:
image

To reproduce this output, then in addition to the cpp-tests changes mentioned in the initial post above, also change this line:
holesClipper->setStencil(_holesStencil);

to this:
holesClipper->setStencil(_holesStencil, true);

@rh101 rh101 closed this as completed Jun 3, 2024
@halx99 halx99 added this to the 2.1.4 milestone Jun 3, 2024
@halx99 halx99 added the enhancement New feature or request label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants