Open shaunlebron opened 5 years ago
Thanks, looks like the call to get_primary_ray
is where we can do the projection. 👍
Yes, you just need to make sure to also change all the code that uses global_ubo.VP
My practical knowledge of path tracing is too limited to be any help here, but as someone who's spent far too much time trying to come up with needlessly clever raster projections to do this in other engines without the post-process step (spoiler alert: haha nope), I'm super excited to see if you can make this work. 😃
vp = vector projection? found this reference: https://github.com/cschied/q2vkpt/blob/a4de8e90ea86a31e0cc8c6f74303c2dd473a56ca/src/refresh/vkpt/shader/asvgf_fwd_project.comp#L90
This is the view-projection matrix, going from world-space to clip-space.
Ah I see now, thanks. Here's a plan, if you wanna check it:
These matrices are used for standard projection:
global_ubo.VP
- forward projection matrixglobal_ubo.invVP
- inverse projection matrixNOTE: Non-linear projections can't be performed by matrices—it's a linear algebra afterall.
To swap out the standard projection with a non-linear one—any time the above matrices are multipled by a vector, we have to replace them with calls to custom projection functions:
global_ubo.VP * ws
-> global_ubo.customVP(ws)
global_ubo.invVP * cs
-> global_ubo.customInvVP(cs)
Add projection functions to global_ubo.h:
customVP(ws)
- from world space to clip space (forward projection)customInvVP(cs)
- from clip space to world space (inverse projection)Modify to use inverse projection (customInvVP
) here: https://github.com/cschied/q2vkpt/blob/a4de8e90ea86a31e0cc8c6f74303c2dd473a56ca/src/refresh/vkpt/shader/path_tracer.h#L282
Modify to use forward projection (customVP
) here:
https://github.com/cschied/q2vkpt/blob/a4de8e90ea86a31e0cc8c6f74303c2dd473a56ca/src/refresh/vkpt/shader/asvgf_fwd_project.comp#L90
The plan looks good! Let me know if you need any additional information. There might be the need to fix some of the reconstruction filter but we'll have to see the results first.
Congrats on the project 🎉 I wanted to add that path-tracing isn't just the holy grail for lighting—it also frees the renderer to use different projections for showing wider FOVs without terrible distortion:
Before I jump in—could you weigh in with your thoughts? I imagine this wouldn't be hard to do since each pixel just has to map to a different ray determined by the chosen projection, but I'm not sure if anything in the pipeline assumes the standard projection. Thanks for your thoughts.