Hello,
I am having a little hard time to understand linear vertex and @vtxnum. Why is @vtxnum returning a single value instead of a value for each vertex?
How does the @primvertex function work? (vertex.png)
I understood it as, primvertex points to the point number, so vertex 2 of primitive 1 should return 2 but instead it is returning 6. Not sure why? (second image - vertex2.png)
Linear Vertex
3063 4 2-
- raman.siddhartha
- Member
- 3 posts
- Joined: Aug. 2019
- Offline
-
- jsmack
- Member
- 8239 posts
- Joined: Sept. 2011
- Online
raman.siddhartha
I am having a little hard time to understand linear vertex and @vtxnum. Why is @vtxnum returning a single value instead of a value for each vertex?
@vtxnum is linear vertex. It has a value for each vertex. Calling primvertex of @primnum's 0th vertex is the same thing as @vtxnum when evaluated per-primitive. (In cases where there are more than one value for the queried element index in the current runover class, e.g. @ptnum when run over primitves, the value will be the first one found)
raman.siddhartha
How does the @primvertex function work? (vertex.png)
primvertex() returns the linear vertex number of the specified vertex index in the specified primitive.
-
- raman.siddhartha
- Member
- 3 posts
- Joined: Aug. 2019
- Offline
-
- tamte
- Member
- 9578 posts
- Joined: July 2007
- Online
raman.siddhartha@vtxnum in primitive mode contains just linear vertex number of the first vertex of that primitive
So does @vtxnum have the same value for each vertex of the same primitive?
the same way as @ptnum will contain just point number of the first point that the primitive is attached to
since your code is run per primitive you will only get one value per primitive, so it's usually the first one
if you run per vertex however @vtxnum will contain linear vertex number of current vertex
its called linear vertex number cause the numbers are organized in a linear way, so if you have 2 primitives, each has 3 vertices then primitive 0 will have vertices 0 1 2 and primitive 1 vertices 3 4 5
if you add another primitive, let's say quad, then that primitive 2 will have vertices 6 7 8 9, let's say another primitive 3 with vertices 10 11 12
etc.
if you then run wrangle over primitives, as mentioned @vtxnum for each primitive will return linear vertex number of the first vertex of that prim so for primitive 0 it will be 0, for primitive 1 it's 3, for primitive 2 it's 6 and for primitive 3 it will be 10 , ...
if you want to get all vertex numbers for the prim you have to get them using primvertices() function
Edited by tamte - March 26, 2021 23:58:58
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- raman.siddhartha
- Member
- 3 posts
- Joined: Aug. 2019
- Offline
Hi Tomas,
Thanks for the detailed explanation. This really helps. I understand it now.
My confusion was each primitive was showing vertex number 0 - 3 in the scene view, so I was getting confused why @vtxnum was showing values that were 4 8 12 and so on. Your explanation clears it up.
Thanks a ton.
Thanks for the detailed explanation. This really helps. I understand it now.
My confusion was each primitive was showing vertex number 0 - 3 in the scene view, so I was getting confused why @vtxnum was showing values that were 4 8 12 and so on. Your explanation clears it up.
Thanks a ton.

tamteraman.siddhartha@vtxnum in primitive mode contains just linear vertex number of the first vertex of that primitive
So does @vtxnum have the same value for each vertex of the same primitive?
the same way as @ptnum will contain just point number of the first point that the primitive is attached to
since your code is run per primitive you will only get one value per primitive, so it's usually the first one
if you run per vertex however @vtxnum will contain linear vertex number of current vertex
its called linear vertex number cause the numbers are organized in a linear way, so if you have 2 primitives, each has 3 vertices then primitive 0 will have vertices 0 1 2 and primitive 1 vertices 3 4 5
if you add another primitive, let's say quad, then that primitive 2 will have vertices 6 7 8 9, let's say another primitive 3 with vertices 10 11 12
etc.
if you then run wrangle over primitives, as mentioned @vtxnum for each primitive will return linear vertex number of the first vertex of that prim so for primitive 0 it will be 0, for primitive 1 it's 3, for primitive 2 it's 6 and for primitive 3 it will be 10 , ...
if you want to get all vertex numbers for the prim you have to get them using primvertices() function
-
- Quick Links

