
Jeff Lait
jlait
About Me
EXPERTISE
Developer
Connect
LOCATION
Not Specified
WEBSITE
Houdini Skills
Availability
Not Specified
My Badges
SideFX Staff
Since Jul 2005
My Tutorials
Recent Forum Posts
COPS - how to convert SLOPE cop output to RGB ? Sept. 15, 2025, 3:02 p.m.
We have some default "visualizers" to help view data types that otherwise would not be visible. Having negative directions all go black isn't very helpful for telling how things will swirl.
Unfortunately, we don't have a Bake Visualizer node, so it is hard to get a rendered output of what you see for things like SDFs and Vector2s.
The code is pretty simple - it projects onto a hexagone in RGB space and then scales by the length of the vector.
In the attached I've copied the code from our visualizers verbatim so should get the same result.
Unfortunately, we don't have a Bake Visualizer node, so it is hard to get a rendered output of what you see for things like SDFs and Vector2s.
The code is pretty simple - it projects onto a hexagone in RGB space and then scales by the length of the vector.
In the attached I've copied the code from our visualizers verbatim so should get the same result.
Matrix formatting difference between VEX and OpenCL Jan. 6, 2025, 11:17 a.m.
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.
.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.
Copernicus: How to do fisheye distortion? Aug. 9, 2024, 11:33 a.m.
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]