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

linePerspective breaks with push pop #7209

Closed
1 of 17 tasks
TiborUdvari opened this issue Sep 3, 2024 · 2 comments · Fixed by #7213
Closed
1 of 17 tasks

linePerspective breaks with push pop #7209

TiborUdvari opened this issue Sep 3, 2024 · 2 comments · Fixed by #7213

Comments

@TiborUdvari
Copy link
Contributor

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

1.9.2

Web browser and version

No response

Operating system

No response

Steps to reproduce this

I took the linePerspective example and added push and pop around the block of drawing boxes. When toggling linePerspective, the strokes inside the the push pop boundary are not being affected. I added another box (green) outside the boundary, which seems to get affected correctly.
https://editor.p5js.org/TiborUdvari/sketches/NcnxLpEum

I think the big issue is that in the current state anything inside a push-pop boundary will have linePerspective on.

This noticed this with v1.9.2 for p5.xr as it was using a custom camera and thus uniform strokes (cf snippet below). As there seem to be some issues with the line rendering as I mentioned here #7200, I wanted to get this mode working first.

p5.shader v1.9.1

    if (this.isStrokeShader()) {
      if (this._renderer._curCamera.cameraType === 'default') {
        // strokes scale up as they approach camera, default
        this.setUniform('uPerspective', 1);
      } else {
        // strokes have uniform scale regardless of distance from camera
        this.setUniform('uPerspective', 0);
      }
    }

p5.shader v1.9.2

this.setUniform('uPerspective', this._renderer._curCamera.useLinePerspective ? 1 : 0);

Right now the useLinePerspective always sends in true for things inside push pop, I can't quite understand why just yet.

@davepagurek
Copy link
Contributor

Good catch! I think we may be missing this property in p5.Camera::set and p5.Camera::copy, so saving and restoring that property isn't working. I suspect adding it to those two spots should fix this!

@TiborUdvari
Copy link
Contributor Author

Yes, that's the problem. I'll do a PR tomorrow to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants