Hi all!
I'm working on getting a script together in 3ds MAX that bakes local space positions into vertex colors for easy blendshapes in Unity. This is all inspired by the Naughty Dog talk which describes similar processes you can find here:
http://www.gdcvault.com/play/1024103/Technical-Art-Techniques-of-NaughtyThings have been going alright in my adventure so far but I'm struggling to cleanly store the vertex positions in colors in MAX specifically. In Unity I can quickly colorize them in C# because I'm pretty competent in Unity's libraries but I'm really struggling to reproduce something so clean in Max Creation Graph.
Here's the Unity shader in action on a capsule I colorized then skewed in C# code.
My current graph in 3ds MAX looks like this:
I'm using an empty input and the Trimesh has its colors remapped with the function ColorVertices(mesh, vertexToColorFunc). This produces a messy output I've also seen using this script:
http://www.scriptspot.com/3ds-max/scripts/position-to-vertexcolor Which I'm pretty sure looks messy because its remapping the mesh id channel to the vertex color.
Result
Here's what a messy colored object looks like in Unity with the same shader as the above capsule.
How can I fix this so that the colors turn out as cleanly as they do in my Unity scene? + Has anyone attempted to bake local positions to colors a different way with success in the past?
Thanks for reading! :~)
I'm also curious if anyone has attempted something like this: https://vimeo.com/207832662 that moves from 3ds MAX to Unity.
Replies
Your MCG and script from ScriptSpot technically both work. But the vertex colors needs to be normalized into 0-1 UV space. In the screenshot attached the big teapot is like yours, and i used the script from ScriptSpot to generate the colors. For the little teapot, I fit the size into a 1x1x1 box, Reset Xforms, and then ran the script. Notice it looks smoother like your Unity capsule.
It's getting there! I think negative values are getting cut off right now I'm not sure why. This is a sphere.
I am not sure if the Colors are correct for use in Unity, but the normalize give you some options to handle that i think.
But still you'd need to scale in Unity to get the desired size no ? Because here it's 1*1*1 right ?
-Either you scale the object in max/unity to get the correct bounding box ratio at the end.
-Or in Max you scale your vertex color data so it fits in a 1*1*1 cube while keeping proportions.
I dont own max 2017 but you can access vertex color through unwrap.
I dont think you can edit the bounding box size to be cubic, it just always fits your mesh so here's a trick :
-Create a cube that fits your teapot.
-Convert to poly
-Attach teapot and cube.
-Apply an unwrap.
-In the unwrap, switch to vertex Color Channel -> abandon
(new channel creates normalized data of your mesh by default, pivot is at 0.5 0.5 0.5)
-Collapse
-Delete the cube faces.
Should be good then.
Also if i only scale scale, object i guess i have to invert ratio. You can uncomment scale object to test it. What are roughly the scale values you have to put in unity so the teapot looks ok ?
@Noors Thank you so much for the script!! I wasn't totally sure how to get the rest of the Max script working when I uncommented the code I got an error:
Here's a lil editor snippet from current test objects. Note that the teapot still shrinks even with the same bounding box as its vertex colors. The Torus Knot seems to be behaving a little bit nicer but that difference still could have something to do with my magic scale number. :'~)
https://github.com/apras/Unity-VertexTextureFetchAnimation