View in #houdini on Slack
@theodox: Is there a way to turn a raw byte array into an image and/or a heightmap?
@bob.w: I know I you can build a heightmap from a raw float array with the engine API
But if you can convert to floats, you should be able to just make a heightmap and then wrangle those values into the points
probably even just in a python sop that reads a flat heightfield and your bytearray and just sets the points
Most of my heightmap generation work has been through HAPI.
Technically you can generate python bindings from the .thrift file they ship.
@theodox: In my case I’m looking for a speedup on large heightfields (say, 4096^2 x doubles) I can save a ton of time by shooting that to houdini via a named pipe – way, way faster than writing a file to disk and reading it back in – but then I have to actually construct the height field. I’m guessing a python for loop would eat up a lot of those gains…
That’s basically how I’m using HAPI, named pipe to the HARS process and then build the heightfield from the floats
Though I have to do some reordering to get the coordinates lined up properly between the two
@theodox: Is there a good source of example code for that approach?
I’m doing this to help somebody out, my main goal would be to provide a nice fenced off API that they could use without having to hit C++ all the time
@bob.w: I posted an example of the C++ code that I got working on the sidefx forum, but its out of date for the latest version of HAPI
Mostly I picked apart the SideFX UE4 plugin on how it handles landscapes
Though I’ve not looked at the most recent
HAPI_CreateHeightfieldInputVolumeNode is the primary function for creating the volume data from the float vector.
HAPI_SetHeightFieldData is then used to apply the floats
But there’s a bunch of incantation around it for building the various volume parts and other elements that make up a final heightfield node
And I can’t connect to my old machine, so I’m guessing IT probably murdered some of my old example code.
@theodox: I was sort of thinking that I could avoid redoing that work if there were a block byte->image conversion option
@ambrosiussen: @theodox, yes very easy in Python
@bob.w: whoohoo someone that knows more than me
with open(ExportFile, "rb") as file:
a = array.array('f')
(xres, yres, zres) = volume.resolution()
The above snippet is what I used to load .r32 images
Should be able to modify to suit your needs
@theodox: Cool! thanks!