]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
RPN: more accuracy; add sRGB conversion macros.
authorRudolf Polzer <divverent@xonotic.org>
Tue, 24 Sep 2013 07:59:36 +0000 (09:59 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 24 Sep 2013 07:59:36 +0000 (09:59 +0200)
Usage:

rpn 0.1 $rpn_sRGB_to_linear

defaultXonotic.cfg
qcsrc/common/command/rpn.qc

index 6cd876b4b59f19c21af33cc30d50759401411b5c..4a01ad5876a50b842d2a105c1af02ccae4926f0a 100644 (file)
@@ -110,6 +110,11 @@ v_deathtilt 0 // needed for spectators (who are dead to avoid prediction)
 exec sRGB-disable.cfg
 vid_sRGB_fallback 2
 r_hdr_glowintensity 1
+#define Image_LinearFloatFromsRGBFloat(c) (((c) <= 0.04045f) ? (c) * (1.0f / 12.92f) : (float)pow(((c) + 0.055f)*(1.0f/1.055f), 2.4f))
+set rpn_sRGB_to_linear "dup 0.055 add 1.055 div 2.4 pow exch 12.92 div dup 0.0031308 gt when"
+#define Image_sRGBFloatFromLinearFloat(c) (((c) < 0.0031308f) ? (c) * 12.92f : 1.055f * (float)pow((c), 1.0f/2.4f) - 0.055f)
+set rpn_linear_to_sRGB "dup 1.0 2.4 div pow 1.055 mul 0.055 sub exch 12.92 mul dup 0.04045 ge when"
+
 
 // these settings determine how much the view is affected by movement/damage
 cl_smoothviewheight 0.05 // time of the averaging to the viewheight value so that it creates a smooth transition for crouching and such. 0 for instant transition
index ef330b9a642023be619529237a06498c3129fe85..da107faa9e1c96c34ae791094cc7d342894d98eb 100644 (file)
@@ -46,8 +46,8 @@ void rpn_set(string s)
 
 float rpn_getf() { return stof(rpn_get()); }
 float rpn_popf() { return stof(rpn_pop()); }
-void rpn_pushf(float f) { return rpn_push(ftos(f)); }
-void rpn_setf(float f) { return rpn_set(ftos(f)); }
+void rpn_pushf(float f) { return rpn_push(sprintf("%.9g", f)); }
+void rpn_setf(float f) { return rpn_set(sprintf("%.9g", f)); }
 
 void GenericCommand_rpn(float request, float argc, string command)
 {