Texture sampler how to output rgb values

Hi creators !

Is it possible to output rgb values from texture sampler ?
I want to sample camera texture and check rgb values to know for example if it’s a range of green values.

Thanks for you answers.

All the best !

It’s not possible to output scalar values from a texture sampler. You can’t convert shader signals to another type, but you might be able to find a solution with shader logic. What are you trying to do?

Thanks Josh !
I want to sample the color of the screen (camera extraction) by screen tap and verify if rgb value is between a range and do something or if it’s outside doing another thing.
For example sample the green color of the grass in a garden and if it’s outside a range of green values trigger something.
I don’t know if I am very clear… :sweat_smile:
Thank you again for your reply.

Ah, yeah you would need to figure out how to do this with shaders somehow. It’s very specific to your particular setup, so maybe it won’t work. The idea is to take the distance to the target color and use that to control alpha. You can use step to make it act like a switch.

For animating the changes, you can use delay frames to slowly build up the texture so it acts like a fade effect.

1 Like

Thank you Josh! I’ll look at the shaders. However, I’m not going to need to animate any colorimetric changes. I just want to sample the green color of the grass in the garden to determine if it is an acceptable “green” and trigger a message like you are a “good” or “bad” gardener :sweat_smile:

ahhh great idea. i used to have a similar idea about using color to trigger something but like josh said, unfortunately we can’t use shader signal to trigger logic patch. with that said, maybe the approach will be different instead of using visibility button using boolean, you can try to do it using shader logic like josh mentioned. By using step to control the alpha of both good and bad gardener. so when one is white, the other is black, meaning only one will be visible.

or maybe you can make a lut, with specific color to sample all the green only, average them out, and compare it with your target using step shader logic.

1 Like

Hi Adi_Satrio!
Thanks for the different suggestions, I’m going to go explore this!