w23 / xash3d-fwgs

Vulkan Ray Tracing fork of Xash3D FWGS engine. Intended to be merged into master at some point in the future.
162 stars 16 forks source link

rtx: better shadow pre-culling #102

Open w23 opened 3 years ago

w23 commented 3 years ago

For some areas static map geometry is not reachable by some light sources (permanently shadowed). But current culling is not aware of that because bsp visleaf is still reachable.

We could do two things for example:

w23 commented 2 years ago

Fully dynamic culling draft proposal high-level overview:

  1. Use the same light clusters grid as previously (although it can be made smaller)
  2. Each grid cell has a table for lights, where for each light it says whether it's known to affect this cell or not.
  3. In normal rendering pass only sample lights that are known to be visible.
  4. Regularly check known invisible lights in case they can become visible. This regular check might be every N frames or every T milliseconds. Mark this light known visible if it is.
  5. If a light has been invisible for N frames/T ms mark it as known invisible.

Q:

Regular check variants:

  1. Separate pipeline/pass. Pro: easier to control. Cons: waste sampling rays, no color will be used.
  2. Embed into regular ray tracing. Do it only on 1st bounce (direct lighting). Synchronize light clusters writing between ray groups (how?). Pro: does not waste sampling rays (although can cause firefly). Cons: slightly more complex.

Further improvements:

  1. Instead of bool visible maintain a float pdf for avg/characteristic pdf value. Renormalize every frame. Why: potentially allows better and cheaper light sampling in the shader.