openframeworks / openframeworks/openFrameworks

Difficulty drawing pixel-accurate images in iOS 10.1 GLES2

Open
#5,381 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

iOS
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

When I draw an image that's made up of alternating black and white pixels like this:

    for(int y = 0; y < h; y++) {
        for(int x = 0; x < w; x++) {
            bool on = x % 2 == 0 && y % 2 == 0;
            img.setColor(x, y, on ? ofColor::white : ofColor::black);
        }
    }

(Inverse of the pattern here.) Then I get moire patterns.

screen shot 2016-12-02 at 7 20 51 pm

The above test is with ES2 and with 4-sample antialiasing enabled. Disabling antialiasing changes the pattern but does not remove the moire. ES1 does not show a moire pattern regardless of whether antialiasing is true or false.

I checked out the latest OF, pulled libs, and created a project with the project generator (copied from the 0.9.8-ios release). I'm running iOS 10.1 and XCode 8.1.

If I add the line ofSetupScreenOrtho(ofGetWidth(), ofGetHeight(), -1, +1); at the top of draw() then everything is ok on the real hardware. In the simulator the pattern is still "blurry" (instead of a 2x2 square being [255, 0, 0, 0] it's [149, 43, 43, 17]) but there is no moire. I tried checking if the difference between the hardware and the simulator is due to floating point accuracy, but I think it must be the graphics card. Because the matrices computed by ofSetupScreenOrtho() are exactly the same.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the alternating-pixel image on iOS 10.1 with GLES2, comparing 4-sample antialiasing, no antialiasing, ES1, and the simulator. The issue names no source files or tests; done would mean determining the cause and eliminating the moire without relying on ofSetupScreenOrtho().

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, ios
Domain
computer-graphics, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.