Jump to content

How to sum vertex colors into one solid color of primitive


Recommended Posts

Hi guys!
I want to make 'lowpoly stilyzed' image.
I know it is easy to make that by vex expression(for example),but i don't know vex syntax right now-just starting to learn it.
Please help me on my Houdini way. :)
 
Left what i have,right what i need.
Example in random colors,but i am reading colors from image,don't be afraid. 
All i want is to sum up 3 values of 3 vertex colors to 1 primitive color,and then i'll have 3 same vertex colors in primitive.
By this way: Pr[*].Cd = (Pr[*].Vtx[x].Cd+Pr[*].Vtx[y].Cd+Pr[*].Vtx[z].Cd)/3

example.png
Edited by umpaumpa
Link to comment
Share on other sites

For vertex color:

// Primitive Wrangle.
@Cd = 0;
int vtxs[] = primvertices(0, @primnum);
foreach (int vtx; vtxs)
    @Cd += vector(vertex(0, "Cd", vtx)) / len(vtxs);

For point color:

// Primitive Wrangle.
@Cd = 0;
int pts[] = primpoints(0, @primnum);
foreach (int pt; pts)
    @Cd += vector(point(0, "Cd", pt)) / len(pts);

Then delete point or vertex color with Attribute Delete node, since primitive color has low priority.
 
Use Attribute Promote node. It has different methods, not only averaging.

primitive_color.hipnc

post-13104-0-37904800-1459110228_thumb.p

Edited by f1480187
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...