Skip to content

Some shader() examples behave unexpectedly at higher pixel densities #1063

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

Open
SableRaf opened this issue Apr 25, 2025 · 10 comments
Open

Some shader() examples behave unexpectedly at higher pixel densities #1063

SableRaf opened this issue Apr 25, 2025 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@SableRaf
Copy link
Collaborator

Most appropriate sub-area of Processing 4?

OpenGL

Processing version

4.4.3

Operating system

Tested on macOS 13.4

Steps to reproduce this

  1. Open Processing 4.4.3

  2. Run examples in Topics/Shaders (for example Conway);

  3. Notice the rendering is wrong

snippet

n/a

Additional context

Since version 4.4.3, the default pixelDensity is set to match the display's density. During testing, we found that some shader examples break on high-density displays because they implicitly relied on pixelDensity being set to 1.

Some investigation in how shader() is implemented and what assumptions are made there might be needed.

Would you like to work on the issue?

This can be assigned

@SableRaf SableRaf added bug Something isn't working help wanted Extra attention is needed labels Apr 25, 2025
@SableRaf SableRaf moved this to Backlog in Processing Roadmap Apr 25, 2025
@SableRaf SableRaf added this to the 4.4.4 milestone Apr 25, 2025
@vsquared
Copy link
Contributor

This is what I see on macos 14.6.1 M2; not sure how it's supposed to look:

Image

@perminder-17
Copy link

perminder-17 commented Apr 27, 2025

This is what I see on macos 14.6.1 M2; not sure how it's supposed to look:

Hey, @vsquared I think it should look something like this:

Screencast.from.28-04-25.01.35.32.AM.IST.webm

When I try to run in linux, it's working as expected, so probably it's a mac specific issue. Mac are sometimes really weird when working with opengl.

Btw, @vsquared do you mind removing this line in the code and build again to see what you get, probably you should get the correct result then. I can't debug since I am not a user of mac.

sketch.pixelDensity = sketch.displayDensity();

We should probably work with shader on how it works with mac for pixel Density?

@perminder-17
Copy link

perminder-17 commented Apr 27, 2025

3. Notice the rendering is wrong

Hi @SableRaf , From what I can see, the Conway Game-of-Life example (https://processing.org/examples/gameoflife.html) is rendered with Processing’s default renderer. So does it actually uses any OpenGL pipeline or custom shaders?

I’ve been investigating the flickering you noted in the shader reference sketches. Even after commenting out the line that syncs pixelDensity to the display density the problem persists, so it looks independent of pixelDensity.

sketch.pixelDensity = sketch.displayDensity();

the shader still don't work and shows kind of flickering effect :

Screencast.from.28-04-25.02.01.24.AM.IST.webm

That makes me suspect the issue lies elsewhere. Would you agree this is independent of pixel density? If so, I can prepare a minimal example and file a new issue—just let me know if there’s anything else we should check first. Not sure if conway example we are using uses any opengl context or works on the GPU side.

@SableRaf
Copy link
Collaborator Author

SableRaf commented Apr 27, 2025

This is what I see on macos 14.6.1 M2; not sure how it's supposed to look:

This is the correct appearance. The issue in question is specific to Processing 4.4.3 (the latest beta at the time of posting). We changed the default behavior so that pixelDensity matches the displayDensity. However that causes issues with some shader examples. The temporary workaround is to add pixelDensity(1) to the setup() in these examples. However, we'd like to fix the underlying issue which is that shader examples should be working regardless of pixelDensity.

If you want to investigate further, make sure you're testing on Processing 4.4.3 or building from the latest source. We suspect the issue may be related to the built-in PShader uniforms, or something in the way the shader() function is implemented.

@perminder-17 You're looking at Topics > Cellular Automata > Game of Life. This is not a shader-based example. @vsquared has the correct one which is in Topics > Shaders > Conway. As for the flickering you mentioned, it seems unrelated to this issue. Please open a new issue with details about which version of Processing you are using and the code you are running.

@vsquared
Copy link
Contributor

My mistake; I tested on Processing 4.4.1. Sorry for the confusion.

@AhmedMagedC
Copy link

@SableRaf, i have tried to build the Processing 4.4.3 source code to test
but I can't reproduce this bug on windows! i can see the exact same pic as @vsquared posted, maybe it is macOS specific issue?

@Stefterv
Copy link
Collaborator

Stefterv commented May 5, 2025

@AhmedMagedC Do you have a high-density display? Otherwise you'd need to set pixelDensity(2) manually

@AhmedMagedC
Copy link

@AhmedMagedC Do you have a high-density display? Otherwise you'd need to set pixelDensity(2) manually

i have 1920 * 1080 screen monitor (using laptop)
is that considered high-density? anyway when i set pixelDensity(2) in setup() i see this message in console pixelDensity(2) is not available for this display and still nothing changes i see the same pic

@Stefterv
Copy link
Collaborator

Stefterv commented May 5, 2025

Yeah that message indicates that you do not have a high-density display, you can go into settings -> system -> display (iirc) and change the display scaling to 200% for example. Not sure if you could work this way though

@AhmedMagedC
Copy link

Yeah that message indicates that you do not have a high-density display, you can go into settings -> system -> display (iirc) and change the display scaling to 200% for example. Not sure if you could work this way though

Image

is that how it looks like?

and do you mean i can't work on this issue due to not having high-density display?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: Backlog
Development

No branches or pull requests

5 participants