From 8613f516184769931d50e31a9ff2a8a3e9d4a1b7 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 24 Sep 2013 10:22:28 +0200 Subject: [PATCH] Add a command to convert -nosRGB to -sRGB skyboxes equivalently. --- defaultXonotic.cfg | 24 ++++++++++++++++++++++-- qcsrc/common/command/rpn.qc | 6 +++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 4a01ad587..1220ae060 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -110,11 +110,31 @@ 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)) +// #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) +// #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" +// -nosRGB to -sRGB sky shader conversion: +// +// q3map_sunExt 1 0.6875 0.375 340 25 47 0 16 +// ^^ elevation +// ^^^ sunlight +// q3map_skylight 110 3 +// ^^^ skylight +// +// With that, do: +// ]skybox_nosRGB_to_sRGB 340 47 110 +// rpn: still on stack: new_sunlight: +// rpn: still on stack: 412.122467 +// rpn: still on stack: new_skylight: +// rpn: still on stack: 11.4826183 +// +// The equivalent -sRGB shader then will have: +// +// q3map_sunExt 1 0.6875 0.375 412.122467 25 47 0 16 +// q3map_skylight 11.4826183 3 +alias skybox_nosRGB_to_sRGB "rpn $3 1024 div $rpn_sRGB_to_linear 1024 mul /new_skylight: $3 1024 div $1 256 div $2 0.017453 mul sin mul add $rpn_sRGB_to_linear $3 1024 div $rpn_sRGB_to_linear sub 256 mul $2 0.017453 mul sin div /new_sunlight:" // 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 da107faa9..66e8554a8 100644 --- a/qcsrc/common/command/rpn.qc +++ b/qcsrc/common/command/rpn.qc @@ -203,6 +203,10 @@ void GenericCommand_rpn(float request, float argc, string command) rpn_setf(exp(rpn_getf())); } else if(rpncmd == "log") { rpn_setf(exp(rpn_getf())); + } else if(rpncmd == "sin") { + rpn_setf(sin(rpn_getf())); + } else if(rpncmd == "cos") { + rpn_setf(cos(rpn_getf())); } else if(rpncmd == "max") { f = rpn_popf(); f2 = rpn_getf(); @@ -562,7 +566,7 @@ void GenericCommand_rpn(float request, float argc, string command) print(" f f eq|ne|gt|ge|lt|le|max|min -----> f : compares two numbers\n"); print(" f neg|abs|sgn|rand|floor|ceil------> f : negates/... a number\n"); print(" f not|bitnot ----------------------> f : logical and bitwise negation\n"); - print(" f exp|log -------------------------> f : exponential function & Co.\n"); + print(" f exp|log|sin|cos -----------------> f : exponential function & Co.\n"); print(" f f f bound -----------------------> f : bounds the middle number\n"); print(" f1 f2 b when ----------------------> f : f1 if b, f2 otherwise\n"); print(" s s union|intersection|difference -> s : set operations\n"); -- 2.39.2