Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How does this flow shader work?

Discussion in 'General Graphics' started by TheGameNewBie, Feb 8, 2023.

  1. TheGameNewBie

    TheGameNewBie

    Joined:
    Jul 27, 2017
    Posts:
    92
    So, I'm trying to follow this CatLikeCoding's tutorial. And I got the results similar to the tutorial but I don't understand how it works. I know, the shader adds/subtracts time value from the UV coordinates to make the texture slide, But I don't understand How they came up with these values to make the flow curved?
    Are these values just interpolations across the edges? What If I wanted to make a different 'shape' with the flow?
    Flow Map 03.PNG
    How do these values work? Can anyone explain?
    This is the tutorial - https://catlikecoding.com/unity/tutorials/hex-map/part-8/#7.6
    This is how they make the shader - https://catlikecoding.com/unity/tutorials/hex-map/part-6/#8
     
  2. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    they've added two quads to a triangle, that triangle occupies U1--0 and V.8--.1

    the dimensions are the UVs for the new quads to bend for the estuary

    Code (CSharp):
    1.       estuaries.AddQuadUV2(
    2.             new Vector2(1.5f, 1f), new Vector2(0.7f, 1.15f),
    3.             new Vector2(1f, 0.8f), new Vector2(0.5f, 1.1f)
    4.         );
    5.         estuaries.AddTriangleUV2(
    6.             new Vector2(0.5f, 1.1f),
    7.             new Vector2(1f, 0.8f),
    8.             new Vector2(0f, 0.8f)
    9.         );
    10.         estuaries.AddQuadUV2(
    11.             new Vector2(0.5f, 1.1f), new Vector2(0.3f, 1.15f),
    12.             new Vector2(0f, 0.8f), new Vector2(-0.5f, 1f)
    13.         );

    does this image help?
    upload_2023-2-8_18-34-0.png
     
    Last edited: Feb 9, 2023
  3. TheGameNewBie

    TheGameNewBie

    Joined:
    Jul 27, 2017
    Posts:
    92
    Yes, I get it now.
    The outer vert UVs are 'pulled back' to give the appearance of curved texture.
    I tried visualizing it in Blender and it works.
    Flow Map 08.PNG
    Thank you for the help!