Branimir Karadžić 7 yıl önce
ebeveyn
işleme
573a2b9177
2 değiştirilmiş dosya ile 22 ekleme ve 0 silme
  1. 16 0
      include/bx/inline/math.inl
  2. 6 0
      include/bx/math.h

+ 16 - 0
include/bx/inline/math.inl

@@ -942,4 +942,20 @@ namespace bx
 		_result[3] = -vec3Dot(normal, _va);
 	}
 
+	inline BX_CONST_FUNC float toLinear(float _a)
+	{
+		const float lo     = _a / 12.92f;
+		const float hi     = pow( (_a + 0.055f) / 1.055f, 2.4f);
+		const float result = lerp(hi, lo, _a <= 0.04045f);
+		return result;
+	}
+
+	inline BX_CONST_FUNC float toGamma(float _a)
+	{
+		const float lo     = _a * 12.92f;
+		const float hi     = pow(abs(_a), 1.0f/2.4f) * 1.055f - 0.055f;
+		const float result = lerp(hi, lo, _a <= 0.0031308f);
+		return result;
+	}
+
 } // namespace bx

+ 6 - 0
include/bx/math.h

@@ -567,6 +567,12 @@ namespace bx
 	///
 	void hsvToRgb(float _rgb[3], const float _hsv[3]);
 
+	///
+	float toLinear(float _a);
+
+	///
+	float toGamma(float _a);
+
 } // namespace bx
 
 #include "inline/math.inl"