How could I promote an attribute in wrangle?
3470
4
0
Masoud
Member
426 posts
Joined: Aug. 2015
Offline
Oct. 16, 2017 4:08 a.m.
Hi guys;
In a point wrangle, I want to get the Normal of a specified primitive (from input geometry) and pass the value as @MyNewNormal point attribute to output. (Normal from a “Primitive” to Normal of a “Point”)
I tried these codes, but it doen't work:
int PrimNumber ;
vector Prim_uv ;
float maxdist = 10 ;
float dist = xyzdist (1 , @P , PrimNumber , Prim_uv , ch ("MaxDist" ));
i@PrimNumber = PrimNumber ;
v@MyNewNormal = prim (1 , "N" , PrimNumber );
Edited by Masoud - Oct. 16, 2017 04:09:25
Masoud Saadatmand (MSDVFX)
bonsak
Member
459 posts
Joined: Oct. 2011
Offline
Oct. 16, 2017 6:51 a.m.
If you want to get the normal from a specific prim (f.ex prim zero) you can use:
int success ;
v@N = primattrib (1 , 'N' , 0 , success );
By using xyzdist you get the normal from the primitive that is closest to the point your wrangle is running over.
-b
Masoud
Member
426 posts
Joined: Aug. 2015
Offline
Oct. 16, 2017 8:04 a.m.
Thank you bonsak;
As you said, I tried xyzdist, and it worked:
vector Norm = xyzdist(1, @N, PrimNumber, Prim_uv, ch("MaxDist")); @N=Norm;
Masoud Saadatmand (MSDVFX)
tamte
Member
9416 posts
Joined: July 2007
Offline
Oct. 16, 2017 12:47 p.m.
Masoud Thank you bonsak; As you said, I tried xyzdist, and it worked:vector Norm = xyzdist(1, @N, PrimNumber, Prim_uv, ch("MaxDist")); @N=Norm; xyzdist just returns the float distance, so if it looks like it works in your case, it may just be a coincidence
to get the real primitive normal use:
int pid ;
vector puv ;
xyzdist (1 , @P , pid , puv , ch ("MaxDist" ));
if (pid !=-1 ) {
@N = prim_normal (1 , pid , puv );
}
if you want interpolated normal in case vertex or point N exists then:
int pid ;
vector puv ;
xyzdist (1 , @P , pid , puv , ch ("MaxDist" ));
if (pid !=-1 ) {
@N = primuv (1 , "N" , pid , puv );
}
Tomas Slancik CG Supervisor Framestore, NY
Masoud
Member
426 posts
Joined: Aug. 2015
Offline
Oct. 17, 2017 2:22 a.m.
Thank you “Tamte” You are right, it was my mistake.
Masoud Saadatmand (MSDVFX)