Image component(source Image) as _MainTex for shaderGraph

Hello,
total noob question, but is it possible to use Image component’s source image for Shader Graphs Sample Texture 2D?
would like to use the same material for multiple sprites or UI elements but with different textures
do I need to generate HLSL code script and edit it there?
or use different material per object? …multiple instancing? :roll_eyes:

9894093--1428390--Screenshot 2024-06-17 at 15.34.44.png

or what about effects like “UV distortion” which node should it use it? cuz it has to be applied to Sample Texture 2D, where it should be applied without Sample Texture2D ?

If you want to create a Sprite Material, it’s all detailed here in the doc.
If you want to create a UI Material, it works in a very similar fashion.
Just add a Texture2D property to your Shader Graph, name it “MainTex”, then right click → Set as Main Texture.
Whatever Sprite/Texture assigned to your Image component will be fed into your material instance.
Hope this helps.

3 Likes