r/GraphicsProgramming • u/FuckMicahBellBro • 9m ago
Question I made Radiance Cascades viable in any game, but need comments, help, and critisizm
This is just interesting casual read for someone curious, v3 will include a fully detailed, comprehensive breakdown of every single function, heuristic, math and research behind it. Video quality is also low for an easy and quick upload, observed shortcomings are mentioned below. This post is also almost just a copy of my post in r/reshade
Link (not updated to v3): https://github.com/FlibbertigibbetLollygagger/CRCGI-Compensated-Radiance-Cascade-SSGI/tree/main
Rough drafts of source files and tooling for v2.9 beta can be provided, DM me on reddit for that specific request and code study.
The video has some comparisons and quick shadowing showcase. This is a quickly hacked together preset adapted to fit AC1's artstyle. This runs on the pixel shader variant which is far far far heavier in its current form, and is only suitable for old games.
I already had a dgvoodoo DX9 to DX11 translation layer installed on this game, as I couldn't access depth buffer with DXVK. Even on older games, the pixel shader variant (plain reshade .fx file) is heavy and doesn't benefit from compute shader optimization benefits to run at around 5ms. The compute version is tailored for newer games, while this pixel shader variant will be a normal file for compatibility. I haven't maxed out my GPU in AC1 using this effect, nor has it really dropped below a locked 1440p/60fps experience. Either way, old games (DX10 onwards) stay compatible, just not with the desired performance target that v3 prioritizes. I also didn't take frame time measurements for a 2007 game on modern hardware, because even with this heavy shader on top, it's really redundant unless it can max out your hardware, which will most likely not happen unless DXVK is usable on that game with full depth buffer access. I cannot comment on that, as I haven't tested it and I don't intend to. This is for the sake of compatibility.
It works like this:
> make gbuffer
> make more gbuffer
> bro, compensate for no world space access
> let there be dark (CTAO pass)
> let there be light (RCGI pass)
> blend, combine, mash it together
> shit is smeary
Don't expect me to provide detailed explanation of all the passes, it's thousands upon thousands of lines of code.
CTAO or Chord-Thickness Ambient Occlusion (this pipeline's shadowing system, which will also be provided as a seperate shader .fx file and is very lightweight) is tailored for this specific pipeline. This is a semi-bespoke implementation based on VBAO, with thickness aware rejection (blades of grass, hair, etc) to avoid halos above grass. The main complementary data that is fed to this pass (like any other pass that uses geometry reconstruction data) is the data of silhouette aware thickness finder to remove the need for a single assumed thickness. It also has adjustable penumbra (semi realistic soft falloff, not literal penumbra simulation) and, at its base form, is a hybrid raymarched and visibility bitmask derived system for both contact and close to medium range with "zero" halos in any situation and unlees the object is very thin and very far off in the depth buffer, in which case the "hit" is a big dark halo which even at highest, longest range stress tests, is very subtle. This comes at the expense that it has to collect itself in a 10 frame accumulation window, and it fails as a seperate standalone AO method in that sense that it needs to be perfectly clean. This is hyper efficient, and highly stable, and the full details will be provided in a standalone, detailed documentation of the whole people, and also as a seperate reshade filter, as mentioned previously. This can be "perfect" with an in engine implementation, which doesn't need to worry about disocclusion and constant camera movement, but for the "hyper efficient" purposes of this whole project, it works like a charm and completely fills in the gap of missing radiance cascade shadows. As to why I didn't just also use radiance cascade math for shadowing, it's because it can easily cost waaaaay too much performance so I had to come up with a bespoke system that has soft falloff, finds very tight crevices, and doesn't have halos.
The RCGI (Radiance Cascade Global Illumination) part of the pipeline is complemented with screen space protections, including an offscreen canvas that remembers offscreen light and is meant to bridge the literally unachievable gap between screen space and world space, compensates (get it?) for the lack of world space data such as SDF and BVH and Voxels. The need for an adjustable fov slider is almost completely fixed. Because the shader relies on a perspective accurate ray model that decides how to do its 3D impression of the 2D image that it has access to, it relies on a defined fov value. Dynamic fov in games would become a problem then, but CRCGI uses a parallax derived fov estimation system with adjustable adaptation speed.
It's still the full pipeline, the same math, same underlying systems, and the same exact visuals. Full convergence is done in 10 frames for the effect in both versions, and the AC preset is a bit more realistic and tame to fit the grounded look of AC1, but TW3 is more of a fantasy, colorful look with a tad bit of exaggeration in a way that doesn't diminish the atmosphere of that game.
Per game adaptability and default settings are close to being done for reducing the tuning friction, but which sliders to hide, which to bake, and what defaults to bake, are still not finalized.
Where the v1 version outlined the overall pipeline and design goal, and v2 evolved the underlying systems behind the effect, v3 is a natural evolution of this pipeline by using more advanced shadowing, heavy performance optimization and an overall offers much cleaner image quality.
It still exhibits certain quirks, like the shadow disocclusion on camera movement but during normal gameplay it's unnoticable. The pipeline has become harder and harder to debug and polish, and this disocclusion is a compromise for cleaning up the image vs how stable and "anchored" it looks, and for this pipeline's purposes, it takes the crown of being "good enough".
I have no idea how it would run on Steam Deck with a 30fps target. This is tuned on Ampere and default settings, in theory, scale linearly with other Ampere GPUs. Different capabilities of individual GPU architectures can and will affect overall performance in both pixel shader and compute shader variants so while I can guesstimate how it'll perform among Ampere, I have no way to take measurements and no one to take measurements for me. My guess would be that it'll be noticeably faster on GPUs with larger caches (Ada Lovelace onwards, RDNA 2 onwards) because the mathematical loops will fit inside the cache. This is an unconfirmed hypothesis.
My main questions being:
1- How can I improve temporal stability? Shadow disocclusion is very much a problem when camera moves. It's good enough but if there's any, literally any way to improve it, I haven't found it yet or know of it or haven't thought about it yet.
2- Reliance on denoiser is high, I used SVGF denoising alongside a 10 frame temporal accumulation window. I traced noises of source.
I realize these discussions practically require the source code, but I'll only hand private pixel shader versions alongside compiled compute shader versions. Performance metrics on different GPU architectures for future development is needed, and my priority is reducing temporal accumulation and denoiser reliance. I can provide the pipeline code itself as standalone CTAO (plain .fx), CRCGI compute version (with add-on and DX11 or older), and CRCGI pixel shader version (legacy version that is the plain .fx file). I also have no funding to get access to claude anymore and the project is now simply too big to do manually unless you suggest surgical changes that can be done by hand. Even if you have no idea how the pipeline works, mention what you have done to achieve what I want to achieve in a screen space filter (reshade implementation in this case)
The whole compute pipeline runs at 4.6ms to 5.5ms on RTX 3060 Ti/3070/3070 Mobile, but an in-engine implementation eliminates the need for about half of the pipeline and will be cleaner, but I want to polish it as a universal and genuine global illumination method targeted towards average hardware. My RTX A4000 Mobile is bang on average. The pipeline first "makes a G-Buffer" and reconstructs the geometry that it needs for a lighting pipeline to process, and then does the GI/AO lighting and shadowing combo. DO NOT JUDGE IT BASED ON V2 PUBLIC CODEBASE. Documentation is not ready as of yet for v3. Motion and temporal related code is available in all of the three mentioned forms of delivering the source.
Please help me 😂
Edit: realized the subreddit requires AI disclosure. I'm not fluent in HLSL so the code itself is heavily AI Assisted but the pipeline, shadowing method, fixing radiance cascade issues, all of the research, etc are done by me. It's literally AI Assisted. Y'all know AI can't hallucinate a whole lighting pipeline.



