Search Unity

Question Compatibility between Shader Graph nodes and Ray Tracing

Discussion in 'Shader Graph' started by jsr2k1, Jun 20, 2022.

  1. jsr2k1

    jsr2k1

    Joined:
    Aug 11, 2010
    Posts:
    118
    Hello everyone,

    I need to create some shaders compliant with Ray Tracing using Shader Graph, but I've found some incompatible nodes, for instance, the Rectangle node:

    example.PNG

    Code (CSharp):
    1. void Unity_Rectangle_float(float2 UV, float Width, float Height, out float Out)
    2. {
    3.     float2 d = abs(UV * 2 - 1) - float2(Width, Height);
    4.     d = 1 - d / fwidth(d);
    5.     Out = saturate(min(d.x, d.y));
    6. }
    Using this node with a Volume with any Ray Tracing feature enabled causes this error:

    error.PNG

    So, my questions are:

    1.- Why is this node not compatible with Ray Tracing?
    2.- Is there any documentation where we can see if a node is compatible or not?
    3.- Is there any rule to know if some node is compatible with Ray Tracing?

    Unity v.2020.3.34f1

    Thanks.
     
    Last edited: Jun 20, 2022
  2. jsr2k1

    jsr2k1

    Joined:
    Aug 11, 2010
    Posts:
    118
    According to documentation, the incompatible nodes are:
    • DDX, DDY and DDXY nodes.
    • All the nodes under Inputs > Geometry (Position, View Direction, Normal, etc.) in View Space mode.
    • Checkerboard node.
    But, the Rectangle node is under Procedural > Shape
     
  3. jsr2k1

    jsr2k1

    Joined:
    Aug 11, 2010
    Posts:
    118
    Finally, I did a custom function node replacing the Rectangle node and Ray Tracing works properly with standard Unity planes, but it doesn't work with my procedurally generated meshes. Maybe, it is necessary to add some attributes to the meshes during creation, for instance, tangents or something similar.

    I've done a room test with 6 planes and SSGI enabled with Ray Tracing, everything is correct, but when I use my generated meshes then SSGI doesn't work.

    Any ideas?
     
  4. jsr2k1

    jsr2k1

    Joined:
    Aug 11, 2010
    Posts:
    118
    mesh.RecalculateTangents()

    that's it!