r/GraphicsProgramming • • 11h ago

Question Do you really need g-buffer in your renderer?

6 Upvotes

Hello everyone hope you have a lovely day.

I was Reading learnopengl ssao chapter to support ambient occlusion after setting up my pbr renderer, but the one thing I found very strange was that It used g-buffer in this tutorial, I don't use g-buffer or deferred rendering technique in my renderer I use clustered forward+ rendering technique so I didn't need the g-buffer.

And Here I started to ask myself this question, Is there on the long run any advantage of implementing g-buffer? like really do I need it?

Does any strong engine like unreal or unity use g-buffer?

Thanks appreciate your help and your time!


r/GraphicsProgramming • • 16h ago

Procedural Wildlands: how the grass, trees, stones and clouds are rendered

31 Upvotes

Wildlands runs in the browser through WebGPU and natively through DirectX 12 or Metal, using Rust, wgpu and WGSL. The vegetation, stones and clouds are generated in code. :) So therefore, not a imported 3D models.

Grass/Foliage and wind

In the CPU, each blade is rebuilt every frame from a stable hash, so this allows that it can come back in the same place without needing to store mesh for each of its blade. And Compute, in GPU, passes the selection and compacts the plants, and then prepare a indirect draws.

Vertex Shader is building each blade as curved Bézier shape and bends it depending on the wind strengthness and direction. At my testing with profiling, it showed that separate compute dispatches cost more than the extra indirect draws, so I was combining the plant types into one dispatch (at least, in my macOS machine).

Yes, the grass also thins out with distance (LOD), so, the remaining blades get wider to keep the field from the looking bare.

This line comes from the vertex shader excerpt:

let fuller = pow(1.0 / max(keep, 0.12), 0.6);

Each blade also has their own stable rank, so it gives a gradual fade around the cutoff.

The wind itself is from two layers of moving noise, so its pretty much simple and basic. The tree leans, branches moves, and flutters the leaves. Even a gust moves through both the meadow and canopy.

Related reading:

- Eric Wohllaib, Procedural Grass in Ghost of Tsushima, GDC 2021

Trees

Trees and bushes uses "space colonization", and branches grow towards attraction points inside the crown, and the points disappear once reached. With clustering with nearby groups on the crown surface gives then the silhouette separate lobes, instead one smooth blob.

Trees also uses LOD here, at further away, leaf cards and cheaper bark shading takes over, and the lost LOD level uses a card built form eight views (Imposters LOD) to maintain high details while very low vertices count.

References:

- Runions, Lane and Prusinkiewicz, Modeling Trees with a Space Colonization Algorithm, 2007

- Shinozaki et al., The Pipe Model Theory: Basic Analyses, 1964

Stones

Stone is pretty much simple here, it starts as sphere grid displaced with 3D value noise. And then there is random planes cut to get "flat surface" for the stone. Normals leans towards the cutting planes so the faces looks fractured instead just "rounded".

The material uses procedural triplanar mapping, with moss shells on upward and weather-facing surfaces.

Clouds and sunlight

Clouds was a bit of challenge to implement, clouds are raymarched into cached 4096x1280 sky image, split into 8x4 tiles. With a steady view, one tile updates like only every third frame. A fast camera movement or cloud changes triggers several updates per frame. Unfortunately, this isn't perfect yet and sometimes you will be able to see some traces of imperfections / cuts at the cloud yet...

With the cache, it stores the cloud distance along with the color and fullscreen pass uses that idstance to re-project the clouds for the current view and movement since the tile was drawn.

New tiles fade in over a few frames very slowly and in chunk-ways.

As for lightning, I was using combination of "Henyey-Greenstein-form" lobes with a cheap multiple-scattering term, so then the cloud can still keep the base pale grey. Grass / trees from the shadow uses a separate cloud-shadow texture.

And the sun shafts are marched through the shadow maps, with cloud shadow included!

For background on volumetric cloud rendering, The Real-Time Volumetric Cloudscapes of Horizon Zero Dawn, SIGGRAPH 2015:

https://www.guerrilla-games.com/read/the-real-time-volumetric-cloudscapes-of-horizon-zero-dawn

----

Explore this demo in your browser (or... simply download the files to run natively in Windows or macOS!):

https://share.uverse.dev/kpHWOGxHMldiZyBFWuRLY_X7ctE4A5WLZI-FuDM081w

AI disclosure: Orbit created the scene under my direction, with the papers and references I found. However, I've written this post by hand manually!

If you have question, I'd be happy to answer it! :)


r/GraphicsProgramming • • 12h ago

Path tracing CAD models in a browser tab: WebGL and WebGPU engines, OIDN denoise, tracing while the camera moves

Post image
0 Upvotes

ive been building an open source cad app that runs in the browser (https://rodeo.build, code at https://github.com/rodeobuild/rodeo) and the rendering side might be interesting to people here.

the live view is three.js with a gbuffer, ssr and ao pass. path tracing is three-gpu-pathtracer with two engines behind one interface, webgl and webgpu. the bvh gets built in a worker with three-mesh-bvh and the denoise is intels oidn running on webgpu. it keeps tracing while you orbit, does tiled 4k stills, and the same renderer runs on a cloud gpu for bigger ones. the scenes come straight out of cad files (walls, solids, imported revit, sketchup, rhino, ifc) so nobody has cleaned up the meshes first.

stuff i learned the hard way:

webgpu wasnt faster. 256 spp at 1600x1000 takes about 14s on both engines on an m3 max.

4k tiles could reset the gpu and lose the context with no error, which gave me black pngs for a while.

the webgpu tracer builds a bvh per mesh and my render meshes are non indexed, so big meshes just vanished until i kept the index the worker made.

its kernels size a texture array at compile time, so if the texture count grows you have to set the whole scene again.

happy to answer questions. has anyone actually got webgpu path tracing meaningfully ahead of webgl2 in a real scene? disclosure: AI used to build this project


r/GraphicsProgramming • • 14h ago

Video Screen-space GI in my OpenGL 4.6 deferred renderer: half-res trace, temporal accumulation and à-trous denoise

0 Upvotes

How do you get stable screen-space GI at half resolution with only a few rays per pixel? Here's the approach I used in my C++ / OpenGL 4.6 deferred renderer, and I'd like feedback on it.

The pipeline:

• Half-res trace: cosine-weighted rays marched in world space against the depth buffer, blue noise + R2 sequence for sampling, firefly clamp

• Temporal: depth-based reprojection with a plane-distance test, variance clipping, and a motion-adaptive blend

• Spatial: 5×5 à-trous filter with variance-guided luminance edge-stopping

• Emissive surfaces feed into the GI through the direct-lighting buffer, so a glowing sphere can light a dark corridor

The video shows each stage: raw trace → temporal → à-trous → final. In the Sponza night shot, the point light inside the cyan sphere is off, so the cyan on the walls comes only from SSGI. Cost is 5–16 ms per frame on an RTX 3050 Laptop GPU, depending on the scene.

Known limits: it's screen-space, so light from off-screen or hidden surfaces is missing. There are no per-object motion vectors yet. Reprojection uses depth + camera matrices, so moving objects rely on the disocclusion test and variance clipping to reject stale history.

Question for people who've shipped SSGI or similar: is it worth moving to per-object motion vectors here, or is the bigger win a better spatial filter (e.g. moving from à-trous towards something like ReBLUR/SVGF-style history-aware filtering)?

AI disclosure: I used an AI assistant (Claude) for debugging, code review, some shader code (e.g. the bloom pass), and writing the README. The renderer design and the SSGI pipeline are my own work.

Source: https://github.com/Saurav280191/OpenGL-SSGI

Video: https://youtu.be/x6MQW1AD2Rc


r/GraphicsProgramming • • 14h ago

Video Wave simulation

53 Upvotes

Long-time lurker here. Watching GTA VI’s water system in action inspired me to write a wave simulation testbed.

I tried FFT but eventually settled on Gerstner waves (see Tessendorf’s paper) as they’re faster to calculate. For ripples I use pre-rendered waves in a number of tileable textures that I offset over time and tessellate in real time.

Foam uses Gerstner crest information. Still lots to do here.

The lighting is pretty straightforward.l: A Fresnel term with reflection from the cubemap, and irradiance calculated from the cubemap pre-integrated as a function of surface normal. Then there is a transmission term based on water depth. I came up with a cool trick to get a light transmission effect for thinner parts of waves. I’ll write this up properly at some point.

The ocean mesh is a geometry clipmap style thing that moves with the camera. Eventually I will LOD this based on camera height from sea level.

Waves and ripples are affected by wind via a wind flow map overlaid over the ocean’s area. This is still rudimentary. Eventually I want to add a current flow map which will form the basis for coastal waves and rivers.

Here’s one wave configuration in three different lighting conditions.

Still lots to do but it’s starting to look pretty cool I thought!

I use Codex to assist with writing code.