Search Unity

Role of the vertex shader in a Post-Effect ?

Discussion in 'Shaders' started by kev42100, Feb 7, 2017.

  1. kev42100

    kev42100

    Joined:
    Apr 17, 2010
    Posts:
    61
    Hi everybody,

    I'm quite confused about the role of the vertex shader for a Post-Effect...
    I understand and know the steps of the Graphics pipeline (vertex shader => rasterization => fragment shader), especially when it's a scene composed of one or many meshes (so vertices in object space to transform in clip space for the vertex shader, etc etc).

    But for a post-process, which vertices are going to be transformed in clip space ?
    If I read the OnRenderImage callback, it's "only" about RenderTexture, so a 2D texture...

    Thanks in advance to clarify my misunderstanding !
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    I think the part you're missing is a post process / image effect takes a render texture as an input which has the contents of the screen already rendered, and outputs a new image written into another render texture that replaces it. However since it's still a normal fragment shader, and a fragment shader needs the rastorization step to know which pixels the fragment shader needs to run on, and the way to do that is using a vertex shader.

    So to further explain, the Blit function is an optimized "render this full screen quad" call. It's still rendering a mesh with four vertices to the screen, and it's still being transformed into clip space before rendering.
     
    mannyhams and kev42100 like this.
  3. kev42100

    kev42100

    Joined:
    Apr 17, 2010
    Posts:
    61
    Thanks a lot bgolus !