Skip to content
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

Light "seams" in corners at high lightmap resolution #98

Open
TomArrow opened this issue Mar 19, 2022 · 7 comments
Open

Light "seams" in corners at high lightmap resolution #98

TomArrow opened this issue Mar 19, 2022 · 7 comments

Comments

@TomArrow
Copy link

2022-03-19 13_17_55-lm_0001 hdr @ 149% (RGB_32_) _

When I output very high resolution lightmaps (in this case 4096*4096), I start getting random light seams in corners, which is very irritating and makes the lightmaps almost useless. Looking at the lightmaps, it looks like it's almost always exactly 3 pixel wide/high strips.

Is there any way to fix this?

These are my compile settings:

q3map2 -game jk2 -fs_basepath "C:\JK2\GameData\base_extracted" -meta -v b-mountain.map
q3map2 -game jk2 -fs_basepath "C:\JK2\GameData\base_extracted" -vis -v b-mountain.map
q3map2 -game jk2 -fs_basepath "C:\JK2\GameData\base_extracted"  -light -filter -lightmapsize 4096 -sky 4 -dark -pointscale 0.125 -spotScale 0.125 -areascale 0.125 -bounce 2 -bouncescale 4 -bouncegrid -dirty -patchshadows -fast  b-mountain.map

I'm also attaching the .map file (not my own work) for debugging purposes
b-mountain.zip

As a general rule, it seems that the higher the lightmap resolution, the more places suddenly have those light strips/seams in the corners. At 1024x1024 it's only a few places, at 2048x2048 it's starting to be in many places and at 4096x4096 it's (I'm exaggerating) on every other corner. It's especially irritating in very dark corners that suddenly have bright strips along their edges, ruins the atmosphere and suspense of disbelief.

@Garux
Copy link
Owner

Garux commented Mar 19, 2022

It's hard to use this test map, as many textures are missing even with jk2 installed, and it's so huge, that >20GB of ram is required with suggested settings.
Don't you have simple test box with the problem reproducible?

@TomArrow
Copy link
Author

Oh sorry about the textures. The map and required textures is this one: https://jkhub.org/files/file/3065-b-mountain/

Only thing I changed is the .map file and the .shader file which I forgot to include before, here it is:
b-mountain.zip

Sadly I don't have a smaller file to reproduce and tbh I don't even know how to map at all or how to even use Radiant so I would be pretty challenged to come up with one. RAM usage was about 120 GB (most of it swapfile naturally) with these settings haha. But I imagine you could just cut off parts of the map? The parts where it is most noticable are in dark areas like those dark narrow corridors with few/dark lights in some places.

For what it's worth, I made a little tool that post-processes the lightmaps to remove the seams. https://github.com/TomArrow/q3map2_lightmapSeamFixerHDR

It detects strips of fixed width that are at least 4 pixels long. The fixed width was set at 3 pixels at first and already got rid of a lot of them, but a few were left, so I changed it to 1 to 5 pixels and now it seems the lightmaps are relatively clean. So it's not actually always 3 pixels I guess. But obviously it's not a very elegant solution.

But they are always at borders of surfaces it seems. Not sure if any of this helps.

@Garux
Copy link
Owner

Garux commented Mar 19, 2022

Such lightmaps do not work ingame:
image
lm has expected shadow:
image
outline there cause of -dark, no -dark:
image
Such samplesize makes no sense usually, also map is huge, how much lms take?

@TomArrow
Copy link
Author

TomArrow commented Mar 19, 2022

I remember I had issues compiling it initially because I needed to add the shader file to the shaderlist.txt or something. As for them not working ingame, I had to modify the engine code because jk2 normally doesn't support external lightmaps.

The parts you show are fine, no issues there. The outline I mean is always bright, and it's always in corners/at edges of surfaces. For another example, in the very top of the map, there's little blocks sticking out of the wall and in the edge where the cubes connect to the wall, there's that light seam.

Here's a whole lightmap file demonstrating the issue (it's one out of 49 files):
lm_0000.zip

You can see it all over the image, those bright thin yellow lines at edges of surfaces.

@Garux
Copy link
Owner

Garux commented Mar 19, 2022

This gives no usable info on the issue, these areas are likely legitimately lit.
What would help is barebones quickly compilable map, demonstrating the problem.
To note, problem may be engine, downscaling huge images or improper texture clamp param, allowing neighbor pixels to leak in.

@TomArrow
Copy link
Author

Hmm okay. I don't know if I'll be able to create a smaller version of the map that demonstrates the issue. If I manage to do it, I'll post the results here for further analysis.

@MoritzJT
Copy link

MoritzJT commented May 9, 2023

@TomArrow fixed by mapping with proper MITRE in mind and providing a shell of func_usable with start off spawnflags as a black shadow blocker for example - that way your sky will not leak onto slim trims such as the outsides of brushes touching the void where it's still being reached by for example sky light or other light entities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants