A float4 in OpenCL is laid out in memory as xyzw.
.lo refers to the front half of the vector, so xy, and .hi to the back half, or zw.
The same is with float16, so .lo is the first 8 floats in memory, and .hi the next 8 floats.
The second .hi / .lo then further grabs the first 4 floats or last 4 floats of those setups.
Thus .lo.lo refers to the FIRST four floats in memory. This is what would normally be called the "top row", row zero and columns zero through three. So I think OpenCL is already doing what you expected in VEX.
Found 392 posts.
Search results Show results as topic list.
Technical Discussion » Matrix formatting difference between VEX and OpenCL
-
- jlait
- 6696 posts
- Offline
Technical Discussion » Copernicus: How to do fisheye distortion?
-
- jlait
- 6696 posts
- Offline
The problem is we did too good a job making VEX easy to write :>
We've done a lot to make OpenCL less painful, so hopefully you can start to transition for Copernicus nodes.
Here's your code transformed to OpenCL, starting from the default OpenCL node...
Note the use of M_PI rather than PI. VEX also supports M_PI, and I'd recommend you get in the habit of M_PI as it is a lot more portable outside of VEX.
There is a lot more explicit boilerplate in OpenCL, thus the #bind commands to define your interface to the code.
One change you can make in both VEX and OpenCL is to use sinpi(). sinpi() is in 20.5 VEX and allows you to avoid needing to work with Pi. This isn't just an improvement in typing, but also is useful mathematically as PI/2 isn't an exact number, while sin(PI/2) is an exact number.
We are definitely missing all the nice helper functions that VEX has... You often have to go down to mix() or similar. fit01 is luckily present from interpolate.h, but a lot of your other gotos will be missing :<
This is my go-to for references for raw OpenCL functions.
https://www.khronos.org/files/opencl-1-2-quick-reference-card.pdf [www.khronos.org]
We've done a lot to make OpenCL less painful, so hopefully you can start to transition for Copernicus nodes.
Here's your code transformed to OpenCL, starting from the default OpenCL node...
#bind layer src? val=0 float #bind layer !&dst float @KERNEL { float ang = fit01(@src,0,M_PI/2); float result = @src * sin(ang); @dst.set(result); }
Note the use of M_PI rather than PI. VEX also supports M_PI, and I'd recommend you get in the habit of M_PI as it is a lot more portable outside of VEX.
There is a lot more explicit boilerplate in OpenCL, thus the #bind commands to define your interface to the code.
One change you can make in both VEX and OpenCL is to use sinpi(). sinpi() is in 20.5 VEX and allows you to avoid needing to work with Pi. This isn't just an improvement in typing, but also is useful mathematically as PI/2 isn't an exact number, while sin(PI/2) is an exact number.
#bind layer src? val=0 float #bind layer !&dst float @KERNEL { float ang = fit01(@src,0,0.5); float result = @src * sinpi(ang); @dst.set(result); }
We are definitely missing all the nice helper functions that VEX has... You often have to go down to mix() or similar. fit01 is luckily present from interpolate.h, but a lot of your other gotos will be missing :<
This is my go-to for references for raw OpenCL functions.
https://www.khronos.org/files/opencl-1-2-quick-reference-card.pdf [www.khronos.org]
Houdini Lounge » Houdini Color Schemes
-
- jlait
- 6696 posts
- Offline
It is very nice to see cool colour schemes being built despite the clunkiness of the current system.
As for the green line, I'm afraid I must report that colour isn't actually part of the schema :cry:
I've submitted Bug: 132255 regarding this, as we do not like such hard coded colours.
As for the green line, I'm afraid I must report that colour isn't actually part of the schema :cry:
if(myViewport->manager()->getViewportBorders()) { if(myViewport->manager()->isCurrentPort(myViewport->getPortIndex())) r->setColor(UI_Color(UT_RGB, 0.0F, 0.6F, 0.0F)); else r->setColor(UI_GREY20); r->rect2DS(x, y, x+w-1, y+h-1); }
I've submitted Bug: 132255 regarding this, as we do not like such hard coded colours.
Technical Discussion » Expression Short Circuiting
-
- jlait
- 6696 posts
- Offline
You are correct that VEX doesn't short circuit. I can't say we are happy with that, as it is very useful and expected to short circuit. I'd say we want to reserve the right to fix this some day, so please do not write code that requires us to not short circuit in the meantime.
Technical Discussion » Houdini recalculating every node when just pressing "save"
-
- jlait
- 6696 posts
- Offline
Thank you for the file. We can reproduce that, and it does seem very suspicious.
I've submitted a bug with internal tracking number 125726.
Thank you for reporting this!
I've submitted a bug with internal tracking number 125726.
Thank you for reporting this!
Houdini Lounge » Houdini 19 Visualize SOP
-
- jlait
- 6696 posts
- Offline
OdFotan
What's up with the Visualize SOP tho?
It's become more focused on setting up the various magic attributes to control visualization, rather than being a node to add visualizers.
Gear icon on the Top Right, Add Visualizer, Add Color Visualizer. This will get you the node-level visualizer it had by default before.
For the visualization to pass down-stream from the SOP you can click the "Update Visualizers" toggle. This will bake the visualizer into an attribute so any node down-stream will also visualize, useful if you are exporting this as another View Output from an HDA.
The actual code has stayed the same, it is the defaults we've changed.
Technical Discussion » How to get JSON formatted strings from Ramps
-
- jlait
- 6696 posts
- Offline
Ah, good point, the spline docs have not been updated. It uses the same underlying code as the Ramp, so thus in practice they will remain in sync.
18.5.605 will have ramp_lookup() working as expected, and adds ramp_pack to do the to-string operation if you need it.
18.5.605 will have ramp_lookup() working as expected, and adds ramp_pack to do the to-string operation if you need it.
Technical Discussion » How to get JSON formatted strings from Ramps
-
- jlait
- 6696 posts
- Offline
The ramp_lookup() for arrays is a wrapper around what used to be ramp_lookup in pyro_aaramp. That did a linear warp of the sample position into a uniform key distribution, and then sampled the ramp as if the keys were uniform. I'm guessing maybe the full key spline function wasn't present when that was written, and it "gets away" with it for many ramp types as the key spacing isn't important. But for bsplines it is pretty important!
Fortunately there is a workaround, rather than ramp_lookup() you can go directly to the spline function:
Hopefully we can fix ramp_lookup, but you probably want to use the spline() version for backwards compatibility in 18.5 for a while.
Fortunately there is a workaround, rather than ramp_lookup() you can go directly to the spline function:
y = spline(s[]@r_basis, x, f[]@r_val, f[]@r_key);
Hopefully we can fix ramp_lookup, but you probably want to use the spline() version for backwards compatibility in 18.5 for a while.
Houdini Indie and Apprentice » I can't import obj's
-
- jlait
- 6696 posts
- Offline
Apologies for the necro thread, I was seraching an unrelated issues ran into this post.
The offending program isn't qwavefront.exe, but should be gwavefront.exe.
A fair number of file formats are supported in Houdini by using standalone programs to do the conversion. gwavefront, gdxf, gply, etc. When houdini tries to read or write a .obj, it will instead launch this program to do the task. This is usually done with pipes so no files go to disk, but the gwavefront program doesn't know it was invoked by Houdini. Thus, it has to check for licenses to see it is allowed to run. This usually involves contacting hserver. In most configurations, this should be entirely local connections, which is why it will run normally unattached to the network. But it surprisingly difficult to separate local from external connections, which is probably why Zone firewall is tripping on it.
The offending program isn't qwavefront.exe, but should be gwavefront.exe.
A fair number of file formats are supported in Houdini by using standalone programs to do the conversion. gwavefront, gdxf, gply, etc. When houdini tries to read or write a .obj, it will instead launch this program to do the task. This is usually done with pipes so no files go to disk, but the gwavefront program doesn't know it was invoked by Houdini. Thus, it has to check for licenses to see it is allowed to run. This usually involves contacting hserver. In most configurations, this should be entirely local connections, which is why it will run normally unattached to the network. But it surprisingly difficult to separate local from external connections, which is probably why Zone firewall is tripping on it.
Technical Discussion » How Hscript and Expressions are different?
-
- jlait
- 6696 posts
- Offline
It isn't a stupid question.
hscript is a shell-like language, similar to csh or bash.
However, when you use back-ticks to escape it doesn't run shell commands, but a separate expression language. This is also the language that is used by default in parameters.
If you open a textport in Houdini (Windows::Textport) and type
3 + 2
it doesn't work because it tries to run the command 3
But
echo `3 + 2`
will invoke the expression language and evaluate 3+2.
I tend to call the expression language EXPR, but most people will just call it HScript. But I think it is simplest to think of there being Python VEX, Hscript, and Hscript Expressions as separate languages to learn. It is likely you don't have to learn HScript, only Hscript expressions, for example. Most of what hscript did is better done with python.
Our goal was to remove both Hscript and Hscript expressions and replace them with Python. Due to performance issues, however, HScript Expressions are likely to stick around.
hscript is a shell-like language, similar to csh or bash.
However, when you use back-ticks to escape it doesn't run shell commands, but a separate expression language. This is also the language that is used by default in parameters.
If you open a textport in Houdini (Windows::Textport) and type
3 + 2
it doesn't work because it tries to run the command 3
But
echo `3 + 2`
will invoke the expression language and evaluate 3+2.
I tend to call the expression language EXPR, but most people will just call it HScript. But I think it is simplest to think of there being Python VEX, Hscript, and Hscript Expressions as separate languages to learn. It is likely you don't have to learn HScript, only Hscript expressions, for example. Most of what hscript did is better done with python.
Our goal was to remove both Hscript and Hscript expressions and replace them with Python. Due to performance issues, however, HScript Expressions are likely to stick around.
Technical Discussion » pcsegment. How is it supposed to work?
-
- jlait
- 6696 posts
- Offline
An embarrassing bug!
Thank you for isolating & reporting this.
Hopefully 18.0.339 will work for you without the need for workarounds.
Thank you for isolating & reporting this.
Hopefully 18.0.339 will work for you without the need for workarounds.
Technical Discussion » New Paint SOP
-
- jlait
- 6696 posts
- Offline
pickled
Paint Attributes/Attribute Paint SOPs redundancy?
“Situation normal.”
I wanted “Tab->Paint<enter>” to get you the new paint sop. So it has to be called Paint Attributes in the tab menu for that. But the natural naming scheme for this is “Attribute Paint” to match the other Attribute prefixed nodes.
Of course, we allow typing names out of order in the tab menu, so whichever you type the other will show up… Best course would likely be to have only the highest-matching variant show up in the menu, but that will require a fair bit of extra metadata to tie the tools together.
Technical Discussion » Animated groups driving vellum simulations
-
- jlait
- 6696 posts
- Offline
In the vellumconstraintspropertiy it is bound to the Constraint primitives. Thus @PinSelection would read the primitive attribute on the constraint geometry, which likely isn't where you have your animated data.
This is why you likely want to use a point() expression to read from one of the other inputs, and set that input to the animated geometry. In particular,
stiffness = 1e10 * point(2, ‘PinSelection’, @ptnum);
would work if the Third Input (2) is set to point to the SOP that has the animated PinSelection attribute.
Note stiffness is exponential, so it will be pretty much on/off even for intermediate values of PinSelection like 0.5.
This is why you likely want to use a point() expression to read from one of the other inputs, and set that input to the animated geometry. In particular,
stiffness = 1e10 * point(2, ‘PinSelection’, @ptnum);
would work if the Third Input (2) is set to point to the SOP that has the animated PinSelection attribute.
Note stiffness is exponential, so it will be pretty much on/off even for intermediate values of PinSelection like 0.5.
Technical Discussion » Animated groups driving vellum simulations
-
- jlait
- 6696 posts
- Offline
The vellum constraint node is only run on the first frame. So it creates all the pin constraints on that first frame. The “Animated” flag adds an attribute that the target position to be updated, but will not re-create the pins. Thus it won't notice that the group has since changed. This might seem a pedantic separation when the group is “pins” as it seems trivial to re-evaluate membership in that group. But that generation group can be any arbitrary expression.
Since you created soft pins they exist as spheres on the Constraints geometry.
The easiest way to deactivate them is to set their stiffness to 0. You can do this in the vellumconstraintproperty DOP inside the forces tab.
The Animated Constraints help card example shows a setup reading in to a vellum constraints property. You could do similar with a vexpression of
stiffness = 1e10 * inpointgroup(2, “pins”, @ptnum);
and then set the Input 3 to point to where the pins group is animated.
Since you created soft pins they exist as spheres on the Constraints geometry.
The easiest way to deactivate them is to set their stiffness to 0. You can do this in the vellumconstraintproperty DOP inside the forces tab.
The Animated Constraints help card example shows a setup reading in to a vellum constraints property. You could do similar with a vexpression of
stiffness = 1e10 * inpointgroup(2, “pins”, @ptnum);
and then set the Input 3 to point to where the pins group is animated.
Houdini Indie and Apprentice » Delete empty attributes
-
- jlait
- 6696 posts
- Offline
Faster way might be to use nuniqueval/uniqueval to see if the string attribute has only blank strings in it. Can do it in a detail wrangle that builds up a detail string of attributes to delete that the attribute delete brings in with a details() expression. Bonus points is to wire your geometry to test to the *second* input of the detail wrangle so you have no copy costs for generating this.
Technical Discussion » Unstable Vellum Weld constraints
-
- jlait
- 6696 posts
- Offline
The peculiar behaviour of disableself may be found in the vellum attributes docs:
http://www.sidefx.com/docs/houdini/dyno/vellumattributes.html [www.sidefx.com]
The idea of how to use this to solve this case isn't in the docs. We're exploring how to make as a proper built-in, and will probably be adding an option to the vellum solver to auto-disable freshly broken welds.
One issue is that if your tear is pulling apart quickly, you don't want to auto-disable as it may cause layered cloth to fail.
http://www.sidefx.com/docs/houdini/dyno/vellumattributes.html [www.sidefx.com]
The idea of how to use this to solve this case isn't in the docs. We're exploring how to make as a proper built-in, and will probably be adding an option to the vellum solver to auto-disable freshly broken welds.
One issue is that if your tear is pulling apart quickly, you don't want to auto-disable as it may cause layered cloth to fail.
Technical Discussion » Overhead hit for fit vs. fit01?
-
- jlait
- 6696 posts
- Offline
In VEX:
In the EXPR world (expressions outside of VEX)
So it is just convenience.
#define CREATE_FIT01(TYPE) \ TYPE fit01(const TYPE val; const TYPE nmin; const TYPE nmax) \ { \ return fit(val, TYPE(0), TYPE(1), nmin, nmax); \ } CREATE_FIT01(float) CREATE_FIT01(vector2) CREATE_FIT01(vector) CREATE_FIT01(vector4) #undef CREATE_FIT01
In the EXPR world (expressions outside of VEX)
EV_START_FN(fn_fit01) { fpreal val = SYSfit(argv[0]->value.fval, 0, 1, argv[1]->value.fval, argv[2]->value.fval); EV_END_FN(val); }
So it is just convenience.
Technical Discussion » Can xyzdist VEX function be used on specific primitives without making a group per prim?
-
- jlait
- 6696 posts
- Offline
Groups can be ad hoc groups, so don't need to be created ahead of time.
So you can use the group “53” (note a string holding 53, not the integer 53) to find distance to primitive 53. sprintf(“%d”, primnum) can be used to generate such a group.
A big warning, however: internally it will have to create a group for all those primitives. So while it won't be as clunky, there may be more expense than you expect if every point creates a different group.
So you can use the group “53” (note a string holding 53, not the integer 53) to find distance to primitive 53. sprintf(“%d”, primnum) can be used to generate such a group.
A big warning, however: internally it will have to create a group for all those primitives. So while it won't be as clunky, there may be more expense than you expect if every point creates a different group.
Technical Discussion » Are volumes vertex-centered or cell-centered?
-
- jlait
- 6696 posts
- Offline
The samples of Houdini volumes are stored in the voxel centers. If you use volume slice, you will notice that it is half a voxel smaller than the original volume on each side as it is placing the generated points at the volume samples, not the corers of the voxels.
Technical Discussion » In a Point Wrangle, is there a way to mark a variable as only needing to be calculated once per cook, rather than once per point?
-
- jlait
- 6696 posts
- Offline
howiem
Or is the VEX compiler smart enough to recognise variables that won't change per-point, and just calc/cache them once?
Pretty much this.
There are three levels of computation:
1) Compile time
2) Once per point block (uniform)
3) For every point
If you have code like:
s@foo = sprintf("hello%d", 3);
The sprintf() will actually be computed at compile time.
If you have code like:
s@foo = sprintf("hello%d", ch("localparm"));
the ch() function has no per-point dependency, so will be marked uniform. Thus the sprintf() likewise will be uniform and only evaluated once per point-block. Point blocks are 1024 in size, so for almost all cases are pretty much equivalent to only evaluating it once outside the loop. It has to be pretty exceptional for me to consider pre-computing something rather than trusting the VEX compiler.
-
- Quick Links