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 Very confused on UVs in Shader Graphs

Discussion in 'Shader Graph' started by TGAnole, Feb 25, 2023.

  1. TGAnole

    TGAnole

    Joined:
    Sep 5, 2021
    Posts:
    1
    I'm new to using Shader Graphs (and Shaders in general), so sorry if this is an obvious nooby question.

    I can't figure out for the life of me how to do what I want. My end goal is to create a shader that I can put on 2D boxes that will display the outline of the box with a transparent center. (Yes I could probably do this easier with LineRenderer but I'd like to do it with a shader.) I've narrowed my objective down to three seemingly simple steps:

    1) Have mainTex and get its alpha
    2) Have a second mainTex, shrink the copy and get its alpha.
    3) Subtract the copy's alpha values from mainTex's alpha and input that into the Fragment node's alpha.


    I'm having issues on #2. No matter what I try, when I cannot change the size of a texture's alpha.

    So essentially, my issue is that I want to take a Texture (mainTex) and decrease its scale. I would imagine that being simple, but I really can't figure it out. From what I've seen, I plug mainTex into the Sample Texture 2D node's texture input. Then input into a Tiling and Offset node how I want to modify the UV, and then take that output and put it into the UV of the Sample Texture 2D. Then I take the alphas, subtract them, and put that result into Fragment.

    Its probably something obvious that I'm not understanding, what am I doing wrong? Pictures of everything related below, in case its just a small problem with a setting or something. (No matter what I put into Tiling and Offset, nothing changes. mainTex is just a 16x16 white cube. One thing I saw while looking stuff up was the Wrap Mode clamp vs repeat on the texture, but I've tried both and neither do any difference. The "Use Tiling and Offset" option also seemed like it might be the issue, but turning it on and off also makes no difference.) I'm really at a lost and probably misunderstanding something fundamental, so thank you for any potential help!

    shaderGraph.png shaderGraph.png shaderGraph.png
    shaderGraph.png