camera mapping

Forums: camera mapping
Houdini Integrated Plugin

Moderator: juanjgon

camera mapping

Postby pingovanderb » Wed Jun 28, 2017 5:31 pm

pingovanderb Wed Jun 28, 2017 5:31 pm
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
pingovanderb
Licensed Customer
Licensed Customer
 
Posts: 12
Joined: Thu Oct 23, 2014 11:14 am

Re: camera mapping

Postby juanjgon » Wed Jun 28, 2017 11:07 pm

juanjgon Wed Jun 28, 2017 11:07 pm
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
User avatar
juanjgon
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 8867
Joined: Tue Jan 19, 2010 12:01 pm
Location: Spain

Re: camera mapping

Postby davidgidali » Fri Jul 07, 2017 5:28 pm

davidgidali Fri Jul 07, 2017 5:28 pm
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!
davidgidali
Licensed Customer
Licensed Customer
 
Posts: 1
Joined: Mon Nov 07, 2016 4:53 am

Re: camera mapping

Postby juanjgon » Fri Jul 07, 2017 5:33 pm

juanjgon Fri Jul 07, 2017 5:33 pm
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
User avatar
juanjgon
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 8867
Joined: Tue Jan 19, 2010 12:01 pm
Location: Spain

Re: camera mapping

Postby ptunstall » Fri Jan 11, 2019 3:02 am

ptunstall Fri Jan 11, 2019 3:02 am
Hey Juanjo did you ever get this working?
ptunstall
Licensed Customer
Licensed Customer
 
Posts: 152
Joined: Thu Jun 04, 2015 1:36 am

Re: camera mapping

Postby juanjgon » Mon Jan 14, 2019 1:25 pm

juanjgon Mon Jan 14, 2019 1:25 pm
Hmm, I don't think so, but I'll try to investigate it ASAP.

Thanks,
-Juanjo
User avatar
juanjgon
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 8867
Joined: Tue Jan 19, 2010 12:01 pm
Location: Spain

Re: camera mapping

Postby Nicolas_ts » Sun Feb 17, 2019 1:50 pm

Nicolas_ts Sun Feb 17, 2019 1:50 pm
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.
Nicolas_ts
Licensed Customer
Licensed Customer
 
Posts: 1
Joined: Mon Mar 12, 2018 4:44 pm

Re: camera mapping

Postby vlucendo » Tue Oct 18, 2022 8:31 pm

vlucendo Tue Oct 18, 2022 8:31 pm
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!
vlucendo
Licensed Customer
Licensed Customer
 
Posts: 4
Joined: Tue Apr 13, 2021 4:46 pm

Re: camera mapping

Postby vlucendo » Sat Oct 29, 2022 6:32 am

vlucendo Sat Oct 29, 2022 6:32 am
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;
}


:)
vlucendo
Licensed Customer
Licensed Customer
 
Posts: 4
Joined: Tue Apr 13, 2021 4:46 pm

Re: camera mapping

Postby Terryvfx » Sat Oct 29, 2022 9:39 pm

Terryvfx Sat Oct 29, 2022 9:39 pm
@vlucendo thanks for sharing!
User avatar
Terryvfx
Licensed Customer
Licensed Customer
 
Posts: 358
Joined: Tue Dec 30, 2014 12:43 am

Return to Houdini


Who is online

Users browsing this forum: No registered users and 5 guests

Fri Mar 29, 2024 1:58 am [ UTC ]