Skip to content

Add ReSTIR#10

Open
res2k wants to merge 26 commits intomasterfrom
restir-update
Open

Add ReSTIR#10
res2k wants to merge 26 commits intomasterfrom
restir-update

Conversation

@res2k
Copy link
Copy Markdown
Owner

@res2k res2k commented Jan 29, 2026

Continuing discussion from NVIDIA#477 as upstream project is archived.

@res2k
Copy link
Copy Markdown
Owner Author

res2k commented Jan 29, 2026

@abalfoort, continuing from NVIDIA#477 (comment):

I got around to looking into it, at least a little.
So I can reproduce the effect as well.

My rough hypothesis right now:
Not enough "good" samples.
The darker "smear" appears in areas on the screen that were just "revealed" (ie they were occluded by the weapon the previous frame(s)); initially, the chosen samples did not hit a light, turning out dark. Only over time more desirable samples are collected, improving the situation.

What to do about it? Not sure right now. Probably read a bit up on state of the ReSTIR art and see what options the pros came up with.

@res2k
Copy link
Copy Markdown
Owner Author

res2k commented Jan 29, 2026

Addendum: Seems things get especially odd when sunlight is involved. Hm.

@abalfoort
Copy link
Copy Markdown

Addendum: Seems things get especially odd when sunlight is involved. Hm.

Or at least, more visible.

Good to see that you still are on this project.
If you are interested, I've moved my Q2RTX project (including the mission packs) to my Gitlab account.

mrzyanide and others added 26 commits April 3, 2026 15:47
ReSTIR is currently only used for direct lighting.
Limiting to the same field is unnecessary and not doing so seems to give better results.
The sampling position was carried along, but not actually used!
Using it also seems to make a perceptible difference.
Looks like a hack to deal with fireflies, but it broke lighting in other ways.
@res2k
Copy link
Copy Markdown
Owner Author

res2k commented Apr 12, 2026

@abalfoort, so after spending quite a while trying to understand more of how this is all supposed to work, and prodding the implementation, I think managed to address the issue you were still seeing (still visible smearing outdoors)...

First of all, be aware it's not entirely gone in all cases; but that is in the nature of the thing: when pixels are disoccluded, the denoiser initially has to guess a lot in that area, and that usually tends to result in comparatively darker pixels.
However, I at least tried to make not worse than the "old" RIS light selection.

As I found out, the ReSTIR implementation actually contained a few hacks that made things look alright when using skybox sky lighting (which I mostly used when checking it out previously), but no so much with physical sky lighting (which is comparively bright). So the main aim was to fix those hacks, yet to keep things still looking nicely.

Other things I found out on the journey:

  • The "old" RIS light selection, in conjunction with the A-SVGF denoiser, is quite effective for Q2's lighting setup.
  • The denoiser actually works quite well with input that changes every frame; ReSTIR's tendency to produce the same samples over multiple frames was actually detrimental to denoising quality, so a puzzle piece was to less aggressively reuse samples.
  • Generally, the aggressive sample reuse seemed to result in lighting appearing to only change sluggishly. But again, some extent that's also due to how the denoiser works.

In conclusion, if you have time, I'd appreciate if you could give that latest branch a spin and see how it works for you.

@abalfoort
Copy link
Copy Markdown

@res2k Thanks for the hard work.
I have compiled (Debian 13) and only had a few warnings:

...
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/main.c: In function ‘add_dlights’:
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/main.c:1868:60: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1868 |                         light_entity_ids[(*num_lights)] = *(uint32_t*)&hash;
      |                                                            ^~~~~~~~~~~~~~~~
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/main.c: In function ‘instance_model_lights’:
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/main.c:1916:73: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1916 |                 light_entity_ids[entity_frame_num][num_model_lights] = *(uint32_t*)&hash;
      |                                                                         ^~~~~~~~~~~~~~~~
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/main.c: In function ‘update_mlight_prev_to_current’:
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/main.c:3007:39: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 3007 |                 entity_hash_t hash = *(entity_hash_t*)&light_entity_ids[entity_frame_num][i];
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
[ 82%] Building C object src/CMakeFiles/client.dir/refresh/vkpt/transparency.c.o
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/transparency.c: In function ‘vkpt_build_cylinder_light’:
/home/arjen/dev/_hobby/q2rtx/src/src/refresh/vkpt/transparency.c:550:60: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  550 |                         light_entity_ids[(*num_lights)] = *(uint32_t*)&hash;
      |                                                            ^~~~~~~~~~~~~~~~
[ 82%] Building C object src/CMakeFiles/client.dir/refresh/vkpt/uniform_buffer.c.o
...

I have started and played baseq2 a little and immediately saw a big difference. I will try to find some time this week to test this, also with the mission packs.

@res2k
Copy link
Copy Markdown
Owner Author

res2k commented Apr 13, 2026

@res2k Thanks for the hard work. I have compiled (Debian 13) and only had a few warnings:

I'll look into them

I have started and played baseq2 a little and immediately saw a big difference. I will try to find some time this week to test this, also with the mission packs.

Awesome!
Take your time. After all, so did I ;)

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

Successfully merging this pull request may close these issues.

3 participants