Shader graph gets detached from mesh if I move the mesh

Hi,

I’m a newbie in shader graph.
So, I have a 3d model (imported from cinema 4d), then I added a shader graph material onto it.
When I move the 3d model, the shader graph portion gets detached from the mesh (mesh and shader graph are in 2 different positions).
Is there a way to fix it?

Do you mean (for example) texture mapping doesn’t stay with the object while you drag it around? If so, that would mean it’s using world-space coordinates somewhere - you’d have to either modify the related node(s) in the graph to use object space instead, use Transform nodes (to convert from whichever space it’s using to object space where needed), or just try using a different shader. Unless you mean something else… in which case, please clarify :slight_smile:

Hi, yes. That’s what I meant.
I have changed it to object space and it works!
But now if I change the model size, the shader follows the location but not the size of the model.
is there another node that I need to add?

Do you mean model size as in the transform’s scale? If that’s the case, depending on the shader you might try multiplying or dividing by the scale output of a Scene->Object node. It’s hard to say without seeing the graph. However it’s worth mentioning that if you need to consider object scale, that’s probably because something is still working with world space coordinates.

If you mean size as in a different mesh with different bounds, that gets more complicated based on exactly what the problem is. For example if the shader is expecting all vertices to have positions with a Y component between 0 and 1, it wouldn’t work properly for a mesh having vertices outside that range. You might need to do something like use a Multiply node to scale vertex position and/or Add so they all fall within expected range.

I have tried to change all UV value to float and space value to object.
But still the shader doesn’t follow the transform’s scale value of the model.

6551320--741520--Screen Shot 2020-11-23 at 13.39.22.jpg
6551320--741526--Screen Shot 2020-11-23 at 13.42.00.jpg

You can multiply vertex position by the transform’s scale using the Scene->Object node:
6551338--741532--sg_multiply_by_object_scale.jpg

Ah, I see!
Ok. It works now!
Thank you so much for the pointer! :slight_smile: