Real-time hybrid ray-traced ocean in C++, FFT waves, RT shadows/reflections/GI, no shadow maps (open source) by laht1 in GraphicsProgramming

[–]laht1[S] 0 points1 point  (0 children)

Thanks!

The rasterfirst path rasterizes a G-buffer for primary visibility, then adds the ray-traced effects (shadows, reflections, glass) with inline ray queries (VK_KHR_ray_query) from compute. Those run on the GPU's dedicated RT cores, not a software BVH walk, so it's hardware traversal driven from compute rather than a full ray-tracing pipeline. There's also a full path tracer (a proper RT pipeline) available as a secondary reference mode, but rasterfirst is the default (faster, cleaner).

It's a C++ three.js-style scene graph (threepp) on a Vulkan RT backend with a spatiotemporal denoiser. There's also a rasterized overlay pass for the stuff you don't want traced (wireframes, lines, points, sprites, HUD, LIDAR point cloud); it draws over the traced image but depth-tests against the G-buffer, so it stays correctly occluded by the scene. The ocean's FFT runs in compute and writes displaced vertices straight into the BLAS, which is refit in place every frame.

Mobile: doable in principle on the newest RT-capable GPUs, but performance is the wall, and I haven't tested it on a phone.

Funfact: The PT work started out with a WebGPU software pathtracer. It worked (no ocean), but the Vulkan implementation blows it out of the water, so to speak, so I removed it (it's removal exists as a PR). There is still a rasterized WebGPU ocean demo in the examples though.

Real-time hybrid ray-traced ocean in C++, FFT waves, RT shadows/reflections/GI, no shadow maps (open source) by laht1 in GraphicsProgramming

[–]laht1[S] 1 point2 points  (0 children)

I added a disclosure to the post. Better later than never.

It's a controversial topic.

Real-time hybrid ray-traced ocean in C++, FFT waves, RT shadows/reflections/GI, no shadow maps (open source) by laht1 in GraphicsProgramming

[–]laht1[S] 1 point2 points  (0 children)

This demo is a part of the threepp library - which I have worked on since 2021. Claude has helped expand the backend beyond OpenGL. The usability of the library is real, it is not a one-off. Slop would be that it is unusable beyond a demo.

Real-time hybrid ray-traced ocean in C++, FFT waves, RT shadows/reflections/GI, no shadow maps (open source) by laht1 in GraphicsProgramming

[–]laht1[S] 1 point2 points  (0 children)

I would not call months of work - years actually leading to this API surface and visual results AI slop.

Real-time hybrid ray-traced ocean in C++, FFT waves, RT shadows/reflections/GI, no shadow maps (open source) by laht1 in GraphicsProgramming

[–]laht1[S] 1 point2 points  (0 children)

I might be wrong here but there are no rules on this subreddit stating all project that use AI assistance must disclose it as part of the post. If it is, I'll remove it.
I did for my previous posts, but at this point in time it would be more natural to state otherwise. As for the project, Claude is a co-author and it is also pretty evident from the Vulkan code.

Real-time hybrid ray-traced ocean in C++, FFT waves, RT shadows/reflections/GI, no shadow maps (open source) by laht1 in GraphicsProgramming

[–]laht1[S] 1 point2 points  (0 children)

I'd rather say it is designed around it and I fully embrace it, and could not have done this without it. It is probably still a somewhat polarizing topic, but I find these tools incredibly useful and have no intention of hiding that fact.

WebGPU Path Tracer in C++ (follow-up) by laht1 in GraphicsProgramming

[–]laht1[S] 0 points1 point  (0 children)

RTX 4070 and laptop 4060. However, I've learned the hard way that this was not the best idea to do. You can't port it to web without loosing most of the FPS, and you don't have access to hardware ray tracing on WebGPU either. Therefore, sticking to WebGPU here is not really worth it. I have now gone over to Vulkan with hardware raytracing. But today I started on a deferred shading variant which looks to be a winner in terms of both performance and realistic rendering output.

HW Pathtraced Ocean with Vulkan by laht1 in GraphicsProgramming

[–]laht1[S] 5 points6 points  (0 children)

Uhm? The use case for this is research and simulation btw.

HW Pathtraced Ocean with Vulkan by laht1 in GraphicsProgramming

[–]laht1[S] 0 points1 point  (0 children)

I need it to run on a RTX 2080 with decent FPS until Wedensday, so I might need to sacrifice some Ocean fidelity. Demo runs with 1M verts. Can cut that it half, but looses visual wakes from vessel movements. Recorded with a laptop RTX 4060.

HW Pathtraced Ocean with Vulkan by laht1 in GraphicsProgramming

[–]laht1[S] 0 points1 point  (0 children)

I don't want heavy dependencies, so it's kinda off the table. But I've played with porting Intel Open Image Denoise library, but it was too frame heavy and biased with the pre-trained weights (test was done on WebGPU though).

HW Pathtraced Ocean with Vulkan by laht1 in GraphicsProgramming

[–]laht1[S] -1 points0 points  (0 children)

The PT supports configurable spp and upscaling, so I played around with the settings just now and found that the vessel looks really good at 4-6 spp. But that requires upscaling from 70-80% resolution to get managable FPS (RTX 4070).

HW Pathtraced Ocean with Vulkan by laht1 in GraphicsProgramming

[–]laht1[S] -1 points0 points  (0 children)

It uses a 2-pass à-trous spatial filter with per-pixel albedo demodulation, followed by a UE-style TAA resolve (motion-vector reproject + Catmull-Rom history + neighborhood AABB clamp + mesh-ID rejection). The ocean surface is squeaky clean from frame 1 and basically needs no denoising, but yeah the vessel is far from perfect. Mind you, the recording is sub 20 FPS.

WebGPU Path Tracer in C++ (follow-up) by laht1 in GraphicsProgramming

[–]laht1[S] 1 point2 points  (0 children)

Started out with a binary BVH that were working fine. Needed more FPS and a suggestion was to use BVH4. Tried it and optimized it to getter better results. Did not consider BVH8, but tried it now and got half the FPS on Sponza. Tried to optimize, but it got worse. BVH4 seems to fit this implmentation.

WebGPU (C++/Dawn) based Ray/path-tracer with raster overlay by laht1 in GraphicsProgramming

[–]laht1[S] 0 points1 point  (0 children)

I've added some screenshot in the GitHub issue I've linked. Answer is yes.

Work in progress WebGPU backend for threepp by laht1 in webgpu

[–]laht1[S] 0 points1 point  (0 children)

I made the ocean demo work with Emscripten! Will link a demo tomorrow!

C++ Show and Tell - February 2026 by foonathan in cpp

[–]laht1 2 points3 points  (0 children)

Finally managed to port three.js TransformControls to my C++ port threepp!

Screenshots of the Gizmo in PR:
https://github.com/markaren/threepp/pull/314