q3map2: add -externalnames option to write explicit external lightmap names...
q3map2: add -externalnames
option to write explicit external lightmap names when writing style shaders
It makes possible for game engines to run less code on each rendering frame by not doing any computation to find the file.
On some game engines it may even make the lightmaps be processed with simpler GLSL code as they will be processed as simple colormaps instead of more complex code purposed for usual lightmaps with features that aren't needed in such situation anyway.
Or some engine may implement a specific GLSL code to blend multiple colormaps in a single pass without having to implement alternate code for lightmaps.
The option is believed to be only safe when external lightmaps are used, so using -externalnames
implicitly enables -external
.
Example with scripts/q3map2_gloom2.shader
produced when compiling the Gloom2 map for Unvanquished, the diff is before/after this patch:
-gloom2/7C9AD47A87BC98CCA1FF30C4D788DD47
+gloom2/72353935F9542782B847B2E329A8CC80
{ // Q3Map2 defaulted
{
map $lightmap
rgbGen identity
}
// Q3Map2 custom lightstyle stage(s)
{
- map $lightmap
+ map maps/gloom2/lm_0000.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave noise 1 .75 1.6 4.2 // style 2
tcGen lightmap
tcMod transform 1 0 0 1 0.54492 0.10156
}
{
- map $lightmap
+ map maps/gloom2/lm_0000.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave noise 1 .5 3.7 4.9 // style 3
tcGen lightmap
tcMod transform 1 0 0 1 -0.38672 0.19043
}
{
- map $lightmap
+ map maps/gloom2/lm_0000.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave noise 1 1 2.6 1.3 // style 4
tcGen lightmap
tcMod transform 1 0 0 1 0.24023 0.19043
}
{
map textures/gloom2/e8clangfloor05c.tga
blendFunc GL_DST_COLOR GL_ZERO
rgbGen identity
}
}
-gloom2/15F4DE8571DF6BA4B8F54BE06445A8A3
+gloom2/EC8E06CEB8488CD5FCDFCC6591453C89
{ // Q3Map2 defaulted
{
map $lightmap
rgbGen identity
}
// Q3Map2 custom lightstyle stage(s)
{
- map $lightmap
+ map maps/gloom2/lm_0002.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave noise 1 .75 1.6 4.2 // style 2
tcGen lightmap
tcMod transform 1 0 0 1 -0.50000 0.50000
}
{
- map $lightmap
+ map maps/gloom2/lm_0002.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave noise 1 .5 3.7 4.9 // style 3
tcGen lightmap
tcMod transform 1 0 0 1 -0.21777 0.02637
}
{
map textures/gloom2/floor1_l3_1a.tga
blendFunc GL_DST_COLOR GL_ZERO
rgbGen identity
}
}
Note that q3map2 already writes the full path in some situations, here this shader is already written this way before this patch, so we know engine supporting light styles are already expected to support this way of doing lightstyles:
gloom2/4AE931928BA2A9E2B778C73587A06049
{ // Q3Map2 defaulted
{
map $lightmap
rgbGen identity
}
// Q3Map2 custom lightstyle stage(s)
{
map maps/gloom2/lm_0002.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave noise 1 .5 3.7 4.9 // style 3
tcGen lightmap
}
{
map textures/gloom2/es_crate_orange_top.tga
blendFunc GL_DST_COLOR GL_ZERO
rgbGen identity
}
}