Can I send the GameObject.transform.location vector to a shader so that the shader can take the position of the GameObject currently being rendered into consideration? How would I do that? Thanks.
Yes, you can send values,like vector to the shader https://docs.unity3d.com/ScriptReference/Material.SetVector.html setfloat has basic example, https://docs.unity3d.com/ScriptReference/Material.SetFloat.html
So variables set that way are bound to the material? I'm not sure I understand, because I have several GameObjects using the same material, but I need the shader to take the position of the GameObject it's currently rendering into consideration. Can I set a float for one GameObject and then change it before the next GameObject is rendered? Can I do that using SetFloat or is there another way?
Do you have lots of gameobjects, that couldn't use separate materials for them? What kind of effect you actually want to do?
I want to offset a texture lookup index based on the current GameObject's position. Specifically I have multiple terrains tiled together, and using the default terrain shader there will be visible seams between the terrains. I thought I might be able to fix this by using an offset value for each terrain based on its position.
You have gameobject vertex (world) positions in shader, and then could do something based on that. (no need to send any values to the shader) But no idea how to use that for fixing the seams.. Are you using this, https://docs.unity3d.com/ScriptReference/Terrain.SetNeighbors.html
Yes I'm using SetNeighbours. As it says it only helps for the LOD. I've already modified the terrain shaders to use the World UV positions instead, and that works but it doesn't let me control the scale of each individual SplatPrototype anymore, that's why I want another solution.
As long as the gameobject in question is the same position as the renderer component then the shader already has this information, assuming it's not being batched (and I don't think Terrain gets batched?). Either way float3(unity_ObjectToWorld[0].w, unity_ObjectToWorld[1].w, unity_ObjectToWorld[2].w) will give you the world position of the object.