Jump to content

SOP Level Camera Frustum?


Nik S

Recommended Posts

Hey guys!

So I am doing a bunch of particle sims and want to kill the particles outside of the camera frustum's bounds. I could do this no problem if I could create geo matching the camera frust. Thing is, I'm not exactly sure how to create such geo. What comes to mind is matching a grid to the camera "far" attr then drawing lines from the camera origin to those 4 points of the grid then using a Skin Sop...

Has anyone done a tool like this in the past? Mind sharing your methods?

Thank you!! =)

- Nik

Link to comment
Share on other sites

Look into the toNDC node in VOPs. You pass it a camera and it passes back a vector representing where the input you gave it is in camera space. So it goes from world(x,y,z) to (horiz 0-1, vert 0-1, depth). In 12 though it has a bit of issues with multithreading so make sure you set your vop node to no threading unless you want it to randomly error out.

Link to comment
Share on other sites

You can try using the Volume SOP to group based upon the camera frustrum and z-depth you've set there (or linked to the camera attribute) as well. See the simple hack/example attached

Awesome! Exactly what I needed. Cheers.

Link to comment
Share on other sites

Hey guys!

So I am doing a bunch of particle sims and want to kill the particles outside of the camera frustum's bounds. I could do this no problem if I could create geo matching the camera frust. Thing is, I'm not exactly sure how to create such geo. What comes to mind is matching a grid to the camera "far" attr then drawing lines from the camera origin to those 4 points of the grid then using a Skin Sop...

Has anyone done a tool like this in the past? Mind sharing your methods?

Thank you!! =)

- Nik

camera_sop_vis_toodforce.hip

Link to comment
Share on other sites

I knew the community wouldn't let me down! Ended up going with the Volume Sop piped into a Volume Bound to get geometry which I use for some cool things (emission plane etc).

Tip: Add a Clip Sop in there to get a groundplane for your frustum.

:)

Edited by Nik S
Link to comment
Share on other sites

I knew the community wouldn't let me down! Ended up going with the Volume Sop piped into a Volume Bound to get geometry which I use for some cool things (emission plane etc).

Tip: Add a Clip Sop in there to get a groundplane for your frustum.

:)

I can't live without Frustum. Another cool trick i use is trail sop the frustum and you can get the bbox of the animated camera coverage.good emitter for weather effect where you are emitting only where you need . B)

  • Like 2
Link to comment
Share on other sites

kind of "old school" approach (using hscript expressions, etc),

but 1 fun tinkering project is to make your own "frustum" geo object,

wire your camera into it, start with a "box" SOP, UVtexture map it

from the perspective of that same camera, then stretch it using that mapping

in a "point" SOP using expressions referencing the camera channels like :

opparm /obj/frustum/point1/mapu ( '$MAPU + ch(opinputpath("../..",0)+"/winx")' )

opparm /obj/frustum/point1/tx ('($TX+ch(opinputpath("../..",0)+"/winx"))*(0.5/abs(ch(mapu)-0.5))')

...and so on (mapv & winy for ty, near & far for tz, etc)

This is not a complete example, but you'll make it your own! :)

Link to comment
Share on other sites

  • 6 years later...
On 8/1/2012 at 12:29 AM, Nik S said:

I knew the community wouldn't let me down! Ended up going with the Volume Sop piped into a Volume Bound to get geometry which I use for some cool things (emission plane etc).

Needed to group points inside camera frustum in SOPs (to remove instances not seen by camera), googled, ended up here. Found that Volume SOP ('From Camera') ---> Volume Bound SOP is an easy way to get a lightweight polygon version of the camera frustum. Used it as a bounding object (Peak SOP to enlarge a bit to include nearby instances for bounce light) in a Group SOP and voila, job done.

TLDR: +1 for Volume SOP ---> Volume Bound

Edited by limeforce
  • Like 1
Link to comment
Share on other sites

  • 3 months later...

agreed! : +1 for Volume SOP ---> Volume Bound

... seems the most complete And the simplest solution!

can even be made to react to "cam/winx" (for stereo convergence offset, etc)

unlike the Persistent Camera Frustum Handle described in   https://www.sidefx.com/forum/topic/38528/

though I'll always appreciate how "UV Texture" SOP's 'Perspective From Camera'  "@uv.z" = Depth from Camera (which is Also useful for particle Culling...)

'Perspective From Camera' UVs are what I used to build my frustum geo in the past (for example) ...

ml_cam_frustum_v01.hipnc

Link to comment
Share on other sites

  • 1 month later...
In a wrangle write:

v@ndcP= toNDC(chs("cam"),v@P);
float padding = chf("padding");
float nearclip = chf("nearclip");
if(v@ndcP.x > (1 + padding) || v@ndcP.x < (0 - padding) || v@ndcP.y > (1 + padding) || v@ndcpos12321.y < (0 - padding) || -v@ndcP.z < nearclip){
    removepoint(0,@ptnum);
}

 

click on the spare parameters and add the camera you wanna add.

  • Like 1
  • Thanks 3
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...