prim uvs to actual UV attribute?

   2194   6   0
User Avatar
Member
1177 posts
Joined: April 2017
Offline
Hi!

Lets say I wanted to promote prim UVs to replace the UVs for texturing, how would I go about this?

-Olivier
User Avatar
Member
9376 posts
Joined: July 2007
Offline
you probably can use s and t global variables in shader, which correspond to parametric uv coords
Edited by tamte - March 29, 2021 11:27:01
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
9376 posts
Joined: July 2007
Offline
or if you want to have it as vertex uv attrib in SOPs you can do
Vertex Wrangle:
xyzdist(0, itoa(@primnum), @P, int(), v@uv);
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
1177 posts
Joined: April 2017
Offline
Thanks! I'm using arnold so I think the xyzdist option is what I'm looking for.
User Avatar
Member
8177 posts
Joined: Sept. 2011
Online
I don't think xyzdist will work for polygon meshes. Since the shared points need to have different values for the parametric uvs.

For quads, you can use vertexindex to retrieve the corner number within the quad, and then use it to index into a barycentric coord array.

e.g.:
int index = vertexindex(0, @primnum, @vtxnum);
vector corners[] = array({0,0,0}, {1,0,0}, {1,1,0}, {0,1,0});
@uv = corners[index];

For triangles, I think you might need to duplicate one of the corner vertices to replicate mantra behavior. ngons shade completely differently as the u represents the index, and v is the distance from the barycenter, which isn't possible to represent as uv coordinates without triangulating.
User Avatar
Member
9376 posts
Joined: July 2007
Offline
jsmack
I don't think xyzdist will work for polygon meshes. Since the shared points need to have different values for the parametric uvs.
why wouldn't it?
it's using current prim as a group scope, so each vertex only gets primuv coords from its own prim

EDIT: I mean you may be right for ngons that wrap onto itself, like single polygons with bridged holes, but I assume that's not the case
Edited by tamte - March 29, 2021 20:40:12
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
8177 posts
Joined: Sept. 2011
Online
tamte
jsmack
I don't think xyzdist will work for polygon meshes. Since the shared points need to have different values for the parametric uvs.
why wouldn't it?
it's using current prim as a group scope, so each vertex only gets primuv coords from its own prim

EDIT: I mean you may be right for ngons that wrap onto itself, like single polygons with bridged holes, but I assume that's not the case

Ah, scoping it to the primitive may work for quads and triangles, but not if they have coincident points. It also won't work for ngons because the v value is the same for all of the vertices. It's also a sort of raytracing and will be a lot slower than indexing an array.
  • Quick Links