Downsampling for fragment shader

This is what I want:

  • GrabPass
  • Resize GrabPass to a smaller size
  • Do stuff with fragment shader with the resized GrabPass
  • Size the result of fragment shader back to original size as the result

How do I make the fragment shader run just for the resized GrabPass and not the original image?

Sorry if this question is too basic, I’m still learning. I’d like to understand how fragment shaders work.

My assumption is that I’d have to do it in multiple passes, so that each pass controls what is sent to the next pass and this is the only way to control how many times a fragment shader will run. Is this correct?

Thanks!

You do this by not using a grab pass. You’ll need to handle this manually using render textures and likely command buffers.

See the first example here:

Thank you, that worked perfectly.

This works but command buffers can only execute at certain points. Grab pass is highly useful because of it’s ability to be injected right before a shader pass. I guess we lose this with the new pipelines…

It’s unlikely Unity will provide any further support to grab passes. Going forward, the HDRP and LWRP don’t even support grab passes at all.