linearise block colours at generation time

This commit is contained in:
2024-08-22 03:49:50 +10:00
parent 8e3fdfdc25
commit 7eb880f0b7
2 changed files with 3 additions and 3 deletions

View File

@ -112,7 +112,7 @@ public struct Chunk {
public enum BlockType: Equatable { public enum BlockType: Equatable {
case air case air
case solid(_ color: Color<UInt8>) case solid(_ color: Color<Float16>)
} }
public struct Block { public struct Block {

View File

@ -36,7 +36,7 @@ class Game: GameDelegate {
var random = DarwinRandom(seed: Arc4Random.instance.next(in: DarwinRandom.max)) var random = DarwinRandom(seed: Arc4Random.instance.next(in: DarwinRandom.max))
self.chunk.fill(allBy: { self.chunk.fill(allBy: {
if (random.next() & 0x1) == 0x1 { if (random.next() & 0x1) == 0x1 {
.solid(.init(rgb888: UInt32(random.next(in: 0..<0xFFFFFF+1)))) .solid(.init(rgb888: UInt32(random.next(in: 0..<0xFFFFFF+1))).linear)
} else { } else {
.air .air
} }
@ -84,7 +84,7 @@ class Game: GameDelegate {
Instance( Instance(
position: SIMD3<Float>(position) + 0.5, position: SIMD3<Float>(position) + 0.5,
scale: .init(repeating: 0.5), scale: .init(repeating: 0.5),
color: Color<Float16>(color).linear) color: color)
} else { nil } } else { nil }
} }
if !instances.isEmpty { if !instances.isEmpty {