Found 33 posts.
Search results Show results as topic list.
Technical Discussion » Running Python 3 scripts in Houdini as a Subprocess
- GrahamDClark
- 51 posts
- Offline
PDG/TOPs » USD import lops, arrays dif lengths points vertex, TOP way?
- GrahamDClark
- 51 posts
- Offline
EDIT#4: Yes I keep editing it, and talk to myself.
I have a python script that iterates over USD curves and their point attributes and does various stuff with them.
Trying to migrate that script to TOPs has been frustrating as I don't really get how to assemble the data to then run over it using mostly TOPs vs mostly Python.
So with Geometry Import TOP we get elements and the attributes at least come in as P 0.0,1.0,0.0 etc but even then I'd need to make worktimes or maybe partions for each subcurve.
With USD import TOP I can expand curveVertexCounts to get a workitem per subcurve of the basis curve. But that Expand breaks my by frame serial loop (serial because I'm driving other apps per frame).
1. I don't see a way to unflatten the points to subcurves, and then a set of 3 for xyz, using TOPs, just via python see below example script. Not an issue just curious as I would have thought there was a TOPs way. Do we correlate points of subitems to their element attributes using python, or is their a TOPS way (especially in a serial loop with multiple prims and subcurves?
2. The issue is that Expand TOP wont work when going over a frame range using partition by frame TOP for a serial loop TOP, so I have to revert to enumerating over the subcurves and then extracting its points inside a Python Script TOP. I was hoping to be able to have a TOPs loop over frames and inside a TOPs loop over subcurves. I've tried putting the expand TOP inside and outside of loop, guessing we cant have a loop based on a parition by subcurve work_items inside a loop based on partition by frame.
I would like to try to get this working in TOPs, as I think, like my setups in Touchdesigner, having a nodal tool structure offers a lot of speedy flexibility.
I have a python script that iterates over USD curves and their point attributes and does various stuff with them.
Trying to migrate that script to TOPs has been frustrating as I don't really get how to assemble the data to then run over it using mostly TOPs vs mostly Python.
So with Geometry Import TOP we get elements and the attributes at least come in as P 0.0,1.0,0.0 etc but even then I'd need to make worktimes or maybe partions for each subcurve.
With USD import TOP I can expand curveVertexCounts to get a workitem per subcurve of the basis curve. But that Expand breaks my by frame serial loop (serial because I'm driving other apps per frame).
1. I don't see a way to unflatten the points to subcurves, and then a set of 3 for xyz, using TOPs, just via python see below example script. Not an issue just curious as I would have thought there was a TOPs way. Do we correlate points of subitems to their element attributes using python, or is their a TOPS way (especially in a serial loop with multiple prims and subcurves?
2. The issue is that Expand TOP wont work when going over a frame range using partition by frame TOP for a serial loop TOP, so I have to revert to enumerating over the subcurves and then extracting its points inside a Python Script TOP. I was hoping to be able to have a TOPs loop over frames and inside a TOPs loop over subcurves. I've tried putting the expand TOP inside and outside of loop, guessing we cant have a loop based on a parition by subcurve work_items inside a loop based on partition by frame.
I would like to try to get this working in TOPs, as I think, like my setups in Touchdesigner, having a nodal tool structure offers a lot of speedy flexibility.
# Executes a Python script, either in process or as a job import numpy as np # Get curveVertexCounts and points attributes curves = work_item.attrib("curveVertexCounts").values points = work_item.attrib("points").values # Calculate the starting and ending indices for the points of the current subcurve start_idx = int(3 * np.sum(curves[:work_item.index])) end_idx = int(3 * np.sum(curves[:work_item.index + 1])) # Extract the points for the current subcurve subcurve_points = points[start_idx:end_idx] # Print the results print("Subcurve: ", work_item.index) #print("curveVertexCounts: ", curves) #print("points: ", points) print("Subcurve points: ", subcurve_points)
Edited by GrahamDClark - April 23, 2023 22:13:58
Solaris and Karma » Retime USD
- GrahamDClark
- 51 posts
- Offline
thank you! will stick with the python and try your suggestion to avoid hou.frame() (and better as i mod it for files).
Solaris and Karma » Retime USD
- GrahamDClark
- 51 posts
- Offline
Thanks Nick and Mark, I tried a ridiculously slow and super dumb thought exercise with for loop lops that at least worked, then saw this thread and your answers and tried to mod Nicks code to usd retime by attrib. Any recommendations to make it better/more correct?
I would drive the 'timey' attribute by distance or something. And so I think I excluded 'timey' from being also updated in the python. It still gets slow on lots of stuff. Could I vex it for speed?
I would drive the 'timey' attribute by distance or something. And so I think I excluded 'timey' from being also updated in the python. It still gets slow on lots of stuff. Could I vex it for speed?
Edited by GrahamDClark - April 18, 2023 02:44:59
Houdini Lounge » Chat GPT and Houdini
- GrahamDClark
- 51 posts
- Offline
___________ ___________ | Sphere | | Grid | | SOP | | SOP | |type:poly | |___________| |rad:0.5 | | |scale:exp | v |___________| ___________ | | Wrangle | | | SOP | | | @thing | | |___________| | | | v | ___________ | | For Each | | | Point | | | Loop | | | SOP | | |___________| | | | | v v ___________ | Copy | | SOP | |___________| | | v ___________ | foreach_end | | SOP | |___________ | Expression for scale parameter in Sphere SOP: point("../foreach_begin1", 0, "thing", 0) Wrangle SOP vex expression: @thing = rand(@ptnum);
apologies for the misunderstanding. Here's an ASCII diagram to represent the process: +------------+ +-----------+ +----------+ | fontList.txt |----->| fontList | | text.txt |----->| text | +------------+ +-----------+ +----------+ /\ / \ / \ +-----------+
Technical Discussion » Getting the camera to screen matrix
- GrahamDClark
- 51 posts
- Offline
Mario MarengoThank you I was killing myself to get x y in camera in python in Houdini and chatbot gpt-4 wasn't saving me until I gave it your method!
As I understand it, yes, you can represent the NDC transform as a matrix, but to do anything useful with that matrix, you'll need to work in homogeneous coordinates.
def calculate_ndc(point, focal, aperture, resx, resy, aspect, near, far, Mcam): # Convert point to homogeneous coordinates point_h = np.array([point[0], point[1], point[2], 1]) # Define the NDC matrix f = focal / aperture a = resy / (resx * aspect) b = (far + near) / (far - near) c = (2.0 * far * near) / (far - near) Mndc = np.array([[f, 0, 0, 0], [0, f / a, 0, 0], [0, 0, b, -1], [0, 0, c, 0]]) # Transform the point to camera space and then to NDC space point_h = point_h.dot(Mcam).dot(Mndc) # Convert back to Cartesian coordinates Pndc = np.array([point_h[0] / point_h[3], point_h[1] / point_h[3], point_h[2] / point_h[3]]) # Add 0.5 to x and y to get the final NDC coordinates Pndc[0] += 0.5 Pndc[1] += 0.5 return Pndc
Edited by GrahamDClark - April 2, 2023 19:16:44
Houdini Indie and Apprentice » Set external script editor not working
- GrahamDClark
- 51 posts
- Offline
molderThank you!
EDITOR = “C:/Users/XXXX/AppData/Local/Programs/Microsoft VS Code/Code.exe”
Set external editor crashes Houdini after file browser pops up briefly. Just setting it in the houdini.env file worked, thank you.
Solaris and Karma » [RESOLVED]usd_getbbox Vex functions return Huge incorrect values
- GrahamDClark
- 51 posts
- Offline
Solaris and Karma » [RESOLVED]usd_getbbox Vex functions return Huge incorrect values
- GrahamDClark
- 51 posts
- Offline
not resolved here, same issue.
opened your .hip file, changed it to "Proxy" and still get same error. Was there something else you set to make it work?
I get same error with all the usd bbox functions
opened your .hip file, changed it to "Proxy" and still get same error. Was there something else you set to make it work?
I get same error with all the usd bbox functions
Edited by GrahamDClark - March 24, 2023 01:27:41
Solaris and Karma » toNDC() function for USD Cameras
- GrahamDClark
- 51 posts
- Offline
edit: sorry I posted wrong code.
thanks again David
thanks again David
//thanks David Krepelka!!! modified camera culling to flatten_to_CAM_9hole int n = usd_attriblen(0, @primpath, "points"); // make sure to have the mesh set under "Primitves" so @primpath works vector pos[] = usd_attrib(0, @primpath, "points"); //string campath = chs("camera"); // select the camera primitive string campath = ch("`opinputpath(".", 1)`"+“/primpath”);//pipe camera into second wrangle input (and must be somewhere upstream in first input). maybe fudgy? matrix mcam = usd_worldtransform(0, campath); matrix mprim = usd_worldtransform(0, @primpath); float focal = usd_attrib(0, campath, "focalLength"); float hap = usd_attrib(0, campath, "horizontalAperture"); float vap = usd_attrib(0, campath, "verticalAperture"); for(int i=0; i<n; i++){ vector pprim = pos[i] * mprim; vector pcam = pprim * invert(mcam); // get point positions into camera space float xcam = (focal * pcam.x / (hap/2))/pcam.z; float ycam = (focal * pcam.y / (vap/2)/(hap/vap))/pcam.z; pcam = set(-xcam,-ycam,pcam.z); pcam.z *= 0; pcam.z-=1; //seems really dumb to just reverse above, better way? pcam.x= ((-pcam.x*focal)*(hap*2))*pcam.z; pcam.y= ((-pcam.y*focal)*(vap*2)*(hap/vap))*pcam.z; pcam = pcam * mcam; pcam = pcam * invert(mprim); usd_setattribelement(0, @primpath, "points", i, pcam); }
Edited by GrahamDClark - March 23, 2023 22:30:38
Solaris and Karma » toNDC() function for USD Cameras
- GrahamDClark
- 51 posts
- Offline
Solaris and Karma » layout > sopmodify instances in worldspace
- GrahamDClark
- 51 posts
- Offline
Hi thank you for the quick response, much better than the extract instances solve I finally got working and was crashing previously in a full scene.
Yes on the pattern editor, will use that lots now.
Yes on the pattern editor, will use that lots now.
Solaris and Karma » layout > sopmodify instances in worldspace
- GrahamDClark
- 51 posts
- Offline
layout > sopmodify works on the prototypes but I cannot get it working on the instances.
attached is a really silly example trying to just move points up in y 1 unit.
sorry for my basic understanding of usd.
attached is a really silly example trying to just move points up in y 1 unit.
sorry for my basic understanding of usd.
Edited by GrahamDClark - Jan. 31, 2023 03:59:58
Solaris and Karma » Karma XPU failure on 3090ti
- GrahamDClark
- 51 posts
- Offline
briansThank you!!!
We were getting more certain it was a driver issue, introduced sometime after 495.89, and were attempting to narrow it down to get some information back to NVidia (proving a little difficult given it exhibited heisenbug behavior). But the most recent driver (526.86) is working fine for us. So hearing it's working fine for you too gives me confidence this bug may have been fixed (or at least crawled back under its rock).
Brian
I was going crazy trying to resolve this as well.
@Alpha plus velocities wasn't working with Karma XPU until new nvidia driver. Now it is
I have though run into an issue whereby lots geometry with alpha and large velocities still fails to render opacity with the addition of a volume. Will try to narrow it down.
Houdini Lounge » primitive properties lookat
- GrahamDClark
- 51 posts
- Offline
Awesome, always loved your site and MOPs.
I changed one part so the prims faced the target more and the geo could be moved.
Thank you again, hours of pain lifted.
I changed one part so the prims faced the target more and the geo could be moved.
//vector target = normalize(point(1, "P", 0)); vector p0 = point(1,'P',0); vector target =normalize(p0-@P);
Thank you again, hours of pain lifted.
Image Not Found
Edited by GrahamDClark - Dec. 12, 2022 18:21:01
Houdini Lounge » primitive properties lookat
- GrahamDClark
- 51 posts
- Offline
How do you point primitives towards another object?
I've tried with primitive properties look at and my badly formed vex.
Sorry I'm sure that I am missing the obvious.
I've tried with primitive properties look at and my badly formed vex.
Image Not Found
Sorry I'm sure that I am missing the obvious.
Edited by GrahamDClark - Dec. 12, 2022 16:47:34
Technical Discussion » setdetailattribute min
- GrahamDClark
- 51 posts
- Offline
tamteThank you!!! I had this set in an upstream wrangle but still had rounding, putting it in same wrangle fixed. thanks
adddetailattrib(0, 'speed_min', 1e10);
Solaris and Karma » [LOP instancer] Crashing on Point Attributes to Copy
- GrahamDClark
- 51 posts
- Offline
Hey thanks Rob, yeah got it for CPU Karma, makes sense.
Also made me realize why I couldn't get the instancer working with XPU going back and using SOP indexes. That works for me now too.
Thanks so much for your help and the file!!
Also made me realize why I couldn't get the instancer working with XPU going back and using SOP indexes. That works for me now too.
Thanks so much for your help and the file!!
Solaris and Karma » [LOP instancer] Crashing on Point Attributes to Copy
- GrahamDClark
- 51 posts
- Offline
Doesn't crash for me in 19.0.431, the attribute is there on the Source Primitive, but I cannot find a way to successfully have it on the instances.
Even using primvar displayColor won't color instances.
Any pointers to get it working greatly appreciated.
Even using primvar displayColor won't color instances.
Any pointers to get it working greatly appreciated.
Technical Discussion » Canning animation for Copy SOP
- GrahamDClark
- 51 posts
- Offline
DavidRindnerModeling for Digital Visual Effects and Animation
Thanx.
To put it mildly, I don't get it. I don't understand this tutorial at all.
Makes no sense to me whatsoever. I tried to match his settings, but its not working at all. Completely muddy.
DR
that's got to be the funniest review for a tutorial I've ever had. Thanks David I put the review up on my site : )
good you figurd out a way to get your project done
-
- Quick Links