Search Unity

World Position: calculate in vertex or fragment

Discussion in 'Image Effects' started by bitinn, May 14, 2018.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi all,

    I am seeing 2 different ways of computing pixel world position in shader (for volumetric effects).

    1. Calculate "camera to far plane" vector in vertex shader and pass it to fragment shader, then using depth and camera world position to calculate pixel position.

    2. Calculate the whole thing in fragment shader using uv data (texcoord).

    Are there any pros/cons for these 2 approaches?