Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Shader Graph remap parts of UV map

Discussion in 'Shader Graph' started by L2GX, Sep 17, 2019.

  1. L2GX

    L2GX

    Joined:
    Aug 19, 2016
    Posts:
    42
    I'd like to remap parts of a UV map, e.g. selecting an upper left quadrant and remapping it to the lower right, driven by properties.
    I can see complicated ways of ding this with masks, but is there a simple way? Can/should I program my own node?
    I'm currently targeting ios/mobile.
    Would it make sense to do so in Shader Graph rather than just writing a custom shader?
     
  2. L2GX

    L2GX

    Joined:
    Aug 19, 2016
    Posts:
    42
    here's what I managed in Shader Graph so far which is basically masking an offset enlarged texture overlaying the original texture. Not really what I'm looking for as it's easier to do in code!
     

    Attached Files:

    deus0 likes this.
  3. LandonTownsend

    LandonTownsend

    Unity Technologies

    Joined:
    Aug 21, 2019
    Posts:
    35
    I'd recommend learning to use the Custom Function node (available in 2019.2 and above); if you find something that you'd prefer to do with code, then using a custom function node is usually a good way of doing that. If you choose the type as "string" then you can write shader code right in the node (or write it in the text editor of your choice and paste it in the node).
    If the version of Unity you're using is too old for the custom function node, you could make that shadergraph a bit cheaper by using a comparison node and a branch on the rectangle:
    upload_2019-9-17_15-43-44.png
     
    deus0 and L2GX like this.