Maya: Get Screen Space Coordinates with Nodes

I’m embarrassed since I should know this after 20 years of Maya :confused:

How can I calculate the screen space coordinate of a 3d point with Maya nodes only? I want to use it efficiently in a particle expression, that’s why I don’t want to use code.

Also I’d prefer to not use a plugin for compatibility.

The cameraShape doesn’t seem to offer all the matrices needed and my matrix math knowledge is too limited to manually construct them.


Ah OK basically by trial and error I found a way:

a = vectorProduct (matrix dot mult) : camShape.worldInverseMatrix[0] x 3D point
b = multiplyDivide: a.z * -1
c = multiplyDivide : a.outX / b.outZ, a.outY / b.outZ and Z is the distance to the camera

screenSpace c.x / c.y ranging from -0.5 to 0.5 (a square, not taking into consideration the film gate)

Why exactly this worked I’m not sure, but good enough.

I wrote a script to automatically set this up, if someone needs this let me know.


I have an unrelated question, but slightly related.

Matrix Math:

I tried to get through linear algebra last year. The thing is, things like Guass Jordan Elimination and 10 dimensional matrix math are useful for machine learning and probably advanced graphics programming…

But tech art and rigging? Is vector calc where most of that is covered? (What’s the right university math course to go over)

I am always happy to shout the praises of 3b1b’s Essence of Linear Algebra.


Ah yes, this is good. I found it to be a nice accompanying to a Linear Algebra course :slight_smile:

I probably just need to practice more with it.

For example, a while back I posted about skew lines / closest point between non intersecting line problems that come up in modeling (think unbevel scripts) and perhaps rigging.

The thing is none of this really comes up in a Linear Algebra course… so is Linear Algebra the right subject? Or is it something like 3d vector calc. You could potentially solve it with Linear Algebra, if I remember correctly that involved some sort of subspace intersections and projections…I guess it’s more robust but I’m a 3d artist and I don’t care about n dimensional space solutions haha. :slight_smile:

I think even the sites you linked a while back Tfox, they do it with basically vector math…it’s like vector… calc? Is that the class? Is Linear Algebra actually the right classification for problems we solve regularly?

I’m just trying to figure out the right mapping between the 3 dimensional basic vector problems I’m trying to solve and the abstract stuff I learned.

I have seen SVD come up on demo reels and such… but again, as a Junior I have no idea how to apply solving those things, and what I did in class into “cool tools” that in maya…

I think this was the resource you linked:
From my experience a Linear Algebra course, which I’m sure I’ll be glad I took later on… almost never dealt with these. Starting to think vector calc? Maybe that would have been the right course? It’s funny because initially I thought okay…vectors, matricies… def linear algebra.

Ah, sorry. I throw those links at people so often that I forget who I’ve told. Mostly because they’ve helped me so. dang. much. Vector calc is definitely a class, but you might be looking for vector algebra? I never took it. I only made it as high as Calc 1 and a terrible linear algebra class. Everything else for me is self-taught. But now you got me thinking … So I looked up vector calculus on youtube and started watching some of the most popular series. After looking at a couple series, I like this guy’s style of teaching, and it may be closer to what you’re looking for.

Ok, I’m done watching series. He does some good stuff in there, but towards the end, he gets a little proof-heavy (re-deriving all the derivative rules). The thing he does great is he mostly stays in affine space (that’s the space where there is no origin) and only worries about the relationships between objects.
There was one where he did a proof that the medians of a triangle intersect at a point, and I had to go back to 3b1b to remind myself what a null space was :slight_smile:

1 Like

Thanks tfox :slight_smile:
No worries! Actually the site you linked is the solution, I was just trying to figure out which math “class” I needed to learn to get a handle on the plethora of useful algorithms on It took me quite a while to grasp the skew lines solver but I finally got it.

Honestly just looking for a math course that helps me really understand what’s on to start, and be prepped for a first job at this point haha.

It seems like it aligns quite well conceptually with vector calc | vector algebra, I’m enjoying the series you posted. For example line and plane intersection is covered in some vector calc classes. There’s no perfect mapping for CG related topics and Math (it’s mainly vector calc / algebra and deeper in Linear Algebra I think?)

Thinking about it more and doing some research it seems like both Linear Algebra and Vector Calc are useful in different ways. Vector Calc seems directly applicable for day to day rigging, modeling scripts, and houdini work.

On a deeper level, Linear Algebra, (Like SVD, or Gilbert Strang’s Linear Alebra course at Mit Open Courseware, comes more into play when you’re developing your own deformers or custom solvers?) This is the course I tried to cram into a month last year and it was rough haha.

2 Questions:
In your day to day work as a character TD, what has your experience been with math related topics? What should I focus on first, especially as someone trying to just get their start in the industry? (My guess would be Vector Calc related stuff, edit: Didn’t realize vector algebra is a thing, will look into that too :slight_smile: )

Do you find yourself going deep into Linear Alegbra (Like Strang’s MIT course) conceptual stuff on the job? That is quite intimidating :slight_smile: and beyond my current understanding.

My university background is similar to yours, I stopped at multivariable calculus in school, (with some vector work), didn’t take vector calc or linear algebra. (I probably should have started with Vector Calc , then proceeded to Strang’s Linear Algebra).

Proofs are another thing. Like if you asked me to take advantage of SVD in numpy, I could probably do it with some effort. But asking me to work out SVD or even Gauss Joran by hand, or even proove it I’d seriously struggle (which is what lots of HW’s for these types of classes entail (Proofs and Computation, but without nice libraries like Numpy).

Like on the job is it mostly Problem -> Map to concept -> Exploit in Library right? At least starting out?

How are you able to cope with cramming in the math to write tools in the midst of production?

That really depends on your role within a Tech Art team and the state of the project(s) you are working on, but at least in my experience there’s generally more non-math related tech art tools, pipeline, and production work to be done than the other way around. That said, studios will generally seek to hire math savy tech artists, rigging or not, because you will be that much more capable of developing creative solutions.

In our line of work understanding the practical utility of math principals in 3D is generally more important than working out the proof of it. Key Vector and 4x4 Matrix manipulation concepts being the baseline. If you are exploring SVD already, that’s great, especially if you can demonstrate valuable uses for it.


The “real” day to day for me is mostly about debugging and artist workflow stuff: A button to select all the deformers of a mesh. One to randomize colors based on naming convention. Changing the filepath widget for one ui to point to a different place. I think I’ve gotten more compliments for color-coding the tabs in a UI I wrote than anything else in the last year. I have a lot of fun when I get to write a deformer or implement some new idea, but that isn’t the norm. Even then, the hard math is done in less than a week, then there’s the month of making it usable by artists.

So what should you focus on first? I thnk Crispy hit the nail on the head: Vector and matrix manipulation are the baseline. I would also contend that learning how to write a UI for non-technical people is worth thinking about early.

Mostly when I get to do the math stuff, it’s more about the vector algebra than the linear algebra. Every once in a while I get into some hardcore linear algebra. But the linear algebra thing I find most useful is converting the vector algebra loops into single linear algebra commands for performance gains.

A simple example is if you need to bake blendshape animations into a cache, you could loop per frame, and multiply the value of the blendshape by its deltas, and accumulate them together. Or you could take the product of the array of animated blendshape values with the array of vertex deltas per-shape. Doing it that way is like a 50x speed boost in numpy vs. the naiive loop.
I helped an old buddy at another company get a 30 minute rig verification process down to 5 minutes with tricks like that. He owes me a case of beer for that one :slight_smile:

Speaking of performance, It’s worth learning a little bit about algorithms and data structures. A co-worker was working on writing c++ code that interacted with skin weights. He’s a python guy, so he was using unordered_maps (like python dicts) everywhere. I suggested using a different data structure, and it saved like 0.1 seconds per frame in his tests.

Ish? What I think has worked best for me has been learning what is possible first. That way, when I get a request or identify an inefficiency I know where to start to get a solution. Sometimes I already know how to do it, but often enough it’s just googling, or doing a github code search. I’ve got like 200 open source projects downloaded onto my work machine just for examples or little snippets.

Luckily for me, I’ve found the things that have needed heavy math, and the things that are needed quickly generally don’t overlap. The things needed now are things like shot builders, or tools to handle that weird custom character, or a one-off fix for when layout put the shot 50k units from the origin and they’re getting floating point jitter again (headdesk). The heavy math things I’ve done are either improvements on stuff the artists already have (like better blendshape transfer, or dynamic spline reparametrization), or stuff they didn’t know to ask for in the first place (fast heuristics for automatic point reordering)

1 Like

Thank you both tfox and Crispy4004, I very much appreciate the insights and guidance.

It’s especially useful to hear distinct use cases/ and examples, it gives me a more clearer picture of things to look for going forward. I really should start thinking about ways of transforming standard loop iteration into dot products. So cool :slight_smile:

I wanted to ask about github projects that have more examples of just linear algebra and code… but I think just looking at your repos on github might be enough. Lots to process! It’s nice that blur studio, imageworks and other places have a lot of open source code. Although a lot of it is def a bit too advanced for me.

Speaking of data structure, I’m very much a python guy as well :). If it’s possible, what data structure did you suggest Tfox? I always thought hash maps were really good given their lookup time is O(1). Often times I try to switch extensive switch cases into hash maps, given that’s more “pythonic”.

O(1) means that it takes a constant amount of time … but it doesn’t say what that amount of time is.
The reason that dictionaries are nice is that we don’t have to care what the keys are, or whether they’re even able to be put in an order. However, every time you do a lookup, you have to take the time to hash the key. But then what happens (ish. There’s more to it) is you take that hash value mod the length of your list, and that’s where the value for that key is stored.

But if your key is already an int, and you know you’re going to fill every slot in your data list (like if you’re storing data per vertex of a mesh), why go through the trouble of hashing? Just store your data in a list.

1 Like

To whom it may concern:

I made a short demo what I did with this screen space calculation.

I’m working on a system to overlay drawings on 3d renderings. It chooses the right size from a drawing database and inserts the image in screen space as particle sprite (best performance).

I developed the style a while ago, but I always used Nuke to finalize the image from raw data exported in Maya. So now, at last, I can complete the workflow in Maya without Nuke. Here’s an old post of an abandoned blog to see the previous workflow and more details on the database method:



That is really cool.