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

Possible solution to reconstruct light entities from lightmaps #1298

Open
VReaperV opened this issue Sep 13, 2024 · 1 comment
Open

Possible solution to reconstruct light entities from lightmaps #1298

VReaperV opened this issue Sep 13, 2024 · 1 comment

Comments

@VReaperV
Copy link
Contributor

VReaperV commented Sep 13, 2024

Given the conversation in #1209 I've had some thoughts on how we might be able to reconstruct light sources to create shadowmaps for maps that we don't have sources for, so I'm putting them here so they aren't lost.

One possible approach to reconstructing them would be a multi-pass process:

  1. Voxelize all of the geometry (this would probably be best done with some sort of sparse acceleration structure, since most of the map volume would be empty space). Assign values to voxels based on the lightmaps.
  2. Process groups of n×n×n voxels (there's probably a more efficient way to do this since surfaces are flat), convert RGB values into luminance, then infer light angle based on the derivative of voxels "mirrored" over the center.
  3. Convergece phase: go over each of those groups and converge angles of nearby groups. This way, if for example, there was an emissive surface that resulted in angle being deemed as 90° for some of the groups, would have it corrected. This would also mean that groups affected by more than one light source would simply converge to the nearest one. This would, however, still have edge cases, like this (light0 and light2 are at a non-90 angle, while light1 is perpendicular):
    image
  4. Ray tracing phase: light from each group based on those angles would be traced through the map with a specified amount of bounces, places where it hits would have some sort of value changing that represents the amount of light sources and their strength.
  5. The previously acquired values from ray tracing phase would be used to construct light sources, potentially merging multiples of them.
  6. Perhaps a phase that would recreate the lightmap and do some adjustments based on the difference between result and original lightmaps?
@VReaperV
Copy link
Contributor Author

VReaperV commented Oct 17, 2024

So since the .shader files keep the information on which shaders emit light, this might be easier to do, since we recreate the lightmaps created by these light-emitting shaders and then subtract it from the lightmaps we already have, thus leaving only the light entities parts of lightmaps. We would, however, also need to know what settings the map was built with to produce correct results.

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

No branches or pull requests

1 participant