Search code examples
rustwgpu-rs

How to render at a lower resolution in wgpu?


I am using wgpu and I can't find anywhere how to render at a given resolution. I have tried with setting the Surface width and height but that didn't seem to do anything. I also couldn't find any methods in the render or surface structs I am using either.


Solution

  • If you want to render at a lower resolution than the Surface you're displaying to then you have to

    1. create a texture of the size you want,
    2. render to that (in exactly the same way you'd render to the surface), and
    3. in a separate render pass, render that texture to the surface by putting it on a triangle that covers the entire screen.

    A fair bit of setup, but the second render pass is also a useful opportunity to do things like tone mapping and other screen-space effects.