mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
more lightning; adjustable initial samples
Former-commit-id: d928ce6689411900e256a82e9f4c1371284d10fa Former-commit-id: 52899acc116ddc400811687ed5944bd229a447b7
This commit is contained in:
@@ -14,11 +14,13 @@ import java.util.*
|
||||
* Created by minjaesong on 16-10-28.
|
||||
*/
|
||||
class TileableValueNoise(
|
||||
val octaves: Int, val persistency: Float, val width: Int) {
|
||||
val octaves: Int, val persistency: Float, val width: Int, val initSamples: Int = 4) {
|
||||
|
||||
init {
|
||||
// FIXME wow, such primitive!
|
||||
if (!FastMath.isPowerOfTwo(width)) throw Error("width is not power of two!")
|
||||
if (!FastMath.isPowerOfTwo(initSamples)) throw Error("initSamples is not power of two!")
|
||||
if (initSamples < 2) throw Error("initSamples must be equal to or greater than 2, and power of two!")
|
||||
}
|
||||
|
||||
private val noiseData = Array<Float>(width + 1, { 0f })
|
||||
@@ -36,7 +38,7 @@ class TileableValueNoise(
|
||||
octaveLoop@ for (octcnt in 0..octaves - 1) { // 1, 2, 3, 4, ...
|
||||
val i = octavesIntStream[octcnt] // 1, 2, 4, 8, ...
|
||||
// octave 1 samples four points
|
||||
val samples = 8 * i
|
||||
val samples = initSamples * i
|
||||
val amp = FastMath.pow(persistency, octcnt.toFloat()) // 1/1, 1/2, 1/3, 1/4, ...
|
||||
var pointThis = 0f
|
||||
var pointNext = rng.nextBipolarFloat()
|
||||
|
||||
@@ -54,12 +54,12 @@ class StateTestingSandbox : BasicGameState() {
|
||||
private var timer = 0
|
||||
private var regenTime = 17
|
||||
|
||||
private var seed = 1L
|
||||
private var seed = System.nanoTime()
|
||||
|
||||
val samples = 256
|
||||
val samples = 128
|
||||
|
||||
val lightningXgen = TileableValueNoise(8, 0.67f, samples)
|
||||
val lightningYgen = TileableValueNoise(8, 0.36f, samples)
|
||||
val lightningXgen = TileableValueNoise(8, 0.67f, samples, 8)
|
||||
val lightningYgen = TileableValueNoise(8, 0.58f, samples, 4)
|
||||
|
||||
override fun render(container: GameContainer, game: StateBasedGame, g: Graphics) {
|
||||
g.color = ColourTemp(7500)
|
||||
@@ -73,7 +73,7 @@ class StateTestingSandbox : BasicGameState() {
|
||||
|
||||
|
||||
val ampY = 40f
|
||||
val ampX = 3
|
||||
val ampX = 6
|
||||
val xoff = 10f
|
||||
val yoff = 300f
|
||||
|
||||
|
||||
Reference in New Issue
Block a user