Search Unity

Help Wanted Is there a way to modify the final color output of a pixel in a PBR shader graph?

Discussion in 'Shader Graph' started by JohnKP-Mindshow, Jan 14, 2020.

  1. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    50
    For the effect I'm trying to making via ShaderGraph, I want to modify the final pixel color of a PBR shader after the light/shadow pass to tint it by a color value. It seems like a relatively simple thing, but I can only seem to modify the color before the light/shadow pass (albedo value).


    It is pretty simple operation I've done many times via code, even further verified by making a copy of their generated code from the ShaderGraph and reordering some of the lines.

    I would use post processing for this if custom post processing was supported in URP/HDRP, but it still should be doable via shadergraph without compiling out the code and making a new shader with the code...

    Is there something simple I'm overlooking or is this functionality not possible with shadergraph and the current render pipelines without making custom edits to the packages?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,112
    Nope. There's a lot of those handy Surface Shader tools still missing from Shader Graph.
     
  3. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,349
    What would be the shortest path to achieving the goal of having this? Is there a way to get our grubby little hands on the bits that comprise the PBR master node and modify it to be a subgraph or something like that, adding an output? Or is there simply no alternative but to fully flesh out all the PBR features, node by node, thus reinventing the entire wheel?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,112
    I'm not even sure if it's possible to recreate all of the features of the PBR Master Node using nodes alone. There's features that are required that the node graph simply doesn't support. Currently the easiest solution is to setup your shader in Shader Graph as you want it, minus anything you can't do (like a final color modifier), then right click on the master node and select "Show Generated Code", and paste that into a new .shader file and hand modify that shader to add whatever else you're missing.
     
  5. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,349
    I was afraid you were going to say something like that. :( Thanks for the suggestion though! That's probably what I'll wind up doing.

    It seems to me like a better architecture would have been to have a final output color node that PBR, Unlit, and whatever else, could feed into, instead of having to have a special magical "master node" that does a ton of stuff after all your custom stuff is done. There are lots of situations where you'd want to modify the final output of the lighting. For example, in my case I have a custom fog effect that needs to layer on top of the final output of PBR, not simply input into it.
     
  6. JohnKP-Mindshow

    JohnKP-Mindshow

    Joined:
    Oct 25, 2017
    Posts:
    50

    Yeah I'm running into the same issue. Can't port my custom fog effect because I can't modify the final color output after lighting/shadows. I would compile it out and make edits by hand, but then I would have to remake those edits or try to merge them with the newly compiled version of the shader every time its tweaked by someone.

    Also having the issue that I want one of my shader graph nodes to only run during the lighting pass and not run during the shadow pass. However, it seems like shader graph has given developers less control in that regard compared to the legacy system they plan the deprecate.
     
  7. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,349
unityunity