Single Pass Downsampler #15
Replies: 1 comment 1 reply
-
This is exactly why niagara goes with a two-step approach, where you first reduce the depth buffer to the previous power of two (during this you can use - like niagara does - a min filter operation which makes reduction conservative), and then generates a mip pyramid. You could generate a mip pyramid using single-pass downsampling, in which case you'd have two passes - which is still fine, the reason why single-pass downsampling can be useful is that it reduces the overhead of smaller downsample passes. Of course this isn't guaranteed to be efficient. For example, if the input resolution is 1025x1025, the first downsample pass goes to 1024x1024 which is a bit of a waste. If that's a concern, you could go down to the next power of two in the first pass, which requires doing four "bilinear" (min filter) samples instead of just one in the first pass to still result in a conservative downsample. Now, if you really want to work with the non-power-of-two resolutions, you need to be careful wrt what the mip data actually means. What you'd want is that for any pixel at any given level of detail, if it's a pixel in the middle, it's a conservative reduction of a 2^K * 2^K block from the original image; if it's an edge pixel on the right or bottom edges, it's a conservative reduction of a slightly larger block that extends all the way to the right or top of the edge in the larger image. To get there, when you generate mip levels, every next mip level might need to reduce more than a 2x2 block - specifically, the last row & column in each mip level would need to reduce anywhere between 2x2 and 3x3 (e.g. if the source image is 5x5, the next mip is 2x2; the top left pixel would be a reduction of a 2x2 top left corner block from the original image; the bottom right pixel would be a reduction of a 3x3 bottom right corner block in the original image. With SPD technique this might be rather painful to implement efficiently, I haven't attempted this. This is why I feel like from the practical perspective it might be simpler to do what niagara does and round to the power of two, even though it can sometimes lead to slightly less efficient culling for odd input sizes. |
Beta Was this translation helpful? Give feedback.
-
Hello Zeux !
I'm approaching the end of the niagara stream and I was thinking about using a single pass downsampler to generate the depth pyramid. I already wrote something heavily inspired by AMD's SPD ( https://gpuopen.com/fidelityfx-spd/ ). But there's one problem, form my understanding I need to generate power of 2 resolution mips. My current solution only works with resolutions that are original/2
( My window res is 960x600 => mip0: 480x300 ). If I try to use FloorPow2 => 512x512 then the mips aren't completely filled and mip LAST will be 0/empty/maxDepth. I've read that it's "ok" to not have a pow2 res mip chain , IF you cull small primitives.
But I still don't understand the part about "conservative". Is there something more about this business ?
Thanks in advance !
Beta Was this translation helpful? Give feedback.
All reactions