Skip to content

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

Open
@SableRaf

Description

@SableRaf
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

Activity

added this to the 4.4.4 milestone on Apr 25, 2025
vsquared

vsquared commented on Apr 27, 2025

@vsquared
Contributor

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

Image
perminder-17

perminder-17 commented on Apr 27, 2025

@perminder-17

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

perminder-17 commented on Apr 27, 2025

@perminder-17

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

SableRaf commented on Apr 27, 2025

@SableRaf
CollaboratorAuthor

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

vsquared commented on Apr 28, 2025

@vsquared
Contributor

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

AhmedMagedC

AhmedMagedC commented on May 5, 2025

@AhmedMagedC

@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

Stefterv commented on May 5, 2025

@Stefterv
Collaborator

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

AhmedMagedC

AhmedMagedC commented on May 5, 2025

@AhmedMagedC

@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

Stefterv commented on May 5, 2025

@Stefterv
Collaborator

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

AhmedMagedC commented on May 5, 2025

@AhmedMagedC

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?

6 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

Status

Backlog

Relationships

None yet

    Development

    Participants

    @SableRaf@vsquared@Stefterv@AhmedMagedC@perminder-17

    Issue actions

      Some `shader()` examples behave unexpectedly at higher pixel densities · Issue #1063 · processing/processing4