r/GraphicsProgramming • u/696969sixtynine42069 • 35m ago
Question not a graphics programmer, but i wanted to know why scratch starts making these crazy patterns when i let whirl and fisheye effects grow exponentially.
https://scratch.mit.edu/projects/1444420354/ < see for yourself, you gotta watch it for a few minutes. removing the changing colors would probably help see it better.
i let the whirl effect grow by 1% of what its at every 0.01 seconds, and when it reaches a certain number, i let the fisheye effect do so alongside it. then eventually, scattering crazy white pixels appear and spread across the sprite, and then stop scattering randomly and start forming a beautiful pattern that's almost like a really crazy rug pattern, and then a circle of no white pixels grows from the middle and erases any white pixels it touches until there's no more, and then white rings start growing from the middle, almost looking like those lines that represent the planets orbiting the sun? and then those rings disappear, and the scattering white pixels appear, and the cycle continues forever. why?????? is this some crazy math stuff, or are the graphics glitching out, or what?


•
u/AutoModerator 35m ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/noradninja 25m ago
What you are seeing is a moiré pattern, it’s an interference pattern made in this case by combining a dense twirl with a fisheye, but lots of things exhibit this, more info here: https://en.wikipedia.org/wiki/Moiré_pattern
As a game developer, this is something that we have to fight against when viewing surfaces with regular patterns (like bricks, stairs, roof shingles, and tiles)- it tends to appear when you have a tight pattern like that, and a low amount of pixels to represent it, so you can see it more on objects in the distance. If you’ve ever played Ocarina of Time on a Nintendo 64, you can easily see this happening if you go up the stairs leading to Kakariko Village. Antialiasing can mitigate it to a certain extent, but the better solution is higher resolution.
3
u/IDatedSuccubi 28m ago
It's called Moire effect. These patterns don't actually exist, it's just aliasing that are there because you can't have enough pixels to properly draw this
1
u/Jahmann 24m ago
It is a moire effect that emerges from resampling. I'm not too mathy so maybe somebody would have a more refined explanation..
Something something nyquist aliasing
1
u/EC36339 5m ago
Moiré patterns, as others have pointed out.
This is aliasing, and it comes from sampling a high frequency signal at a too low frequency (typically your screen or texture resolution, depending on what you are doing). When you do that, "random" lower frequencies are introduced, and those become very visible patterns. A picture would explain this better, but this sub doesn't allow pictures in comments (weird rule for a computer graphics sub... but it's how it is).
You see this also, for example, when you take a picture of a screen with your phone.
You don't want aliasing, even if you like the pattern artistically, because it depends on resolution, so it won't look the same on every display. Animated aliasing can result in flickering or shimmering. Even if it fits (for example, stars that are smaller than one pixel may shimmer like they do through atmosphere), it won't give you consistent results. And usually you just don't want it at all.
The math behind this is in the field of signal processing, if you're interested.
There are enough techniques for antialiasing to fill books. Some are generic, others are specific to certain contexts. For example, a procedural texture can implement anti-aliasing right at the source (by smoothing out sharp edges, fading out detail that is smaller than pixel footprint, limiting the number of noise octaves, screen derivatives, ...)
For still images, you can also anti-alias by randomising (for example ray direction). This turns aliasing pattern into noise, which makes it less visible. But once your picture starts moving, the noise also gets animated.