I meet a strange question.
After change modles’s mesh.uv,some modles’ texture will be blurred.
code like this:
Vector2[] newUV=mesh.uv;
UVChange(ref newUV);
mesh.uv=newUV;
I meet a strange question.
After change modles’s mesh.uv,some modles’ texture will be blurred.
code like this:
Vector2[] newUV=mesh.uv;
UVChange(ref newUV);
mesh.uv=newUV;
This could be caused by UVchange() assuming that uv(0,0) is a single pixel and not in the centre of 4 pixels. The reason for this oddity is to make working with mipmapped textures easier, if I recall correctly.
You basically have to move each corner of your rect inwards towards the centre such that the uv co-ordinate is at the exact centre of a pixel. I believe the (unoptimised) formula was something like this (note that index will depend on the triangle order/etc):
float pixelSizeX = 1 / texture.width;
uv[0].x += pixelSizeX / 2; // 0,0
uv[1].x += pixelSizeX / 2; // 0,1
uv[2].x -= pixelSizeX / 2; // 1,0
uv[3].x -= pixelSizeX / 2; // 1,1
float pixelSizeX = 1 / texture.height;
uv[0].y += pixelSizeY / 2;
uv[1].y -= pixelSizeY / 2;
uv[2].y += pixelSizeY / 2;
uv[3].y -= pixelSizeY / 2;
If this isn’t the cause, some elaboration on “blurred” and perhaps some more code will help.