Search Unity

Feature Request ShaderGraph - how can I use "nointerpolation"?

Discussion in 'Shader Graph' started by funkyCoty, Jul 22, 2020.

  1. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    I'm trying out HDRP and shadergraph, and attempting to port a very custom shader over to it. I need to use a uv channel without interpolation. Normally I'd just toss a nointerpolation before it when defining the data I need in the shader file; is there a way to do this in Shader Graph? If not, can it PLEASE be added in?
     
  2. tomweiland

    tomweiland

    Joined:
    Dec 15, 2017
    Posts:
    19
    I need this as well, although in my case it's for the vertex color and in URP.

    I'm also trying to port some custom shaders to shader graph in the hopes that it'll help me avoid having to manually update my shaders every time the standard shaders get an update (as I'm piggy backing off the standard lit one). I have converted the first of my shaders to shader graph, and unless I'm forgetting something else, setting the vertex color to not be interpolated is the last thing it needs.

    I've been scouring the web for the past half an hour and can't really find anything—most search results are related to lerping, so that's basically the opposite of what I want.

    For now I've grabbed the shader code generated by shader graph and saved it as its own shader, and then added the nointerpolation qualifier to the color, but this has several glaring problems. Most notably:
    • I now have 2 files for the same shader in my project,
    • any time I change the shader graph, I'm going to have to "re-grab" the generated code and re-add the nointerpolation qualifier,
    • having to replace all the code any time I make a change defeats the purpose of why I wanted to switch to shader graph in the first place (since the goal was to avoid having to manually update things), and
    • the generated shader is throwing warnings (mostly related to things not being truncated properly) which results in a lot of console spam. I guess I could go through and fix those, but there's quite a few of them, and I'd also have to do that every single time I update the shader.

    So far shader graph seems like a nice way to make shaders without the code, and it has definitely come a long way since I looked at it last, but if we don't have a way to control more "advanced" things like interpolation qualifiers, I can't really see myself switching permanently, at least not for my current project.

    If this could be added, that'd be awesome, or in the event that there already is a way of doing it, could we get that solution added to this thread? It's the first search result for the keyphrase unity shader graph "nointerpolation".
     
  3. Shiv2k3

    Shiv2k3

    Joined:
    Jun 30, 2019
    Posts:
    118
    Any updates?
     
  4. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Can't believe this still isn't in. It's such a simple addition.
     
  5. Shiv2k3

    Shiv2k3

    Joined:
    Jun 30, 2019
    Posts:
    118
    I've seen shader graph has a new node on the master stack relating to interpolation but I'm not sure what it is really doing
     
  6. Shiv2k3

    Shiv2k3

    Joined:
    Jun 30, 2019
    Posts:
    118
    Would it be possible to "undo" the interpolation, how does the interpolation happen in the first place?
     
  7. Shiv2k3

    Shiv2k3

    Joined:
    Jun 30, 2019
    Posts:
    118
    It looks like we need to bake the barycentric coordinate into a vertex attribute, then use it to undo the interpolation in the fragment stage.
     
  8. jribijed6

    jribijed6

    Joined:
    Mar 7, 2019
    Posts:
    6
    Yep custom interpolators, but even then, they don't allow you to completely disable interpolation. They're just tools to allow you to cache a bunch of fragment heavy computations into the vertex stage to save on computation costs. Still a shame that this isn't supported by Unity's ShaderGraph. I'm going to try to check if it would be possible to do such a thing with custom HLSL functions but even then there isn't a lot of documentation or anything about them.
     
  9. FredMoreau

    FredMoreau

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    161
    Hi,

    thanks for bringing this up!
    I just added a card on Product Board for you to give more feedback on this.