Jump to content

Camera frustrum bounds for simulation


trebz7

Recommended Posts

Hello,

I am using Houdini 18.5 with the pyro sparse solver and simulating plane trails moving from point a to b.
When simulating first 100 frames it goes quite fast.. max 1 minute per frame but for the next 100 frames simtime is now almost 15 minutes per frame and I am only talking about 1 trail. Multiple will be added soon.

Problem is I actually don't need to simulate the areas where the camera does not see the trail. After 100 frames, over 50% of the trail is not even in the camera frustrum anymore. I was wondering if I can use some kind of dynamic bounds with the camera frustum. I only want it to process the data when seen by the camera. If the trail moves out of the camera frustrum it does not need to be simulated anymore. Not removing it after the simulation but while the simulation is necessairy to improve the speed.

Any hints?

Link to comment
Share on other sites

maybe it Helps
 

// accum the frame range

int sf = detail(1, "startFrame");
int ef = detail(1, "endFrame");
int npts = npoints(1);
// range loop our points , cal the weight of there camera matrices!
for(int i=0; i< npts ; i++)
{
    float mat[];
    mat = point(1,"mats", i);
    matrix mat44 = set(mat); 
    vector camP = @P * mat44;
    camP = normalize(camP);
    
    int condition1 = camP.x < -0.5 || camP.x > 0.5;
    int condition2 = camP.y < -0.4 || camP.y > 0.3;
    int condition3 = camP.z > 0;
    
    int condition = condition1 || condition2 || condition3  ;
    if(condition ) {
        @accum += 0;
    }
    else{
        @accum += 1;
    }
}

@accum = @accum / npts;
@Cd = @accum;
if(@accum <= 0) 
{
    removepoint(geoself(),@ptnum);
}

Python
 

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.

frameStart = node.parm("start").eval()
frameEnd = node.parm("end").eval()
fps = 24.0

# add detail attribute to save our frame range that is camera key range
geo.addAttrib(hou.attribType.Global, "startFrame", frameStart)
geo.addAttrib(hou.attribType.Global, "endFrame", frameEnd)

# get camera node:
camNode = hou.node("/obj/cam1")

matrix_list = []      # this is our camera matrix here
for frame in range(frameStart,frameEnd+1,1):
    time = float(frame)/ fps 
    camWorldMatrix = camNode.worldTransformAtTime(time).inverted()  # get camera at time!
    camWorldMatrix = camWorldMatrix.asTuple()
    matrix_list.append(camWorldMatrix)

# add a array attrib in every point, our point is our frame
geo.addArrayAttrib(hou.attribType.Point, "mats", hou.attribData.Float, 1)

for it in geo.iterPoints():
    ptnum = it.number()  # get point number , start with 0
    it.setAttribValue("mats", matrix_list[ptnum])

 

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