Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Implement ReSTIR sampling#475

Closed
abalfoort wants to merge 3 commits intoNVIDIA:masterfrom
abalfoort:restir
Closed

Implement ReSTIR sampling#475
abalfoort wants to merge 3 commits intoNVIDIA:masterfrom
abalfoort:restir

Conversation

@abalfoort
Copy link

Code from Sirtsu55:
Sirtsu55@33d91e3

I was reading through the issues and found this one and remembered I saw an implementation of ReSTIR of Sirtsu55.

So, all credits go to Sirtsu55. I don't know if this is even wanted, but it was a relative small change.

@res2k
Copy link
Contributor

res2k commented Jun 2, 2025

Generally, the changes seem to based off an older version and probably need more "merge work".
Eg I don't think get_spherical_triangle_pdfw should simply be removed.

@abalfoort
Copy link
Author

I was afraid of that and this is also where my knowledge ends.
Do you want me to close this PR, or do you want to keep it?

@WabbitToonz
Copy link

sorry if this is not the propper place to show this
i tried abalfoort restir in actions (date 6/2/2025 )and notised shaows working where they were not and noise seems cleaner .
Here os a picture left is before and right is abalfoort restir
https://ibb.co/27L28PSd

@abalfoort
Copy link
Author

Very nice.
Could you also post links of the mods you're using?
I usually keep it clean for development purposes, but that looks really good.

@WabbitToonz
Copy link

my mod is unreleased mix of q2rtx /quake 1/ sprawl models
other older videos are on my youtube
https://www.youtube.com/@erickarz9581

@res2k
Copy link
Contributor

res2k commented Jun 2, 2025

i tried abalfoort restir in actions (date 6/2/2025 )and notised shaows working where they were not and noise seems cleaner .
Here os a picture left is before and right is abalfoort restir
https://ibb.co/27L28PSd

Handy. Putting it inline for convenience:
image

There's certainly less noise and more detail visible (esp. in the scratches).
But there's also light in some places where there was only shadow previously - eg in the left corridor, or the space above it.
Not sure which side is more accurate, tho.

[Edit] Also interesting: the FPS counter is visible, indicating that ReSTIR's FPS are ~10% lower.

@WabbitToonz
Copy link

WabbitToonz commented Jun 3, 2025

so i wanted to share 2 videos of that arera that in the picture (without and with restir).
the video with restir shows shadows where they were not before.
https://www.dropbox.com/scl/fi/r2mgezyjdmmobdw50yfkd/Quake-2-RTX-Remaster.zip?rlkey=dysm5vqojvnqd5troma5h0nfw&st=zs8pee69&dl=0

@abalfoort
Copy link
Author

Nice, it's looking a lot better than expected.
I have been playing for some time now and, apart from the FPS loss, I haven't seen any issues.

@res2k What is needed, if any, to get this PR approved?

@res2k
Copy link
Contributor

res2k commented Jun 3, 2025

Nice, it's looking a lot better than expected. I have been playing for some time now and, apart from the FPS loss, I haven't seen any issues.

@res2k What is needed, if any, to get this PR approved?

Well, you should rather ask that @apanteleev, as he's the only one who can actually commit.

Personally, as stated earlier, I think the changes should be updated to not remove features.
From a quick glance, the following features seem to be steamrolled:

Additionally, I would try to check if using an UBO flag to choose ReSTIR vs "old" sampling, and having shaders carrying all the logic, would have a performance difference compared to eg specialization constant(s) or different variants decided via preprocessor.

@res2k
Copy link
Contributor

res2k commented Jun 5, 2025

Ok, so I'll try to tackle this (as in "bringing it into the shape I'd like it to be"). No idea how long I'll take, though.

@abalfoort
Copy link
Author

Thanks. That would be great.
I tried to get into the code with the above mentioned commit #266, but was taken aback by the complexity. That'll take time.
So, if you're willing to upload changes in batches, that would be very helpful.

@abalfoort
Copy link
Author

Today I restored #266. That was straight forward.

But now I'm looking at the spotlight emission profiles.
I suppose, in src/refresh/vkpt/main.c the "add_dlight_spot" function needs to be restored. It is called from "add_dlights" after the "case DLIGHT_SPOT" which is heavily changed with this PR.

So, what would be best to do with this part of the code:

				case DLIGHT_SPOT:
					// Old code
					light->type = DYNLIGHT_SPOT;
					add_dlight_spot(light, dynlight_data);

					// New Code - Copy spot data
					VectorCopy(dlight->spot.direction, light->positions + 6);
					light->positions[4] = dlight->spot.cos_total_width;
					light->positions[5] = dlight->spot.cos_falloff_start;
					hash.model = 0xFD;
					break;

@res2k
Copy link
Contributor

res2k commented Jun 10, 2025

But now I'm looking at the spotlight emission profiles.

I've actually already created a branch with the notes features preserved: https://github.com/res2k/Q2RTX/tree/restir-update

However, I'm still collecting some additional things for a PR write-up, hence I didn't publish that branch yet...

@abalfoort
Copy link
Author

I see, you're splitting the change in separate commits. Thanks, that way I can better understand the code changes.

Now that you created a new branch, shall we close this PR?

@res2k
Copy link
Contributor

res2k commented Jun 10, 2025

Now that you created a new branch, shall we close this PR?

If you prefer. Though I'd probably wait until the "other" PR.

@res2k res2k mentioned this pull request Jun 10, 2025
@res2k
Copy link
Contributor

res2k commented Jun 10, 2025

I see, you're splitting the change in separate commits. Thanks, that way I can better understand the code changes.

Now that you created a new branch, shall we close this PR?

Created #477. There are some more observations in there, take a look.

@apanteleev
Copy link
Collaborator

Is this PR superseded by #477? If so, please close this one.

res2k added a commit to res2k/Q2RTX that referenced this pull request Jun 28, 2025
@abalfoort
Copy link
Author

Superseded by #477 - closing

@abalfoort abalfoort closed this Jun 28, 2025
res2k added a commit to res2k/Q2RTX that referenced this pull request Oct 31, 2025
@abalfoort abalfoort deleted the restir branch December 11, 2025 08:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants