- Home /
Find position of pixel that's currently being calculated in shadergraph custom function
I am creating a shader with a custom function that highlights edges on a 2D texture. For my calculations I need to know which pixel is currently being calculated. There are two ways to do this:
- Use shadergraph to input the position on the texture (not in object space) into the custom function.
- Keep a count of how many pixels of the texture have been calculated and then calculate which pixel is the current pixel. This method requires a variable either in the Unity editor or in the custom function that holds it's value across pixels. There is no documentation for interacting with variables in the Unity editor from a custom function. Everything that I have tried in the custom function gets deleted and recreated for each pixel.
I need a solution to either of these problems. Either getting the location on the texture, or holding a static variable.
Cbuffers are out. For whatever reason they get deleted and recreated for each pixel.
Tbuffers are out. They aren't supported by Unity yet.
Your answer
![](https://koobas.hobune.stream/wayback/20220612220442im_/https://answers.unity.com/themes/thub/images/avi.jpg)