Jump to content

Perspective Projections


sibarrick

Recommended Posts

Hi all,

Does anyone know how to build a matrix that will project the points of an object onto the viewing plane of a camera or light. I know how to transform the points from world space to the camera space but then how do you do the perspective projection onto the viewing plane using the FOV and the image res of the camera or light?

I've found various descriptions of how to do this but when I try to impliment them they don't work with Houdini's camera FOV's and image res. :angry:

I did find one formula that seemed to work but it wasn't a matrix, and so didn't allow me to transform z too, which is actually what I need to really do.

Ultimately what I want to do is build a cop that lets you input 2 images with Pz info, one from the point of view of a camera and one from a light and then by specifying where the light was it will add shadows to the image.

Of course if there is a cop that I don't know about that already does this then that would be handy too :)

Any help gratefully recieved.

Oh I should add that I can't do this with any built in space change functions. Firstly because you can't use them in cops and secondly because this is just a test for something that will eventually be done outside of Houdini, I just trying to figure out the maths for it.

Link to comment
Share on other sites

Does this help? Look at the SOP method.

Velocity Rendering Tutorial

17265[/snapback]

Hi Jason, unfortunately this was exactly what I was trying to avoid, it uses those lovely built in space change functions, I want to know the math behind the functions.

Edward, that link looks like exactly what I want, I try it out later, sometimes it seems to be hard to track down the basics. All my CG books describe the process but none of them are very precise about what is going on. For some reason my google search completely failed to turn up anything like this. All I got was a bunch of papers on doing perspective shadow mapping or openGL implimentations without the explaination. That link looks really handy, ta. :D

Link to comment
Share on other sites

Ok you clever people now I'm really stuck.

Edwards link was great and when I implimented the code all looked good. However I had to use the tangent and not the cotangent to get sensible results.

BUT when I compare it with doing the same projection with the UVtexture sop I found they didn't match.

Digging a little deeper I find that according to the notes in Edwards link the Houdini projection is the incorrect way to do things. Take a look at the attached and you will see that the UVtexture sop distorts lines into curves whereas the method in the link does not.

This raises two questions.

1. Is the Houdini UVtexture sop wrong or just different, and does this have any implications else where. Does it actually matter? Surely though people use this method of textureing for matching to live action plates so surely the UVtexture sop must work?

2. I still don't know how to match the way Houdini does it, in the attached example I've had to fudge it by manually altering the FOV value so that it no longer matches the light that it's linked to.

If anyone has any answers to either of these questions I'd really appreciate it, in the meantime I'll keep digging.

:ph34r:

test1000.zip

Link to comment
Share on other sites

2. I still don't know how to match the way Houdini does it, in the attached example I've had to fudge it by manually altering the FOV value so that it no longer matches the light that it's linked to.

I took a quick peek at your vex setup and have one question...

The aperture of the light/camera also effects the view frustum but I don't see it being taken into account anywhere?

Link to comment
Share on other sites

I took a quick peek at your vex setup and have one question...

The aperture of the light/camera also effects the view frustum but I don't see it being taken into account anywhere?

17307[/snapback]

That's a good point, I hadn't even begun to think about that, all the notes I've read so far only talk about the FOV. Changing aperture just seems to create a linear scale, if this is true it shouldn't be too hard to incorporate.

By the way I've uploaded a new version as I made some errors in the original that I've already fixed. I'll totally confused at the moment and it's late so I'm off to bed. With any luck by the morning Edward and Mario will have sorted this mess out for me ..... :P

One thing I'm thinking is that if you don't care about Z, and for texture mapping you mostly don't then the whole distortion thing doesn't matter it's only introduced by looking at the complete projection.

All I really want to know is what transform do Sesi use, I have most of it now but I'm still having to fudge the FOV value so something is definately missing. :(

Link to comment
Share on other sites

In case anyone was wondering what all this was about. Here is the result so far. It's a cop that lets you add depth map shadows in post.

It's WIP - I still need to add a softness control.

If anyone knows what the best way to do this is please let me know. I'm still researching it and there seems to be an a lot of different approaches.

To see what it's doing go to the cop editor and bypass any of the file sops that are called light1* you should see the shadow for that object magically dissappear. B)

Depth_composite.zip

Link to comment
Share on other sites

That's cool. All you're missing now is an option to output an alpha channel instead you that we can blur it for soft shadows. :thumbsup:

Could you also use autogen shadow maps? I wonder what space those maps are in. I guess you could always just look at the IFD.

Link to comment
Share on other sites

That's cool. All you're missing now is an option to output an alpha channel instead you that we can blur it for soft shadows. :thumbsup:

Could you also use autogen shadow maps? I wonder what space those maps are in. I guess you could always just look at the IFD.

17445[/snapback]

I've added soft shadows too now and alpha channel. see attached

I think it will work with autogen shadow maps - they just store the depth like Pz deep rasters do.

cop_shadows1000.zip

:)

Link to comment
Share on other sites

Indeed the quality parameter is specifying number of samples, although I do it like a convolution filter where the dimension of the filter is actually (quality + 1) x (quality + 1)

This gives better results although slower because it actually jitter the points around in the light space.

If you just want to blur the hard edge result set the quality and the softness to 0 and then blur the alpha channel and use it in a composite.

Link to comment
Share on other sites

Actually not so easily changed. You can't create planes in Vex (unless I'm missing something) so I'm stuck with the alpha solution.

17473[/snapback]

You can try connecting your image to a color COP, which should add an M channel.

then you can rename it with the rename COP

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...