Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hair has no skinning #51

Open
cochrane opened this issue Jun 5, 2015 · 1 comment
Open

Hair has no skinning #51

cochrane opened this issue Jun 5, 2015 · 1 comment

Comments

@cochrane
Copy link
Contributor

cochrane commented Jun 5, 2015

Lara's ponytail in TR4 has gaps instead of being continuous and smooth, because skinning of hair meshes is not yet implemented. (This also applies to TR2 and TR3, but there that was original)

I'm currently working on changes to the skinning code in general (they already work, but broke animated textures again; I'll push them once that's fixed), so I'd like to claim this one. It will probably end up with TR2 and TR3 getting skinning, as well.

@cochrane cochrane self-assigned this Jun 5, 2015
@Lwmte
Copy link

Lwmte commented Jun 5, 2015

Great! Thank you so much for that!!!
I already thought about implementing skinning for TR2/3, and actually made some preparations for it. If you will look into scripts/character/hair.lua file, you'll notice that each hair settings table has v_count field and sub-table named v_index. v_count contains amount of vertices which should be "attached" from Lara's head to first hair mesh, and v_index is a list of corresponding vertex indices.
So, for example, for adult Lara in TR4, you need to check up vertices 40, 38, 37 and 39 (I'm not sure about the order) and correspondingly attach them to first four vertices in hair mesh (0 to 3). Same goes for all other versions.

Both v_count and v_index values are loaded into character hair structure, when you call addCharacterHair script function.

P.S.: Also there is unused hair_vertex_map array in hair structure, it is reserved in case we need hair vertex mappings as well (as I didn't check the order of linked vertices on the "root" hair mesh). In this case, this array should be filled from script in the same manner as head mesh vertex indices array.

cochrane added a commit that referenced this issue Jun 14, 2015
With this change, it is possible to use many more matrices, which will
be relevant for hair later (#51). By keeping the weights fixed at 0.5,
we can avoid the need for another vertex attribute. Note that in a more
complex scenario, we would probably need two.

Sadly specifying an ivec2 input isn’t possible in vanilla OpenGL 2.0,
which remains the target, so we’re doing this weird vec2 cast to int
dance here.

Fun fact that I realized while doing this: There is no actual need to
keep the weights normalized; removing the 0.5s in that shader works
just as well - as would any other number > 0. This actually makes sense
if you think about it for a few seconds (hint: How do homogenous
coordinates work again?), but I’m currently reluctant to make use of
that because it is confusing.

Also removed shaders from the copy-to-bundle phase of the Mac build,
because they remain in the OpenTomb folder.
cochrane added a commit that referenced this issue Jun 14, 2015
This is the penultimate step for #51. The hair is as smooth as anyone
could want it to be, in any TR game (except TR1 obviously). The only
thing missing is the area between the hair and the head, which is very
noticeable in TR4 (especially the tutorial level).
@stohrendorf stohrendorf modified the milestones: TR4, TR2 Jul 1, 2015
@cochrane cochrane removed their assignment Aug 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants