-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
181 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.openrndr.extra.noise | ||
|
||
/** | ||
* uniform hash function | ||
* https://nullprogram.com/blog/2018/07/31/ | ||
*/ | ||
fun uhash11(x: UInt): UInt { | ||
var a = x | ||
a = a xor (a shr 16) | ||
a *= 0x7feb352du | ||
a = a xor (a shr 15) | ||
a *= 0x846ca68bu | ||
a = a xor (a shr 16) | ||
return a | ||
} | ||
|
||
fun uhash1D(seed: Int, x: Int): UInt = uhash11(seed.toUInt() + uhash11(x.toUInt())) | ||
fun uhash2D(seed: Int, x: Int, y: Int): UInt = uhash11(seed.toUInt() + uhash11(y.toUInt() + uhash11(x.toUInt()))) | ||
fun uhash3D(seed: Int, x: Int, y: Int, z: Int): UInt = | ||
uhash11(seed.toUInt() + uhash11(z.toUInt() + uhash11(x.toUInt() + uhash11(y.toUInt())))) | ||
|
||
fun uhash4D(seed: Int, x: Int, y: Int, z: Int, w: Int): UInt = | ||
uhash11(seed.toUInt() + uhash11(z.toUInt() + uhash11(z.toUInt() + uhash11(x.toUInt() + uhash11(y.toUInt()))))) | ||
|
||
|
||
fun fhash1D(seed: Int, x: Int): Double = uhash1D(seed, x).toDouble() / UInt.MAX_VALUE.toDouble() | ||
fun fhash2D(seed: Int, x: Int, y: Int): Double = uhash2D(seed, x, y).toDouble() / UInt.MAX_VALUE.toDouble() | ||
fun fhash3D(seed: Int, x: Int, y: Int, z: Int): Double = | ||
uhash3D(seed, x, y, z).toDouble() / UInt.MAX_VALUE.toDouble() | ||
|
||
fun fhash4D(seed: Int, x: Int, y: Int, z: Int, w :Int): Double = | ||
uhash4D(seed, x, y, z, w).toDouble() / UInt.MAX_VALUE.toDouble() | ||
|
||
|
||
fun fshash1D(seed: Int, x: Int): Double = 2.0 * uhash1D(seed, x).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0 | ||
fun fshash2D(seed: Int, x: Int, y: Int): Double = 2.0 * uhash2D(seed, x, y).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0 | ||
fun fshash3D(seed: Int, x: Int, y: Int, z: Int): Double = | ||
2.0*uhash3D(seed, x, y, z).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0 | ||
|
||
fun fshash4D(seed: Int, x: Int, y: Int, z: Int, w :Int): Double = | ||
2.0 * uhash4D(seed, x, y, z, w).toDouble() / UInt.MAX_VALUE.toDouble() - 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import org.openrndr.application | ||
import org.openrndr.color.ColorRGBa | ||
import org.openrndr.extra.noise.* | ||
|
||
fun main() { | ||
application { | ||
program { | ||
extend { | ||
drawer.points { | ||
for (y in 0 until height) { | ||
for (x in 0 until width) { | ||
val c = cubicHermite3D(100, (x + y) * 0.04, (x - y) * 0.04, seconds * 1.0) * 0.5 + 0.5 | ||
fill = ColorRGBa(c, c, c, 1.0) | ||
point(x.toDouble(), y.toDouble()) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.