ioquake / ioq3

The ioquake3 community effort to continue supporting/developing id's Quake III Arena
https://www.ioquake3.org/
GNU General Public License v2.0
2.34k stars 522 forks source link

OpenGL2: r_mergeLightmaps 1 breaks shaders using internal and external lightmaps #622

Closed zturtleman closed 6 months ago

zturtleman commented 7 months ago

In World of Padman (1.6)'s wop_trashmap the shaders use both internal and external lightmaps in the same shader (external lightmaps generated by q3map2 for a strobe light lightstyle).

The surfaces have an internal lightmap index, which causes OpenGL2's r_mergeLightmaps to offset lightmap tex coords, for merged internal lightmaps atlas. However this breaks using tcGen lightmap with external images.

https://github.com/ioquake/ioq3/blob/f7c12a1cf77335145800507b1cc50b0957e9e381/code/renderergl2/tr_bsp.c#L643-L652

This can be worked around using r_mergeLightmaps 0.

I ported r_mergeLightmaps to opengl1 once and if I remember correctly the performance was worse or the same and I didn't commit it. (Though this would possibly vary by hardware.) I don't know if r_mergeLightmaps is worth fixing or if it should just be removed.

It may be possible to add a tcMod that will undo the atlas offset to the tcGen lightmap stages that reference an external image if lightmapIndex >= 0 and r_mergeLightmaps is enabled. Internal lightmaps are more likely to be possible to use combined draw call with a base texture; adding a tcMod to them would prevent that, at least if not extending GLSL shaders for this.


World of Padman issue: https://github.com/PadWorld-Entertainment/worldofpadman/issues/54