Jump to content

How can I transfer a color attribute from one geo to texture of another geo?


Recommended Posts

Hello;

To create a very high-resolution footprint, I would like to transfer the color attribute from one geometry (from a box, or some sliding particles ) to another geometry ( a grid ),  based on a UV texture map (UV on second object).

This is something like creating a wet-map, and I don't want to scatter points on a surface to ... (I mean that I  know that workflow).

Actually I want to extract a very high-quality texture as output.

 

Any idea?

 

 

Thanks for helping.

 

 

Drag.jpg

Edited by Masoud
Link to comment
Share on other sites

16 minutes ago, Masoud said:

Hello;

To create a very high-resolution footprint, I would like to transfer the color attribute from one geometry (from a box, or some sliding particles ) to another geometry ( a grid ),  based on a UV texture map (UV on second object).

This is something like creating a wet-map, and I don't want to scatter points on a surface to ... (I mean that I  know that workflow).

Actually I want to extract a very high-quality texture as output.

 

Any idea?

 

 

Thanks for helping.

 

 

Drag.jpg

Here is a good way to deal with that. https://lesterbanks.com/2019/01/create-uv-based-wetmap-houdini/

Link to comment
Share on other sites

Hi Masoud,

you can write attributes directly to a 2D volume inside a solver using a volume wrangle:

float radius = 0.02;

int prim;
vector uvw;
float dist = xyzdist(1, v@P, prim, uvw);
vector clr_sample = 0.0;
if(dist < radius){
    clr_sample = primuv(1, 'Cd', prim, uvw) * vector(0.2);
}
v@clr += clr_sample;

The example above is using the usual suspects for transferring attributes, xyzdist() and primuv(). Then the SOP import-node imports attribute values to COPs.

image.png.d1444f3402653678a9f547220990d03a.pngimage.png.c6b38ac31720e82b104e5c0eff992bc9.png 

color_field.hipnc

Link to comment
Share on other sites

17 hours ago, konstantin magnus said:

Hi Masoud,

you can write attributes directly to a 2D volume inside a solver using a volume wrangle:


float radius = 0.02;

int prim;
vector uvw;
float dist = xyzdist(1, v@P, prim, uvw);
vector clr_sample = 0.0;
if(dist < radius){
    clr_sample = primuv(1, 'Cd', prim, uvw) * vector(0.2);
}
v@clr += clr_sample;

The example above is using the usual suspects for transferring attributes, xyzdist() and primuv(). Then the SOP import-node imports attribute values to COPs.

image.png.d1444f3402653678a9f547220990d03a.pngimage.png.c6b38ac31720e82b104e5c0eff992bc9.png 

color_field.hipnc

Hi " Konstantin ";

Thanks for the reply. I don't want to use a 2D plane.
Actually I need to access a corresponding pixel in a UV texture when a point collides a primitive (surface).

Link to comment
Share on other sites

16 hours ago, Librarian said:

I found him
here you gonna find Olaaa la nice stuff to investigate and have fun.:wub:

vimeo.com/zengchen

Hi " Tesan ";

Thanks for the reply. I don't want to scatter extra points on a 2D surface, and I need to access a corresponding pixel in a UV texture when a point collides a primitive (surface).

Link to comment
Share on other sites

You constantly on every Post changing(editing) what you actually want :wub:..its OK

You must define first on-grid some flow map make attributes also what your box do on-grid. Than learn this ..

new asset-SHOP SURFACE.  2 surface that you need somehow-to combine to get that effect I think.

//Read data
#pragma label       mult        "Multiplier"
#pragma label       spread      "Overall Spread"
#pragma label       DATA        "Data Points"
#pragma label       group       "Point Group"

surface
color_transfer
(   float   mult    = 0.5,
            spread  = 1;
    string  DATA    = "$HIP/../VEX/Reading-Data-Points/_datapoints.bgeo.sc",
            group   = "group0";)
{
    float d, Np, pFratt;
    vector _P, pP, pCd, pVratt, outColor;
    
    _P = ptransform("space:camera", "space:world", P);
    
    outColor = 0;
    
    int p[] = expandpointgroup(DATA, group);
    Np = len(p);
    for(int i = 0; i < Np; i++){
        pP = point(DATA, "P", p[i]);
        pCd = point(DATA, "Cd", p[i]);
        pFratt = point(DATA, "fratt", p[i]);
        d = distance2(pP, _P);
        d = exp(-d*d/(pFratt*spread));
        outColor += pCd*mult*d;
    }

    Cf = outColor;
}
---------------------------
SMUDGE

#define PI          3.1415926535897931
#pragma label       Theta       "Maximum Theta"
#pragma label       spread      "Overall Spread"
#pragma label       DATA        "Data Points"
#pragma label       kd          "Diffuse"
#pragma label       ks          "Specular"
#pragma label       bump        "Bump"

surface
qrotation_field
(   float   Theta   = 2.0,
            spread  = 3,
            kd      = 1,
            ks      = 0.5,
            bump    = 0.1;
    string  DATA    = "$HIP/../VEX/Reading-Data-Points/_datapoints.bgeo.sc")
{
    float d, Np, theta, pFratt, factor, pspread;
    vector _P, pP, axis, pVratt;
    vector4 Q;
    string group;
    
    _P = ptransform("space:camera", "space:world", P);

    theta = snoise(_P + 0.9, 1, 0.75, 1)*4.5;
    axis = snoise(_P + 0.05, 1, 0.05, 1);
    Q = quaternion(theta, axis);
    _P = qrotate(Q, _P);
    
    for(int g = 0; g < 2; g++){
        group = concat("group", itoa(g));
        int p[] = expandpointgroup(DATA, group);
        Np = len(p);
        factor = g + 1;
        for (int i = 0; i < Np; i++){
            pP = point(DATA, "P", p[i]);
            axis = point(DATA, "N", p[i]);
            pFratt = point(DATA, "fratt", p[i]);
            pVratt = point(DATA, "vratt", p[i]);
            pspread = pFratt*spread/factor;
            d = distance2(pP, _P);
            d = exp(-d*d/pspread);
            theta = 2*PI*(pFratt*2 - 1)*d*Theta/factor;
            Q = quaternion(theta, axis);
            _P = qrotate(Q, _P - pP) + pP;
        }
    }

    vector outColor = snoise(_P*0.25, 1, 0.25, 1);

    vector Nn = normalize(computenormal(P + min(outColor)*bump, N, Ng));
    
    vector diff = diffuse(Nn)*outColor*dot(normalize(-I), N);

    vector spec = specular(Nn, normalize(-I), fit01(min(outColor), 0.5, 0.1))*0.1;
    spec += specular(N, normalize(-I), 0.05);

    Cf = diff*kd + spec*ks;
}
------------------------------------------------------------------
CONST TEXTURE
#pragma label       mode    "Mode"
#pragma choice      mode    "uv"    "UV :: Geometry coordinates"
#pragma choice      mode    "st"    "ST :: Primitive coordinates"

#pragma label       text    "Texture map"
#pragma hint        text    image

#pragma label       mult    "Color multiplier"
#pragma hint        mult    color

#pragma label       opac    "Opacity"
#pragma hint        opac    color

#pragma label       uv      ""
#pragma hint        uv      invisible

#pragma label       repeat  "Repeat coordinates"
#pragma hint        repeat  uv

#pragma label       offset  "Offset"
#pragma hint        offset  uv

surface
constant_texture
(   string  mode    =   "uv",
            text    =   "Mandril.pic";
    vector  mult    =   {1, 1, 1},
            opac    =   {1, 1, 1},
            uv      =   {0, 0, 0};
    vector2 repeat  =   {1, 1},
            offset  =   {0, 0})
{
    vector  _coord2d, _texture, _color, _repeat, _offset;
    if(mode == "st"){
        _coord2d = set(s, t, 0);
    }
    else{
        _coord2d = uv;
    }
    _repeat = repeat;
    setcomp(_repeat, 1, 2);
    _offset = offset;
    setcomp(_offset, 1, 2);
    _coord2d = _coord2d*_repeat + _offset;
    _texture = texture(text, _coord2d.x, _coord2d.y);
    _color = _texture*mult;
    Cf = _color*opac;
    Of = opac;
}

I hope IT Helps .....and maybe someone can clarify

 

 

Edited by Librarian
  • Like 1
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...