how to camera project meshes

   4994   7   3
User Avatar
Member
45 posts
Joined: July 2015
Offline
hi,

i am trying to camera project meshes (like a texture, but with geometry) onto another geometry…
i tried to use the ray sop with the camera pivot as a projection vector, but this not seems to work correctly because i somehow have to take the focal length in account…
is there a way how to correctly camera project meshes onto other meshes?
User Avatar
Member
806 posts
Joined: Oct. 2016
Offline
Moin,

I guess “correctly camera projecting meshes” depends on what you consider “camera projection” - from my perspective (pun intended) that *requires* a focal length, else it wouldn't be a “camera projection”.

Do you want to “parallel project” (orthogonally ray-cast) a mesh onto a projection target or do you want to “perspective-project” from a single point (pin-hole camera model)? If the latter, you *are* talking about “camera projection” and you *would* need a focal length, since that would define your field of view (or “what part of your projection target can actually receive any points from the projection”).

If you wanted to do a parallel projection, one approach might be to take the vector between the two bounding boxes (projected mesh and projection target) as your direction, then ray-cast every point from the projection mesh onto the projection target and do a “intersect” (VEX) to find the target point (if there is one).

If you “only” want to “project” through your camera's pinhole, you would get a “projection result” using intersect with rays created from your projection-mesh through the pinhole position against the projection target. Technically, this doesn't require a focal length, but it's not exactly a “projection” I think.


Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
User Avatar
Member
7739 posts
Joined: Sept. 2011
Online
To set up a point projection, subtract the points position from the mesh's position and use that as the projection direction. Focal length doesn't actually affect a camera projection, only distance. Although you might want to limit which points are projected by field of view, in which case focal length does matter, but it doesn't affect in what direction the affected points are projected. The easy way to build an fov mask is to use the uv texture node, and test against the resulting uv coordinates.
User Avatar
Member
806 posts
Joined: Oct. 2016
Offline
Focal length doesn't “change the direction of the projection” (as long as you are in 3d space), but it DOES affect your projection if you are going from 2d to 3d or vice versa (that's what I would consider a “camera projection”, involving a 2d-step).

A longer focal length would project onto a smaller area of your target, creating a smaller and less skewed projected mesh, a shorter focal length would stretch your projected mesh across a wider area of your target.
Read: *IF* you are doing a 2d-step in between, focal-length does actually change your rays' directions. If you are NOT doing a 2d-step (“camera”) and only consider the camera's position your pivot, focal length is “out of the picture” (pun intended).

The resulting projection would also depend on how you consider your source (projected mesh) placed within the camera: Is it within the camera's field of view (then you could actually calculate your field of view from there), is it on your camera plate (which might also help) or is it “independent” from the camera's transform/matrix?

Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
User Avatar
Member
45 posts
Joined: July 2015
Offline
thanx for the replys…

it should be perspective projection…

at the moment with the ray sop and and the normalized camera position as a vector i get ortho projection, so i have to take the fov (or focal length?) in to account to get perspective projection…
or shoot a projection ray per mesh point from the cam position…like a raytracer with a virtual screen…

(in xsi ice i would do this with the raytrace node, feeding mesh points, a direction vector and the test geo, but it would shoot rays for every point of the geo)

any hints where to start?

@jsmack would this projection direction (cam pos minus mesh points) be done in a for loop with a ray sop inside?
Edited by soulcage_dpt - July 29, 2020 15:55:10
User Avatar
Member
7739 posts
Joined: Sept. 2011
Online
soulcage_dpt
@jsmack would this projection direction (cam pos minus mesh points) be done in a for loop with a ray sop inside?

No, just subtract it in a vop/wrangle. no loop required. store the result as a direction vector attribute. The ray sop can take an attribute for the direction, and always projects all points by default.

Attachments:
projection_geo.hip (388.4 KB)

User Avatar
Member
45 posts
Joined: July 2015
Offline
thanx for the example. i will take a look (i am just not in front of my computer)
User Avatar
Member
45 posts
Joined: July 2015
Offline
thanx again, this example is perfect…
  • Quick Links