As title says, I’m struggling to find a simple example of a shadergraph and script interaction. What I’ve tried doing myself is adding the property to the shader blackboard and used the reference id
" _shaderPropertyName " etc. and exposed this.
Now after that I’ve created a script referencing this id and unity can’t find it! I’ve attached my script and also the shadergraph to the same game object. I’ve tried to reference the material, shader, renderer and nothing works, It just feels so unituitive to me. The best way for myself to learn is to see. So i’m kindly asking can anybody point me in the right direction or at least show a simple property and script interaction example so i can see what I’m clearly doing wrong.
property ref:
You have to look up the property Reference (not name) in the shader graph. The default HDRP materials have none so how can you know the property names?! Well one way is to click Edit… button next to the shader dropdown in the material inspector - look at the shader code for the Reference names
These should be constants in the HDRP API and be able to be re-used in your own material graphs (new graphs do not even give you starting inputs named as per built in materials! - why?)
non-HDRP has material.mainTexture, material.color etc on materials which works on most shaders as properties are generally constant in name
Setting the property - reference the scene material &
just Material.SetFloat( “_Metallic”, metallic ); or SetTexture/SetColor