https://github.com/xjine/unity_pingpongpattern
"Ping Pong Pattern" is a useful pattern for representing spatial areas, such as national borders or habitats.
https://github.com/xjine/unity_pingpongpattern
assets noise unity
Last synced: about 2 months ago
JSON representation
"Ping Pong Pattern" is a useful pattern for representing spatial areas, such as national borders or habitats.
- Host: GitHub
- URL: https://github.com/xjine/unity_pingpongpattern
- Owner: XJINE
- License: bsd-3-clause
- Created: 2025-04-29T06:26:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-02T01:42:36.000Z (about 1 year ago)
- Last Synced: 2025-05-02T02:34:54.768Z (about 1 year ago)
- Topics: assets, noise, unity
- Language: C#
- Homepage:
- Size: 1.75 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unity_PingPongPattern

"Ping Pong Pattern" is a useful pattern for representing spatial areas, such as national borders or habitats.
The area continuously changes due to seeds bouncing like a "Ping-Pong" inside it.
This isn't a completely original idea. You'll find plenty of others who have come up with similar algorithm.

## Discussion
### Reflection
```csharp
float2 fakeNormal = normalize(seed.coord * texSize - sampleCoord + randomNormal);
seed.velocity = reflect(seed.velocity, fakeNormal);
```
I considered using the vector between the seed and the hit pixel as the normal vector.
(Of course, a bit of randomness is added to that.)
This approach produces poor results. It tends to be very stable, with little variation.
```csharp
float2 randomNormal = normalize(float2(random(seed.velocity * RandomSeed) - 0.5,
random(seed.coord * RandomSeed) - 0.5));
seed.velocity = reflect(seed.velocity, randomNormal);
```
To make the changes more dynamic, the reflections should be completely random.
If stable results are required, it is better to use something like Voronoi.
### Distinction
As you can see, the result is more organic than expected.
What sets it apart from typical noise like patterns is its ability to maintain continuity, even when the number of seeds or parameters changes.
However, this algorithm has no periodicity like typical noise, nor reproducibility.
It is only known that seeds with the same parameters create similar areas.
The sizes and movement speeds of each area tend to yield similar results, but the overall result cannot be controlled.