I have a surface shader which includes this custom vertex function:
void VertexFunction (inout appdata_full v, out Input o)
{
o.edgeDistance = distance(_Origin.rgb, v.vertex);
}
On one mesh, v.vertex comes in as object-relative (local) coordinates, but on another mesh, it comes in as world-relative (global). I don’t know if this is an issue with the shader or with the mesh.
Anybody seen this before?
Update: I have narrowed it down ever further - apparently global coordinates get used whenever multiple instance of the same mesh share the same material with this shader. However, it only happens with this particular mesh, not other ones. Hmm… weird.
Ok… I guess I figured it out…
So apparently having the sceen view in an orthographic mode was what caused this issue. Still very bizarre that it was only with one particular mesh while others had no issue at all.
Maybe batching mess local positions?
Yeah, sounds like batching is screwing things up.
Neither static nor dynamic batching was enabled. It’s some weird interaction between the perspective of the camera and the shader/mesh combo.
Fortunately the game uses a perspective camera, so that wasn’t a problem… but it’s still very odd…
Very weird problem indeed… I used a shader to animate specific vertices of a plane. When i create multiple instances of that same plane in the scene view, the animation behaves with respect to world coordinates (and not object). On the other hand, if I zoom to only one plane, the animation returns back to normal. Worth to note that when I click on the ‘weird’ plane, it seems that the vertex and color coordinates obey to different coordinate systems…
P.S. Currently working with orthographic. Changing to perspective doesn’t make any difference.