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).
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.
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?
In looking at the compiled shader - it would appear that it just calls the function (SHADERGRAPH_SAMPLE_SCENE_COLOR), but never actually defines it - which should throw an error, but doesn’t. Super weird.
If you use the “Scene Color” node somewhere in your graph, it’d probably work, but that would be unnecessarily redundant…
I would call this a bug - you can read the depth buffer without any special nodes and any Full Screen Pass Feature can set Color as a requirement so this is a bit odd. But anyway custom function nodes are so poorly documented in terms of what you can do, reading screen buffers from them can save a lot in graph complexity though…
But also the color buffer is half scale and filtered by default. You have to set your URP Asset up - tick “Opaque Texture” and turn off downsampling. What is the cost of this?
If you just add Scene Color and read it in the graph, then pass it into the function you are fine to not setup any color buffer, so
Feels like custom function nodes should do very trivial stuff, yet reading from buffers make for easy full screen filters and simple scene graphs.