Playmaker Forum

PlayMaker Feedback => Action Requests => Topic started by: escpodgames on April 14, 2013, 09:35:44 PM

Title: Mesh - Get/Set vertex color
Post by: escpodgames on April 14, 2013, 09:35:44 PM
Hi,

What I'm wanting to do (let me know if this is crazy) is get all the vertex colors of a mesh and store them in an array or hash table (using arraymaker), reapply these to a mesh at runtime. I'm using vertex colors to color my models and want to have variations of each model - for example (Blue hat, pink hat, yellow hat)

Would need a Get/Set vertex color action and for performance reasons, a use colors32 option would be awesome (This will avoid byte-to-float conversions in colors, as well as use less temporary memory)

Cheers
Andrew
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on April 14, 2013, 10:15:18 PM
Hi,

Yes, that would not be very effective I fear.

instead of working from the result of your color changes, you should save the color as you edit them, and store that, and then repply them colors.

I guess you are simply setting the color of the shaders right?


bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on April 14, 2013, 10:30:16 PM
Hi Jean,

This is shader independent as I am yet to find a shader that does exactly what I want (even tried writing my own).
Changing the shader color (depending on the shader) does nothing or overwrites all vertex colors with a solid color.

I'll keep trying to write my crazy shader :) OR have multipe versions of the same mesh and take the file size hit.
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on April 14, 2013, 10:35:15 PM
Hi,

 can you give me a example of how you do it? I am not sure I follow the way you are setting vertex color.

bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on April 14, 2013, 10:47:42 PM
So in the below image I've made a very simpe example. A poly plane split into 4, each of those polys have vertex color applied. So the models are exactly the same but I've painted the colors (in an external app).
Ideally it would be great to be able to store this color data and apply it to a mesh when the user changes the color of a mesh (so it would just need to set the colors, no lerping) I am making a game for iOS so I realise this could be very intensive and not an option.

If it's possible I would use it for skinned characters and thus don't really want multiple meshes as I would also have to skin each one (more file size)
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on April 14, 2013, 10:57:38 PM
Hi,

 ok, I see now your workflow, it's done outside unity to begin with,

 ok, that make sense now. It's on my todos for arrayMaker,

bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on April 14, 2013, 10:59:24 PM
Awesome!!! ;D
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on April 14, 2013, 11:01:27 PM
Hi,

 Can you send me a fbx of that screenshot you did? so I have some real data to work from? I would appreciate and it would guarante I fit your purpose as well.

Bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on April 15, 2013, 12:07:59 AM
Sure thing! Attached to this post is an fbx (colors are different as I quickly remade it)
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on April 15, 2013, 12:14:00 AM
hi,

 it's all grey...

Bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on April 15, 2013, 01:06:01 AM
Just setup the Unity scene for you, I assume you didn't have the right shaders.

See attached
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on April 15, 2013, 02:47:07 AM
Hi,
 
Much better, thanks,

Bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on April 23, 2013, 11:30:37 PM
Hi,

 ok, please find the two actions to get and set colors. You will need arrayMaker of course.

http://hutonggames.com/playmakerforum/index.php?topic=3720.0

 bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on April 29, 2013, 05:09:15 PM
Hi Jean,

This is great!
It would be AMAZING to be able to store all the current values of an array so there wont need to be a get action processed at runtime or a mesh with the vertex data held in the game. This would mean we could import a model with existing vertex color, store the colors in an array and then delete the model from our game (leaving one version for the game)

Thoughts?
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on May 02, 2013, 10:49:22 AM
hi,

 currently not possible, sorry. Playmaker only works during runtime. The solution would be to create a beefed up arrayMaker version that expose such tools during editing, but that's quite involving and not really planned at the moment... I have added it to my to dos on arrayMaker, so It will be considered one day :)

bye,

 Jean
Title: Re: Mesh - Get/Set vertex color[SOLVED]
Post by: escpodgames on May 02, 2013, 04:15:00 PM
Thought it might be a lot of work. Might be able to spit the vert colors out of maya as a text doc ... then load that into arraymaker!??! fingers crossed
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on May 03, 2013, 08:10:11 PM
Hey Jean! So close now ..

Exported some vertex colors from Maya and now have a text file which I have plugged into the "split text to array List" action - now I have to get the line in the text to be a color value.

Would it be easy to have a parse type in the "split text to array List" as color?
assuming the color values were something like "0.5342 0.26373 0.823220"
each line was three float values split with a space.

I will also ty to build a maunal process that will take each float and set the RGB color ... in my head that could also work.
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on May 03, 2013, 09:37:34 PM
Solved! YUS! So I take the first three floats and spit out a color, then remove those three from the array and repeat until it's done and I have an array of colors! ready to set on the mesh! I love Playmaker! (and arraymaker)

Thanks for all your help Jean!
Title: Re: Mesh - Get/Set vertex color
Post by: jeanfabre on May 06, 2013, 11:40:28 PM
Hi,

 Very good!

bye,

 Jean
Title: Re: Mesh - Get/Set vertex color
Post by: escpodgames on May 11, 2013, 05:01:14 PM
Just a small update, the vertex colors Maya exports are different to the ones Unity has Doh - this is due to each vertex having a possible 1,2 or 4 colors.
So I'm writting a Unity script that exports the vertex colors into a txt file, its not 100% working yet but I'm working on it :)