-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[idea] pack 4 surface lightmaps into one? #1095
Comments
I have a couple of questions, that come from a deep ignorance of the matter: 1.- From what I understand, in practical terms you did an "atlassed" texture from the 4 lightmaps. 2.- Something that only may affect the Remaster project. The Remaster (or Rerelease) uses a 4 times bigger lightmap according to this. Could it have a negative effect on graphics cards that do not have a very high resolution available for each texture uploaded? I'm talking about ancient hardware here, but it's just to know. |
|
I suppose size of light map and count of light map textures for gl1 was just most common limit size of textures of available gpu's. Gl3 render use bigger textures and less light maps textures as gpu's has much bigger memory limit value. I have found only one map in Rerelease that requires change count of light maps. |
Thanks for the answers @BraXi !
This was what worried me a bit, how a change like that would behave on older hardware. |
I have not tested on old hardware, in same time I suppose it should be supported without issues as I have not changed light map sizes in gl1 render and render loads all Rerelease maps without issues related to textures count or size . |
2024-03-24.20-15-03.mp4I have implemented lightmaps that way in my own engine and done a test by pushing lightmap scale to the max and running many lightstyles at once, seems pretty solid and no graphical glitches happening, level compiled with the lightmap bindings count is pretty huge at that texel density anyway , with default lightmap resolution its much much lower |
I was originally being confused about the 4 different lightmaps and their usage in GL3. As @0lvin said, reading the GL3 code makes clear that the size of one lightmap is 1024x512, which are equivalent to 32 lightmaps in the old 128x128 dimensions. The usage of 4 "lightmaps per surface" I don't fully get, but are supposed to be "used for switching on/off light and stuff like that", according to comments on the code. But after that, they recognize that "most surfaces only have one really and the remaining for are filled with dummy data". So, they are empty in most cases: Number of lightmaps come from here: ...but after having done multitexturing in GL1, I agree with @BraXi that 2 TMUs (one for color, the other for light) are enough for most use cases in Quake 2. Didn't dynamic lights on GL3 supposed to come from a fragment shader? AFAIK that was the main motivation behind having 4 "styles" for each surface. Still, seeing all of this was a good excuse for my new PR, where I implemented 512x512 lightmaps in GL1 by just generating them in that size, so we save ourselves the trouble of converting coordinates for each "sub-lightmap" afterwards. |
This relates to the tools source, there is a max number of 32 static light styles (normal, flicker, pulse, strobe, etc) that can be applied to a surface, where the engine only ever applied 4 per surface. Likely for performance, memory or time constraints. Max number of "lightstyles" MAX_STYLES = 32. Anything over MAXLIGHTMAPS = 4, gets clamped. |
Digging through the lighting code I've noticed that there are 4 lightmap textures being created for each lit surface, which is understandable given thats the maximum count of lightmaps per surface, but It could be improved to build a single texture containing 4 lightmaps which in return would result in less texture binds when drawing lightmapped world geometry and likely improve fps a little. I've only checked GL3 renderpath and I assume GL4 does the same.
I think the benefits are pretty noticeable
r_lightmap
(set tmu0 to white texture) andr_fullbright
(set tmu1 to white) :)Yamagi:
For reference, in my own project I upload all 4 surface lightmaps into a single texture:
and later blend them together in shader:
The text was updated successfully, but these errors were encountered: