Jump to content

Remove cloth objects outside camera frustum


gigafrax

Recommended Posts

hello guys, I wonder if somebody can help me with this.

I have to simulate a lot papers fliyng around and since cloth sim can be very computationally expensive, i was wondering if it is possible to stop simulating or removing the cloths that go outside the camera frustum.

In this case the camera is static, for a moving camera i guess i'll have to find different criteria, but it is a start, and i can learn a lot with the right input :)

 

there is also another problem: in the scene attached you can see that the cloths are emitted from a point on a grid, changin position at every frame. Sometimes two cloths are emitted so close to eachother that they overlap causing a permanent interpenetration. I was thinking of transferring color to the grid from the cloths previously emitted, to prevent the scatter point to be generated within the range set in the attribute transfer, but using a dop import in the second input of attribute transfer doesn't seems to work.

 

thanks in advance!

 

 

cloth_emitter.hipnc

Link to comment
Share on other sites

Hey, never tried this in a simulation but you may be able to edit the @active attribute for objects outside a certain group. What you can do at least for your camera frustum is:

1.  create a volume node.

2. In the volume node there is a tab to do Volume from camera. Switch to that, point to your camera in your object menu and change your z near to close to a smaller value so it is closer to the camera. And your z-far to however far away you want your objects to be. And increase your resolution of your volume to at least 100 because converting it later will slow down signicantly if you don't, (don't know why). Invert your volume.

3. Then what you want is to do a vdb convert and change "from fog to sdf", it WILL look weird and not right but it works.

4. Then just group based on volume, (this only works on points), if you want to do primitives you would have to lay a attrib wrangle down and say if(volumesample(0, 0, "P") > 0) {removeprim(0, @primnum); or something like that

 

5.   Then either delete the geo or in your dop sim, make your @active = 0 for objects grouped in your camera :)

6. If you are animating your camera, you will have to group your objects in a sop solver to get frame by frame evaluation.

CAMERA_DELETE.hiplc

Edited by Tyfx567
Link to comment
Share on other sites

Just looked into your scene. I made modifications to it so that this will work, however not sure how to cut off the actual cloth sim without an @active attribute. I've never done cloth sims in Houdini.  Also, if your cloth goes out of your camera view and then back in, you wouldn't see it once it is inside the camera. Your sim time isn't that long at all so I would just sim what you have without doing this camera grouping dealeo.  

GROUP_CAMERA.hipnc

Link to comment
Share on other sites

Thanks Tyler, that was exactly what i needed. The camera is not moving too much in the actual shot, or at least the cloths that go out don't go in again, so one problem is solved.

 

About the other issue about the emission? do you have any thoughts?

Link to comment
Share on other sites

For emitting part, don't scatter single new point with new seed every frame.

 

Do the scatter first, once for total number of cloth pieces that you will need. Let the Relax function of the new scatter do the work. Then with Blast SOP isolate single point. Use: `$F` expression in group parameter of Blast SOP to pick single point each frame.

Link to comment
Share on other sites

Ok cool, just curious.. how are you telling the cloths to stop simming? I am interested to know. As for the emission, I do not know off the top of my head that's why I didn't mention anything about that. Actually pezetko has a good idea. And just make your grid bigger may do the trick. :)

Link to comment
Share on other sites

I remove simulation points for flip, packed rbd and grains all the time, but never tried with cloth

 

try this in a multisolver

 

Lets say your camera is looking towards the origin and its at X 10, so delete all the points inside simulation whose position is  X > 14 , leave extra distance incase off camera objects are suppose to cast shado or sth

 

use this in an attributewrangle

 

if (@P.x > 14 ){   

removepoint(geoself(), @ptnum);

}

 

this will remove the points forever from during the simulation so they will not come back.

instead of an actual position you can group the points based on camera frustum also but unless your camera is doing crazy stuff, use the code above as it will be a lot more faster

Link to comment
Share on other sites

You can also check if all the points of the cloth object leaved camera frustrum (e.g. attribute promote to detail in Sop Solver DOP).

Then group (Group DOP) the objects that met this condition and delete all objects in this group (Delete DOP) as mentioned before.

 

I will add simple example at the end of the week.

Link to comment
Share on other sites

  • 2 weeks later...

There is simple example how to remove cloth pieces (H14) from simulation by deleting them when all its points leaves camera view.

 

(Near cloth piece hangs from points that are outside of camera view, so it's not possible to just delete points outside of camera view (It will change/break simulation)).

 

But be careful for lighting stage too. Cloth pieces could contribute to lighting/shadowing of the object inside camera view even if they are not directly visible.

 

 

pz_delete_cloth_outside_view.hipnc

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...