]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a command to convert -nosRGB to -sRGB skyboxes equivalently.
authorRudolf Polzer <divverent@xonotic.org>
Tue, 24 Sep 2013 08:22:28 +0000 (10:22 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 24 Sep 2013 08:22:28 +0000 (10:22 +0200)
defaultXonotic.cfg
qcsrc/common/command/rpn.qc

index 4a01ad5876a50b842d2a105c1af02ccae4926f0a..1220ae060c1457f0bd9cd6a79aea2bbcc0499401 100644 (file)
@@ -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
index da107faa9e1c96c34ae791094cc7d342894d98eb..66e8554a87d84f3cf539ca17ec9258726b567dd2 100644 (file)
@@ -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");