Parsing this and storing this as a float not only means all comparisons are done as floats, but also every comparison between this variable and a shaderSort_t enum value like shaderSort_t::SS_NEAREST requires extra code, comparing shader.sort with Util:ordinal(shaderSort_t::SS_NEAREST).
The 5 and 6 values are just another way to write seeThrough or banner, maybe those numbers are a relic of a very old Quake3 version before those were properly named.
Since there is no keyword for that value in the .shader parser, setting this int is a kind of workaround for an incomplete parser.
You'll notice those are all integers, not floats, and parsing integers and doing shader.sort = atoi(token) would work.
But Quake3 code is parsing floats since more than 20 years, is there a good reason for that?
Both XreaL and ET:XreaL also do shader.sort = atof(token), this code is there since first commit of all those repositories and was never modified since:
Dæmon does as well and this code was never modified.
I haven't found a sort with a numeric value in default Tremulous .shader file. In all Tremulous maps formerly listed in betaserv.tk (more than 3000 .shader files) and handful of maps sets integer values, sometime they set sort 6 (which is decal) like in station15-r1.shader, some also set sort 16, in a similar way to Wolfenstein: Enemy Territory.
While I worked on https://github.com/DaemonEngine/Daemon/pull/682 I discovered
shader.sort
is a float.Here is an example of patch turning it to a
shaderSort_t
instead of a float: https://github.com/DaemonEngine/Daemon/compare/6aa28b08dd02aee6e22ffef8d360a62069262eeb...illwieckz/shader-sort-no-floatBut I don't know if we can do this.
Everywhere the code is setting values it is setting
shaderSort_t
enum values, except in one place intr_shader.cpp
when reading.shader
files. It allows the mapper to not only set keywords likeopaque
ordecal
but also numbers, and the number is parsed as float: https://github.com/DaemonEngine/Daemon/blob/6aa28b08dd02aee6e22ffef8d360a62069262eeb/src/engine/renderer/tr_shader.cpp#L3602Parsing this and storing this as a float not only means all comparisons are done as floats, but also every comparison between this variable and a
shaderSort_t
enum value likeshaderSort_t::SS_NEAREST
requires extra code, comparingshader.sort
withUtil:ordinal(shaderSort_t::SS_NEAREST)
.This
shader.sort = atof(token)
is already present in original Quake 3 code: https://github.com/id-Software/Quake-III-Arena/blob/dbe4ddb10315479fc00086f08e25d968b4b43c49/code/renderer/tr_shader.c#L1303-L1305I've noticed a
.shader
files from Quake 3 that sets two time a numeric value instead of using a keyword:According to the enum here: https://github.com/id-Software/Quake-III-Arena/blob/master/code/renderer/tr_local.h#L113-L138
The
5
and6
values are just another way to writeseeThrough
orbanner
, maybe those numbers are a relic of a very old Quake3 version before those were properly named.This
shader.sort = atof(token)
can also be found in Wolfenstein: Enemy Territory: https://github.com/id-Software/Enemy-Territory/blob/40342a9e3690cb5b627a433d4d5cbf30e3c57698/src/renderer/tr_shader.c#L1292-L1294I would only one
.shader
file using numeric values in Wolfenstein: Enemy Territory files:The
16
value is forSS_NEAREST
with a comment about “blood blobs”: https://github.com/id-Software/Enemy-Territory/blob/40342a9e3690cb5b627a433d4d5cbf30e3c57698/src/renderer/tr_local.h#L131Since there is no keyword for that value in the
.shader
parser, setting this int is a kind of workaround for an incomplete parser.You'll notice those are all integers, not floats, and parsing integers and doing
shader.sort = atoi(token)
would work.But Quake3 code is parsing floats since more than 20 years, is there a good reason for that?
Both XreaL and ET:XreaL also do
shader.sort = atof(token)
, this code is there since first commit of all those repositories and was never modified since:https://sourceforge.net/p/xreal/svn/298/tree/trunk/xreal/code/renderer/tr_shader.c#l1304
https://sourceforge.net/p/xreal/ET-XreaL/ci/058289f3c9b016c331e1c364c128ecd1a11ad311/tree/src/renderer/tr_shader.c#l1293
Dæmon does as well and this code was never modified.
I haven't found a
sort
with a numeric value in default Tremulous.shader
file. In all Tremulous maps formerly listed inbetaserv.tk
(more than 3000.shader
files) and handful of maps sets integer values, sometime they setsort 6
(which isdecal
) like instation15-r1.shader
, some also setsort 16
, in a similar way to Wolfenstein: Enemy Territory.At the time I write this, I only found one file setting float values, that's one of us, an Unvanquished file, the mysterious
binary.shader
: https://github.com/UnvanquishedAssets/unvanquished_src.dpkdir/blob/master/scripts/binary.shaderIn this file, all the
sort
invocations use numeric values, and all are float values, they are1537
invocations with float values.All those values are between
15
and16
:Between
15
and16
means they are sorted between what we have in our code being namedSS_BLEND0
(with a comment saying “regular transparency and filters”) andSS_BLEND1
(with a comment saying “generally only used for additive type effects”): https://github.com/UnvanquishedAssets/unvanquished_src.dpkdir/blob/40459674e4c7daa03045a8a3b763925dd8d26294/scripts/binary.shaderAlso, all of them having a different float value means they are all sorted in a way every one of them is sorted before and after another one.
This
binary.shader
file is there since the first commit in Unvanquished repository: https://github.com/Unvanquished/Unvanquished/blob/98b3a1480522dbd90660ee4c6bc91f6d80885286/main/scripts/binary.shaderThis code is used there in
cg_main.cpp
: https://github.com/Unvanquished/Unvanquished/blob/bd8a6aa8dc0e7c3d0cf81d4ffd8785879f551a98/src/cgame/cg_main.cpp#L851-L861It was imported in first Unvanquished commit as a code from
gpp
incg_main.c
: https://github.com/Unvanquished/Unvanquished/blob/98b3a1480522dbd90660ee4c6bc91f6d80885286/src/gamelogic/gpp/src/cgame/cg_main.c#L955-L964The
cg_main.c
file frombase
didn't have it: https://github.com/Unvanquished/Unvanquished/blob/98b3a1480522dbd90660ee4c6bc91f6d80885286/src/gamelogic/base/src/cgame/cg_main.cI had a look at the
cg_main.c
file fromgpp
branch of Tremulous repository and there is no mention of suchgfx/binary
shader: https://github.com/darklegion/tremulous/blob/gpp/src/cgame/cg_main.cI have no idea what those
gfx/binary
shaders with float sort values are for.And then I have no idea why
shader.sort
is a float instead of ashaderType_t
enum.