Search Unity

Question Texture Overlay ontop of a Sprite Sheet

Discussion in 'Shader Graph' started by cowfish13, Jul 21, 2021.

  1. cowfish13

    cowfish13

    Joined:
    Jul 21, 2021
    Posts:
    2
    Hello I have a novice question that I'm having difficulty finding the solution to; I'm not sure what to look up on search engines to find a solution that already exist.

    So I have a simple shader, to overlay a sprite on-top of another sprite via LERP; the texture originating from a sprite sheet. Here I have a "1" texture with alpha overlapping the texture.
    visual shader before.png
    I am aware the overlay sprite applies directly to the whole sprite sheets, rather than the individual sprites of the sprite sheets.
    This is what the whole sprite sheet looks like when applied as the sprite texture:
    Screenshot 2021-07-16 175904.png
    And this is what what one of the individual sprites of the sprite sheet.
    shaderone.png

    So every guide has told me that I should use a position node set to Object to modify the UV value in order to only affect the overlay via the world object:
    visual shader.png

    However, the sprite I'm overlaying is extremely small to the world object size and results in this:
    shadersmall.png
    You can barely see it, but the "1" is actually visible in the center, albeit extremely tiny. I'm looking for the overlayed sprite to scale to the edges of the object, giving me a fully sized "1".

    Thanks.
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
  3. cowfish13

    cowfish13

    Joined:
    Jul 21, 2021
    Posts:
    2
    Yes, this is what I needed but I'm not sure if I'm doing it in an extremely convoluted way. What I'm doing here is I'm using the object Scale*Width&Height data as reference for how big the object UV should be. I move the UV to the bottom left corner and then multiply it by the appropriate scale. I realize that multiplying a UV and tiling do the exact same thing; in the end it's just semantics.

    Screenshot 2021-07-23 112214.png
    Screenshot 2021-07-23 114511.png
    This is the intended result in the end that I get from the graph.
    Screenshot 2021-07-23 114555.png
    I definitely got what I need, but in the end, this solution doesn't seem as snappy for what I imagine would be able to achieve using Shader Graph. If there's a cleaner way to do this, I would love to know.