playMaker

Author Topic: Mesh - Get/Set vertex color  (Read 10446 times)

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Mesh - Get/Set vertex color
« on: April 15, 2013, 12:35:44 AM »
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
« Last Edit: April 15, 2013, 12:49:53 AM by LampRabbit »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #1 on: April 15, 2013, 01:15:18 AM »
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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #2 on: April 15, 2013, 01:30:16 AM »
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.
« Last Edit: April 15, 2013, 01:32:12 AM by LampRabbit »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #3 on: April 15, 2013, 01:35:15 AM »
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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #4 on: April 15, 2013, 01:47:42 AM »
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)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #5 on: April 15, 2013, 01:57:38 AM »
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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #6 on: April 15, 2013, 01:59:24 AM »
Awesome!!! ;D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #7 on: April 15, 2013, 02:01:27 AM »
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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #8 on: April 15, 2013, 03:07:59 AM »
Sure thing! Attached to this post is an fbx (colors are different as I quickly remade it)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #9 on: April 15, 2013, 03:14:00 AM »
hi,

 it's all grey...

Bye,

 Jean

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #10 on: April 15, 2013, 04:06:01 AM »
Just setup the Unity scene for you, I assume you didn't have the right shaders.

See attached
« Last Edit: April 15, 2013, 04:11:08 AM by LampRabbit »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #11 on: April 15, 2013, 05:47:07 AM »
Hi,
 
Much better, thanks,

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #12 on: April 24, 2013, 02:30:37 AM »
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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #13 on: April 29, 2013, 08: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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Mesh - Get/Set vertex color
« Reply #14 on: May 02, 2013, 01:49:22 PM »
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