Jump to content

Transfering colors in attribute wrangler

Recommended Posts

So I'm working with this attribute wrangler that makes a twisting braid around any curves I slot into it. However I am running into an issue where the original curves have a color but I can't seem to have the new twist inherit the color from the curve. Of course I can add a color node afterwards but that will only give it one color. Whereas my curves have multiple colors (each primitive has a different color).  

float rad = ch('radius');
float pi = 3.1415926;
float t = 2.0 * pi  * ch('winding');
int copies = chi('strands');

int prim_pts[] = primpoints(0, @primnum);

for(int i = 0; i < copies; i++){
    int add_prim = addprim(0, "polyline");
    foreach(int pt; prim_pts){
        vector pt_p = point(0, "P", pt);
        vector pt_n = point(0, "Nloc", pt);
        vector pt_b = point(0, "Bloc", pt); 
        vector uv = point(0,"uv",pt);
        float s =uv.x;
        float phase = 2*pi / copies * i;
        vector pt_pos = pt_p + pt_n * sin(s*t+phase)*rad + pt_b * cos(s*t+phase)*rad;
        int add_pt = addpoint(0, pt_pos); 
        addvertex(0, add_prim, add_pt);



Edited by netherknight

Share this post

Link to post
Share on other sites

Instead of this:  setprimattrib(0,"Cd",add_prim,1);

Do this:  setprimattrib(0,"Cd",add_prim,@Cd);

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now