playMaker

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

escpodgames

  • Hero Member
  • *****
  • Posts: 686
    • View Profile
    • Assets
Mesh - Get/Set vertex color
« 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
« Last Edit: April 14, 2013, 09:49:53 PM by LampRabbit »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14611
  • Official Playmaker Support
    • View Profile
Re: Mesh - Get/Set vertex color
« Reply #1 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

escpodgames

  • Hero Member
  • *****
  • Posts: 686
    • View Profile
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #2 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.
« Last Edit: April 14, 2013, 10:32:12 PM by LampRabbit »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14611
  • Official Playmaker Support
    • View Profile
Re: Mesh - Get/Set vertex color
« Reply #3 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

escpodgames

  • Hero Member
  • *****
  • Posts: 686
    • View Profile
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #4 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)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14611
  • Official Playmaker Support
    • View Profile
Re: Mesh - Get/Set vertex color
« Reply #5 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

escpodgames

  • Hero Member
  • *****
  • Posts: 686
    • View Profile
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #6 on: April 14, 2013, 10:59:24 PM »
Awesome!!! ;D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14611
  • Official Playmaker Support
    • View Profile
Re: Mesh - Get/Set vertex color
« Reply #7 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

escpodgames

  • Hero Member
  • *****
  • Posts: 686
    • View Profile
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #8 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)

jeanfabre

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

 it's all grey...

Bye,

 Jean

escpodgames

  • Hero Member
  • *****
  • Posts: 686
    • View Profile
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #10 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
« Last Edit: April 15, 2013, 01:11:08 AM by LampRabbit »

jeanfabre

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

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14611
  • Official Playmaker Support
    • View Profile
Re: Mesh - Get/Set vertex color
« Reply #12 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

escpodgames

  • Hero Member
  • *****
  • Posts: 686
    • View Profile
    • Assets
Re: Mesh - Get/Set vertex color
« Reply #13 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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14611
  • Official Playmaker Support
    • View Profile
Re: Mesh - Get/Set vertex color
« Reply #14 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