sugi-cho/Animation-Texture-Baker

Why vid + 0.5

Closed this issue · 1 comments

Hello. thanks for your code.
I read your code and it works perfectly.
now. I don’t understand a bit.

float x = (vid + 0.5) * ts.x;

vid(SV_VertexID) is the index of vertex. it's 0, 1, 2, 3 .... (vertexCount - 1)
ts.x is 1 / textureWidth

my question:
why vid + 0.5?

Please give me a hint. thanks.

hi, good question.

using texture.filterMode = Bilinear for interpolation of each frames.
The y direction may be interpolated, but the x direction needs to be the center of the texel.

uv.x = (vid + 0.5) / textureWidth
is center value of texel, which is position of vertex.