From 935bb36619f777395e023f3960caae9ec8a7dd91 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 24 Sep 2013 09:59:36 +0200 Subject: [PATCH] RPN: more accuracy; add sRGB conversion macros. Usage: rpn 0.1 $rpn_sRGB_to_linear --- defaultXonotic.cfg | 5 +++++ qcsrc/common/command/rpn.qc | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 6cd876b4b5..4a01ad5876 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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 diff --git a/qcsrc/common/command/rpn.qc b/qcsrc/common/command/rpn.qc index ef330b9a64..da107faa9e 100644 --- a/qcsrc/common/command/rpn.qc +++ b/qcsrc/common/command/rpn.qc @@ -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) { -- 2.39.2