mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-04 05:31:34 +00:00
replace expensive srgb conversion with a simple gamma ramp in chunk mesh builder
This commit is contained in:
@ -139,7 +139,7 @@ public extension Color where T: BinaryFloatingPoint {
|
||||
if x < 0.04045 {
|
||||
x / 12.92
|
||||
} else {
|
||||
T(pow((Double(x) + 0.055) / 1.055, 2.4))
|
||||
T(Darwin.pow((Double(x) + 0.055) / 1.055, 2.4))
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public extension Color where T: BinaryFloatingPoint {
|
||||
} else if x < 0.0031308 {
|
||||
x * 12.92
|
||||
} else {
|
||||
T(1.055 * pow(Double(abs(x)), 1 / 2.4) - 0.055)
|
||||
T(1.055 * Darwin.pow(Double(abs(x)), 1 / 2.4) - 0.055)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,3 +195,15 @@ public extension Color where T: FloatingPoint {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension Color where T == Float {
|
||||
func pow(_ exponent: T) -> Self {
|
||||
Self(r: powf(r, exponent), g: powf(g, exponent), b: powf(b, exponent), a: a)
|
||||
}
|
||||
}
|
||||
public extension Color where T == Double {
|
||||
func pow(_ exponent: T) -> Self {
|
||||
Self(r: Darwin.pow(r, exponent), g: Darwin.pow(g, exponent), b: Darwin.pow(b, exponent), a: a)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user