Page 1 of 1
camera mapping
Posted: Wed Jun 28, 2017 5:31 pm
by pingovanderb
Hey guys, I can read from the documentation that it's possible to camera map textures, however it doesn't say how. It would be great with a screenshot on how to hook it up.
cheers
Re: camera mapping
Posted: Wed Jun 28, 2017 11:07 pm
by juanjgon
Hi,
The camera mapping can be done using the "Projection Perspective" node, but some additional setup will be needed to match the camera node projection parameters. I'll try to build a sample scene for you.
Thanks,
-Juanjo
Re: camera mapping
Posted: Fri Jul 07, 2017 5:28 pm
by davidgidali
Would love to see it done properly in Max. All I was able to do is have it use the active camera as the projector - but I need a separate (static in my case) projection camera.
Thanks!
Re: camera mapping
Posted: Fri Jul 07, 2017 5:33 pm
by juanjgon
Yes, sorry. I'm still trying to figure how to configure it. Some maths are to be computed to get the camera transformation and projection parameters needed to configure the projection node, and it is not easy. I hope to have a solution soon.
Thanks,
-Juanjo
Re: camera mapping
Posted: Fri Jan 11, 2019 3:02 am
by ptunstall
Hey Juanjo did you ever get this working?
Re: camera mapping
Posted: Mon Jan 14, 2019 1:25 pm
by juanjgon
Hmm, I don't think so, but I'll try to investigate it ASAP.
Thanks,
-Juanjo
Re: camera mapping
Posted: Sun Feb 17, 2019 1:50 pm
by Nicolas_ts
You can do camera mapping through UV texture node. Choose texture type - Perspective from camera, and select your camera. But this method doesn't solve problem with flat environment textures.
Re: camera mapping
Posted: Tue Oct 18, 2022 8:31 pm
by vlucendo
Apologies for bumping an old thread but are there any updates on this? I was looking for an easy way to project a texture into a mesh from a specific camera but could not find the right node combination in Houdini.
Thanks!
Re: camera mapping
Posted: Sat Oct 29, 2022 6:32 am
by vlucendo
I ended up doing my own camera projector osl node for this. Hopefully it will help others too.
Code: Select all
// Camera projector osl by Vicente Lucendo - https://vlucendo.com
shader CameraProjector
[[
string label = "Perspective Camera Projector",
string help = "<h3>Perspective Camera Projector</h3> Node to project from a perspective camera",
string version = "0.1"
]]
(
// inputs
int projectBackface = 0 [[ string widget = "checkBox" ]],
point position = point(0, 0, 10),
vector rotation = vector(0, 0, 0),
float width = 1280 [[ float min = 1, float max = 999999 ]],
float height = 720 [[ float min = 1, float max = 999999 ]],
float pixelAspect = 1.0 [[ float min = 0.0001, int max = 999999 ]],
float focalLength = 50.0 [[ float min = 1, float max = 180 ]],
float aperture = 41.4214 [[ float min = 1, float max = 180 ]],
// output
output point uvw = 0
)
{
point meshPosition = P;
vector offset = meshPosition - position;
vector dir = normalize(offset);
// don't project backfaces
if (projectBackface == 0 && dot(transform("world", N), dir) > 0.0) return;
// calculate the camera rotation as a matrix4. we assume rotation is in default order
vector rotRad = radians(rotation);
float a = cos(rotRad.x);
float b = sin(rotRad.x);
float c = cos(rotRad.y);
float d = sin(rotRad.y);
float e = cos(rotRad.z);
float f = sin(rotRad.z);
float ae = a * e;
float af = a * f;
float be = b * e;
float bf = b * f;
// create inverted matrix directly
matrix rot = matrix (
c * e, c * f, - d, 0,
be * d - af, bf * d + ae, b * c, 0,
ae * d + bf, af * d - be, a * c, 0,
0, 0, 0, 1
);
// position in camera space
point pos = transform(rot, offset);
// houdini's camera fov
float apy = (height * aperture) / (width * pixelAspect);
float fov = 2 * atan((apy / 2) / focalLength);
// project the point
float ff = 1.0 / tan(fov / 2);
float aspect = width / height;
ff /= pos.z;
pos.x *= ff / aspect;
pos.y *= ff;
// change range from -1..1 to 0..1
pos.x = 1.0 - (pos.x * 0.5 + 0.5);
pos.y = 1.0 - (pos.y * 0.5 + 0.5);
// dont project off limits
if (pos.x < 0.0 || pos.x > 1.0 || pos.y < 0.0 || pos.y > 1.0) return;
uvw.x = pos.x;
uvw.y = pos.y;
}

Re: camera mapping
Posted: Sat Oct 29, 2022 9:39 pm
by Terryvfx
@vlucendo thanks for sharing!