DaemonEngine / Daemon

The Dæmon game engine. With some bits of ioq3 and XreaL.
https://unvanquished.net
BSD 3-Clause "New" or "Revised" License
306 stars 60 forks source link

Static reflections issues #1310

Open VReaperV opened 2 months ago

VReaperV commented 2 months ago

This is to keep track of issues with static cubemap reflections, since there's multiple of them.

To enable reflections, use /r_normalMapping 1; r_deluxeMapping 1; r_specularMapping 1; r_reflectionMapping 1; r_physicalMapping 0/, then /buildcubemaps. Material system currently also won't select the correct cubemaps since that requires the core feature to work properly first. Use /r_showCubeProbs 1 to see where they are placed.

Primary issues:

Secondary issues:

VReaperV commented 2 months ago

Perhaps it's better to distribute cubemaps more uniformly and access them through e. g. an octree. When building the cubemaps we'd need to somehow check if each spot is "inside" the map.

slipher commented 2 months ago

The second nearest cubemap seems to never be selected at all.

It can happen. It's just rare because the lookup only checks a 100x100x100 box and the probes are too sparsely distributed. In most voxels there isn't even one.

VReaperV commented 2 months ago

Increasing the area it checks did indeed make the second lookup yield some probes.

VReaperV commented 2 months ago

On map thermal, for example: 5 probes together in a space that you can't even go to without noclip: unvanquished_2024-09-22_222029_000 Here most probes are in the same area, yet there are none above the platform: unvanquished_2024-09-22_222053_000 And here you can see how the probes are bunched up to one side: unvanquished_2024-09-22_222227_000

The current algorithm used to place probes just goes through every BSP node and places the probes there. It attempts to skip nodes in the void, but fails to actually do so.

VReaperV commented 2 months ago

A few possible solutions to that:

  1. Place probes on a grid. For better distribution, we can still use the loop over BSP, but "snap" the probes to the grid.
  2. We can use the solution for shadow-castng lights reconstruction proposed in #1298 to find voxels (or, indeed, places on a grid) that have the most light rays going through them and perhaps distance to surfaces (i. e. a voxel that is close to some surfaces is less likely to be a probe candidate).
  3. There's also this paper: https://www.cs.cit.tum.de/fileadmin/w00cfj/cg/Research/Publications/2011/Assisted_environment_probe_placement/aepp.pdf, which explores the use of a combination of irradiance fields and image comparison to remove extra probes.
VReaperV commented 2 months ago

Placing probes on a grid would also speed the lookup up by a lot, since right now it's quite slow while at the same time not even finding any probes a lot of the time.

VReaperV commented 2 months ago

Something like 128 or 256 seems to be a reasonable probe spacing that balances the amount and distribution. With 128 some of the largest maps that we have (e. g. https://users.unvanquished.net/~sweet/pkg/map-voxelworld0_0.dpk) it'd only be a ~500 KB array. On regular maps it will be something like ~138 KB on the larger maps. We can also just put it in a cvar or parse it as an optional keyword in worldspawn.

slipher commented 2 months ago

Did you mean MB? If a probe uses 6 3232 * 3 bytes that's 18K so you could only store a handful of them with that much memory.

VReaperV commented 2 months ago

Did you mean MB? If a probe uses 6 3232 * 3 bytes that's 18K so you could only store a handful of them with that much memory.

I meant for the lookup array. That array would just have an index corresponding to a cubemap, and different elements of that array can point to the same cubemap. The point of using it is to make the lookup fast.

VReaperV commented 1 month ago

Cubemaps can only be built after loading a map. I don't quite remember what I meant by that, but probably that cubemaps can't be distributed in a dpk. Given the features added on #1355 this seems infeasible:

  • Probe placement and quality can be changed, and this requires rebuilding them.
  • If probe placement and quality become independent of user settings, this can be changed, but so far that is not planned.
  • Cubemaps would take up way too much space as they currently, resulting in drastically increased download times, and more memory required to run a server with such feature.