c# - With a UV layout, how can I best modify this function to access any part of my texture? -
i've been trying reduce code used in voxel / planar terrain generator, , wrote function in order call every time need add new set of uv's - representing 4 vertex in texture map:
list<vector2> _uvs(list<vector2> uv, int x = 0, int y = 0) { list<vector2> uvreturn = new list<vector2>(); uvreturn = uv; uvreturn.add(new vector2 (0f, 0f) * x); uvreturn.add(new vector2 (0.125f, 0) * y); uvreturn.add(new vector2 (0.125f, 1)* y); uvreturn.add(new vector2 (0f, 1f) * x); return uvreturn; }
however, can't seem identify exact spots write in modifiers, seem throw things off every time. have single row of 128x textures in 1024 file. uv layout moment seems exact, except multiplication. remove , shows first texture, perfectly. ways can improved on? goal used 4 vertex plane.
you can't multiply that, that's different.
uvreturn.add(new vector2 (x * 0.125f, 0f)); uvreturn.add(new vector2 ((x + 1) * 0.125f, 0)); uvreturn.add(new vector2 ((x + 1) * 0.125f, 1)); uvreturn.add(new vector2 (x * 0.125f, 1f));
you need offset uv coordinates - means have add x * widthofone
x coordinates, , y * heightofone
y coordinates. sample shows x-offset, can expand allow y-offsets well.
Comments
Post a Comment