Search Unity

Chaining two shaders on a textured plane

Discussion in 'Shaders' started by bwrsandman_vrv, Nov 30, 2015.

  1. bwrsandman_vrv

    bwrsandman_vrv

    Joined:
    Sep 10, 2015
    Posts:
    2
    Is there a way to apply two shaders one after the other and still retain the same UV space?

    The problem I am facing is that I have a texture2d that I can retrieve from a camera in raw form, it needs to firstly have bayer demosaic applied to the texture, then have the lens distortion fixed.

    Vertex Shader 1 -> Fragment Shader 1 -> Vertex Shader 2 -> Fragment Shader 2 -> Render on plane.

    I cannot fix the distortion without first having applied my demosaic shader. I can run a second pass of the texture. The issue with that solution is that the output of the demosaic shader is a texture in screen space and the UV mapping of my output is no longer relative to the plane's UV which I need for my lens' distortion map.

    I've tried using render-to-texture in a native graphics plugin, but I am also running into issues there.

    Maybe I am missing an angle here. Ideally, I'd like to avoid adding a camera to the equation.