Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Downsampling for fragment shader

Discussion in 'Shaders' started by Reshima, May 27, 2017.

  1. Reshima

    Reshima

    Joined:
    Dec 10, 2012
    Posts:
    51
    This is what I want:

    1. GrabPass
    2. Resize GrabPass to a smaller size
    3. Do stuff with fragment shader with the resized GrabPass
    4. 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!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
  3. Reshima

    Reshima

    Joined:
    Dec 10, 2012
    Posts:
    51
    Thank you, that worked perfectly.
     
  4. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    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...
     
    Last edited: Aug 22, 2018
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    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.