Camera Projections in Karma

   6319   17   4
User Avatar
Member
235 posts
Joined: 10月 2014
Offline
Could someone provide a quick summary of how one does camera projections in Karma? (projecting a texture onto a mesh from a camera).

Was looking for camera projection node for this, but either I'm underthinking it, or overthinking, or just looking in the wrong place.
Edited by Tim Crowson - 2022年2月4日 15:21:51
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
235 posts
Joined: 10月 2014
Offline
(Bump)
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
7737 posts
Joined: 9月 2011
Offline
I don't think there's anything built in for that. What are you trying to use the camera projection for? For shader level projections, it's up to the renderer, and I think usd currently has no mechanism for shaders to reference cameras other than the render cam.

For projecting onto vertices/points, there's sops. There's not an easy way to access a usd camera from sops though. It might be better to use python to get the matrices for the camera and store them as primvars on the geometry. Karma can access matrix primvars to do the projection in shader using homogenous coordinates.
User Avatar
Member
235 posts
Joined: 10月 2014
Offline
Yikes....


Camera projection is a pretty fundamental tool for us (and I'm sure for many in VFX). In this case I'm just asking about Karma. Redshift already has a working solution for this. I'm just curious what the solution in Karma would be.
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
7737 posts
Joined: 9月 2011
Offline
Tim Crowson
Camera projection is a pretty fundamental tool for us (and I'm sure for many in VFX). In this case I'm just asking about Karma.

There's already no way to do arbitrary projections in mantra, so it's not different in that regard. There's a convenient solution in VEX for building a perspective matrix given camera view parameters. It's not that hard to implement in either renderer. It's just annoying to have to grab all the channels from the camera in /obj or from all the properties in usd.

Tim Crowson
Redshift already has a working solution for this.

A solution in Solaris? As far as I know USD coordsys is still in the proposal stage.

https://graphics.pixar.com/usd/dev/wp_coordsys.html [graphics.pixar.com]
User Avatar
Member
235 posts
Joined: 10月 2014
Offline
I don't know what approach they took, but I know their CameraMap shader takes a USD cam prim and spits out the right thing.
- Tim Crowson
Technical/CG Supervisor
User Avatar
スタッフ
2590 posts
Joined: 7月 2005
Offline
In Karma CPU, you should be able to transform to NDC coordinates pretty trivially.
User Avatar
Member
235 posts
Joined: 10月 2014
Offline
What I'm bumping on is how to query the USD camera in the shading graph... is this possible?

Does the toNDC node accept a USD camera directly?
Edited by Tim Crowson - 2022年2月8日 18:07:34
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
7737 posts
Joined: 9月 2011
Offline
Tim Crowson
What I'm bumping on is how to query the USD camera in the shading graph... is this possible?

Does the toNDC node accept a USD camera directly?

There is no, 'a camera', there is only 'the camera'--the one being rendered from. toNDC/fromNDC use the rendering camera for calculations, they don't accept an arbitrary camera.
User Avatar
Member
77 posts
Joined: 10月 2016
Offline
Hello there,
not sure about karma but here is how you can achieve it in renderman under solaris.
https://renderman.pixar.com/answers/questions/21851/how-to-make-camera-projections-in-solaris.html [renderman.pixar.com]
User Avatar
Member
23 posts
Joined: 9月 2021
Offline
jsmack
Tim Crowson
What I'm bumping on is how to query the USD camera in the shading graph... is this possible?

Does the toNDC node accept a USD camera directly?

There is no, 'a camera', there is only 'the camera'--the one being rendered from. toNDC/fromNDC use the rendering camera for calculations, they don't accept an arbitrary camera.

That node cannot be used with materialX though, can it?

@Tim:
We created a tool that projects NDC coordinates on the points of meshes as array primvar and one can use in the shader to get what you're asking - not perfect if render has displacement (I imagine), but close enough for our purposes.
User Avatar
Member
642 posts
Joined: 8月 2013
Offline
Hi. Could you upload an example of that please?
User Avatar
Member
7737 posts
Joined: 9月 2011
Offline
Mark Wallman
Hi. Could you upload an example of that please?

The uvtexture sop can be used when pointed to a camera object (not usd prim though) in sopmodify LOP
User Avatar
Member
642 posts
Joined: 8月 2013
Offline
Hi Thats pretty much what I do now (modify the UV's) Best. Mark
User Avatar
Member
23 posts
Joined: 9月 2021
Offline
Mark Wallman
Hi. Could you upload an example of that please?

Here you go.

Attachments:
ndc_attrib.hip (207.4 KB)

User Avatar
Member
642 posts
Joined: 8月 2013
Offline
Thanks ;-)
User Avatar
Member
43 posts
Joined: 9月 2018
Offline
Very helpful thanks!
User Avatar
Member
10 posts
Joined: 1月 2015
Offline
Take a look at this:
https://www.sidefx.com/docs/houdini/nodes/lop/coordsys.html [www.sidefx.com]
There's an example scene at the bottom. I have to admit, it took me a while to understand what's going on.
  • Quick Links