Hi,
I’m working on a simple vertex shader: I’d like to move all points to one direction ( world coordinates ) of a known value ( the complete version is not so pointless )
Everything is working fine in editor mode while most of the triangles blink when I launch it on a Galaxy S phone ( and rarely on iOS, too ).
I suppose it’s something about numbers precision transforming the vector from world coordinates with _Object2World matrix.
If I remove the multiplication the blink disappear.
I definitely need this shader… any idea why this is happening ? Any workaround suggestion ?
A way without using _Object2World multiplication, maybe ?
As far as I know, the vertex function of a surface shader should provide the vertex coordinates in object coordinates, i.e. multiplying with _Object2World (which transforms the vector to world coordinates) doesn’t make much sense. (With “v.vertex.xyz += vec.xyz” you are adding world coordinates to object coordinates.)
If you want to add a vector in world coordinates, you have to transform the vector to object coordinates before adding it to v.vertex, or you transform v.vertex to world coordinates, add the vector in world coordinates and transform the result back to object coordinates.
EDIT: Oh, and the precision of _Object2World is probably no issue here.
Mystery solved, I used vec = mul( _World2Object, vec ); instead of mul( vec, _Object2World ); obtaining similar results ( but it’s more correct and logical, right ).
The big problem was that vec.w = 0; was missing: probably other devices set it to 0 as default. GalaxyS doesn’t do it.