Still going over CG tutorial and on keyframe interpolation. I know it can be done through Unity but for Cg purposes, I want to stick with that for now.
In the main Cg tutorial, for the vertex program, the corresponding target vertex positions are stored in texcoord1. For an original cube and the original cube (the target) rotated/translated somewhere in space, how do I go about passing in the target vertices into texcoord1 so that they match up with the original vertices?
Hi,
I just wish to bump this very interesting question.
texcoord1 normally corresponds to the uv property of the Unity Mesh class. I may be wrong but I think you’ll have a hard time using Unity’s uv to store morph target data. uv and uv2 are arrays of Vector2 in Unity even if texcoord is a float4 in cg. Two floats aren’t enough to store a position or a translation (or maybe they are enough if you’re only planning displacement along the normal). You can always use the tangents array of the mesh class instead though if you need tangents for your shader you’ll have to recalculate them for every frame.
If you have the target position of each vertex (e.g. by importing multiple versions of the same mesh such that corresponding vertices are at the same indices in the vertex array), you can probably just put the 3 coordinates either in the uv and uv2 attributes (eg. x and y in uv and z in uv2) or in the tangent attributes; see here:
for a description how to fill the attribute arrays of a mesh.