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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Question Triplanar map a generated noise.

Discussion in 'Shader Graph' started by Xform, Feb 2, 2021.

  1. Xform

    Xform

    Joined:
    Jan 28, 2016
    Posts:
    5
    Hi,

    I want to connect a simple noise to the triplanar node but cant figure out how to convert it so I can connect them. Is it eve possible?


    upload_2021-2-2_16-53-22.png
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    This is not possible. Triplanar node requires texture, so if you want to use noise as albedo you must create texture asset with such a noise and then plug it to Triplanar node. This is the fast/easy way, however there is other solution.
    You can create custom triplanar and it is quite easy, even shader graph docs described example output of Triplanar node here. Just recreate this code as subgraph, and change texture input to anything you want.
     
  3. Xform

    Xform

    Joined:
    Jan 28, 2016
    Posts:
    5
    Thanks for the reply, really appreciate it! The link you sent didnt help me that much, havent used the custom node and dont know how to code shaders. BUT I found this tutorial, which was very help full and got me all the way.
     
  4. Chipboard

    Chipboard

    Joined:
    Aug 26, 2017
    Posts:
    4
    Qriva was right, you can recreate it as subgraph. Here is the code block, just hook a subgraph up to it and use it:



    void Triplanar_float(float3 Position, float3 Normal, float Tile, float Blend, out float2 uv)
    {
    float3 Node_UV = Position * Tile;
    float3 Node_Blend = pow(abs(Normal), Blend);
    Node_Blend /= dot(Node_Blend, 1.0);
    float2 Node_X = Node_UV.zy;
    float2 Node_Y = Node_UV.xz;
    float2 Node_Z = Node_UV.xy;
    uv = Node_X * Node_Blend.x + Node_Y * Node_Blend.y + Node_Z * Node_Blend.z;
    }


    Files attached in a zip if you just want to download it instead, includes the .cginc and the .shadergraph, just drop them into your project and search for the Triplanar UV node

    Set Blend to 150 for best results (in my case).
     

    Attached Files:

    Sameer1472 likes this.