Search Unity

Scale UV to fit Texture

Discussion in 'Shaders' started by ant001, Feb 5, 2019.

  1. ant001

    ant001

    Joined:
    Dec 15, 2010
    Posts:
    116
    Hi, Using the Shader Graph I'm looking to create a shader that takes a Texture2d along with a height and width as parameters. I would then like to scale the UVs to fit the final output without distortion (cropping if needed).

    10*20 input texture would scale up from its center to 20*30, then cropped into a square (20*20) result.