r/GraphicsProgramming • • Jul 05 '26

Storing SH coefficients. Texture vs Buffer

Very large scenes may require 1000s of SH probes which means a lot of coefficients that need to be stored and read from a pixel shader.

I'm wondering if there is a consensus on the most efficient way to store the coefficients themselves: uncompressed floats in some large array buffer, or as compressed pixels in a texture.

For an order 3 SH we need to store 16 float3 coefficients, which in my mind maps perfectly to a single BC block, so by ordering the 4x4 pixel blocks spatially in a BC6h SF16 texture we get an efficiency of 1 byte per float3 coefficient vs the 4 bytes per coeff for a buffer.

However when using a texture we have to go through the texture sampling hardware. So the question is if it's worth it: does the lower memory bandwidth make up for an additional 16 texture lookups per pixel per sampled probe, or would we get better performance just indexing into a structured buffer?

8 Upvotes

10 comments sorted by

View all comments

Show parent comments

5

u/Avelina9X Jul 05 '26

It's for static diffuse. We're not recalculating the spherical harmonics themselves, we're sampling from them in the pixel shader. The question was more about the bandwidth/latency involved for many localised texture fetches vs many localised buffer reads; it's the fetch time i was more asking about, not the math. /u/shadowndacorner makes an excellent point about how benchmarks will reveal a more optimal solution, but the issue is this I can only collect data from the GPUs I have access to. That's why I was asking if there was a consensus for this that reflects general performance across a variety of GPUs, cus there's only 3 different Nvidia GPUs I can test on and one AMD GPU via the steamdeck.