mirror of
				https://github.com/GayPizzaSpecifications/voxelotl-engine.git
				synced 2025-11-04 10:59:39 +00:00 
			
		
		
		
	decrease memory usage by storing chunk colours as 8bit (at the cost of slower mesh generation)
This commit is contained in:
		@ -123,7 +123,7 @@ public struct Chunk: Hashable {
 | 
			
		||||
 | 
			
		||||
public enum BlockType: Hashable {
 | 
			
		||||
  case air
 | 
			
		||||
  case solid(_ color: Color<Float>)
 | 
			
		||||
  case solid(_ color: Color<UInt8>)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public struct Block: Hashable {
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ struct ChunkMeshBuilder {
 | 
			
		||||
              .init(
 | 
			
		||||
                position: SIMD3(position) + $0.position,
 | 
			
		||||
                normal: $0.normal,
 | 
			
		||||
                color: SIMD4(color),
 | 
			
		||||
                color: SIMD4(Color<Float>(color).linear),
 | 
			
		||||
                texCoord: $0.texCoord)
 | 
			
		||||
            })
 | 
			
		||||
            indices.append(contentsOf: sideIndices.map { orig + $0 })
 | 
			
		||||
 | 
			
		||||
@ -32,9 +32,9 @@ struct StandardWorldGenerator: WorldGenerator {
 | 
			
		||||
      if self.ravineMask.get(position * SIMD3(1, 0.441, 1)) >= 0.8 &&
 | 
			
		||||
        abs(self.ravineNoise.get(position * SIMD3(1, 0.6, 1))) <= 0.1 { return .air }
 | 
			
		||||
#endif
 | 
			
		||||
      return .solid(.init(
 | 
			
		||||
      return .solid(Color<UInt8>(.init(
 | 
			
		||||
        hue: Float(180 + self.colorNoise.get(position) * 180),
 | 
			
		||||
        saturation: 0.47, value: 0.9).linear)
 | 
			
		||||
        saturation: 0.47, value: 0.9)))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let chunkOrigin = chunkID.getPosition()
 | 
			
		||||
 | 
			
		||||
@ -19,11 +19,11 @@ struct TerrorTowerGenerator: WorldGenerator {
 | 
			
		||||
        let gradient = simd_length(fpos.xz) / 14.0
 | 
			
		||||
        let value = self.noise1.get(fpos) - 0.25
 | 
			
		||||
      return if gradient + value < threshold {
 | 
			
		||||
        .solid(.init(
 | 
			
		||||
        .solid(Color<UInt8>(.init(
 | 
			
		||||
          hue: ((fpos.x * 0.5 + fpos.y) / 30.0) * 360.0,
 | 
			
		||||
          saturation: 0.2 + noise2.get(fpos) * 0.2,
 | 
			
		||||
          value: 0.75 + noise2.get(SIMD4(fpos, 1) * 0.25)
 | 
			
		||||
        ).linear)
 | 
			
		||||
        )))
 | 
			
		||||
      } else {
 | 
			
		||||
        .air
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user