Search Unity

  1. We are looking for feedback on our SRP Rendering APIs through this Survey.
    Dismiss Notice
  2. Unity 2020.2 has been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Using SAMPLE_SCENE_COLOR in custom function

Discussion in 'Shader Graph' started by zilhk_, Nov 22, 2020.

  1. zilhk_

    zilhk_

    Joined:
    Oct 14, 2015
    Posts:
    2
    Hi there,

    I'm trying to use Scene Color in a custom function but all I get is a grey output. My function just calls
    SHADERGRAPH_SAMPLE_SCENE_COLOR() and returns the color (see screenshot below). My goal is to code a shader graph node that does a screen blur.

    If I replace my custom function by the Scene Color node then it works perfectly so I assume my setup is correct (transparent surface + generate opaque texture).

    Any help is welcome, thanks!

    (Unity 2019.4 - latest packages)

    upload_2020-11-22_17-58-29.png
     
    Last edited: Nov 23, 2020
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,339
    Hi,
    I'm not sure if I follow your logic - couldn't you use Custom Function node and input the necessary things like UV, sampler state and a Texture2D, and then create your blur by writing necessary code in a file or that Body box. That's how I've done a blur node.
     
    zilhk_ likes this.
  3. zilhk_

    zilhk_

    Joined:
    Oct 14, 2015
    Posts:
    2
    Hi Olmi,
    I didn't realized you could access the opaque texture directly, which you can with a reference to _CameraOpaqueTexture (see screenshot below). Using that texture I was able to do the blur in HLSL so thanks a bunch!

    Just out of curiosity, shouldn't the call to SHADERGRAPH_SAMPLE_SCENE_COLOR() have worked though? May be I need to add some #define the HLSL script to be able to use it or something like that?

    upload_2020-11-23_9-53-38.png
     
unityunity