Search Unity

Distortion Effect in Vertex Shader

Discussion in 'Shaders' started by Vegeta1996, Sep 19, 2019.

  1. Vegeta1996

    Vegeta1996

    Joined:
    Aug 20, 2019
    Posts:
    7
    Hello everyone,

    I am new to shader programming and currently trying to implement a fisheye effect for 3D objects using the vertex shader. I want to move insider of a scene with my main camera and have the objects I am looking at be distorted in a fisheye kind of way.

    Does anyone have any experience with 3D distortion shading and maybe link me to existing solutions?
     
  2. tmcthee

    tmcthee

    Joined:
    Mar 8, 2013
    Posts:
    119
    I think this might be quite difficult to do well at the vertex level because the curved effect of a fisheye lens will be limited by the number of vertices in your models. So you may find edges of particularity low poly models, like walls, won't seem to curve at all and will intersect other models in the scene as you distort their vertices.
    Have you considered a post effect?
    This might help

     
    Last edited: Sep 19, 2019
  3. Vegeta1996

    Vegeta1996

    Joined:
    Aug 20, 2019
    Posts:
    7
    Thank you for you reply,

    I was considering post effect, but since I want to use it in an AR application later on, I think that wouldn't work very well.

    For the issue which you brought up, I am using a tessellation shader so that I can get high levels of detail even in very flat surfaces like a wall.

    So I am basically working with a surface shader, which has a tessellation shader in it which increases the number of vertices of my object when I move closer to it, and a vertex shader which (hopefully) does the fisheye distortion part.