Jump to content

Writing attributes to image file


Recommended Posts

I feel like Houdini must be able to do this, but I can't figure it out...

I want to take a vector point attribute and write it out to a 16-bit image file. So for example, for point 0, my attribute @out_P has a value of {561.0, 981.0 ,1174.0 }. I want to create an image sized 256x256 pixels and write the first pixel value to be this value of @out_P. Second pixel is the @out_P value of point 1, and so on...

How would I go about doing this?

Link to comment
Share on other sites

5 hours ago, localstarlight said:

I feel like Houdini must be able to do this, but I can't figure it out...

I want to take a vector point attribute and write it out to a 16-bit image file. So for example, for point 0, my attribute @out_P has a value of {561.0, 981.0 ,1174.0 }. I want to create an image sized 256x256 pixels and write the first pixel value to be this value of @out_P. Second pixel is the @out_P value of point 1, and so on...

How would I go about doing this?

Just use GetAttribute VOP inside Vopcopfilter. Set Geometry File parm to op:/obj/mygeo/mysop and compute point number from current pixel index (IX+YRES*IY).

Alternative approach is to use sopGeo.pointFloatAttribValuesAsString() and cop.setPixelsOfCookingPlaneFromString() inside PythonCOP, but requires little Python magic (actually while stepping on a Python tail it might be easier to save, say, numpy array as image file (google it)). 

 

hth.

  • Like 5
Link to comment
Share on other sites

  • 7 months later...

Hey, I'm resurrecting this thread because while I must have got this working before (in August last year) I no longer seem to have the project file, and I can't figure it out.

I've attached a sample project file. I've scattered 128x128 points inside a sphere in 0->1 space and want to output the positions of these points as RGB values in a 128x128 texture.

The Get Attribute node doesn't seem to be pulling anything into the VOPCOP Filter, but I can't see why...

Side question: I want to export this data as a 16bit PNG file, but I can't see how/where I need to set that. Also, do the 0->1 values need to be scaled to something for a 16-bit output, or will 0->1 be stretched across all possible 16-bit values?

Any help massively appreciated!

PointsToPixels.hiplc

Link to comment
Share on other sites

Figured it out. I thought I could put the  (IX+YRES*IY) straight into the 'Point or Primitive' attribute on the Get Attribute node inside the VOP COP filter, but as it turns out that was always resolving to zero. I just needed to build the sum using nodes inside the VOP COP.

Got it working now.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
On 3/3/2018 at 6:23 AM, localstarlight said:

Figured it out. I thought I could put the  (IX+YRES*IY) straight into the 'Point or Primitive' attribute on the Get Attribute node inside the VOP COP filter, but as it turns out that was always resolving to zero. I just needed to build the sum using nodes inside the VOP COP.

Got it working now.

Hey,

I'm trying to export a 16-bit png heightmap, but I can't seem to find where to set the bit depth. As far as I know, when I import the heightmap into UE4 it reads it in as an 8-bit image. You said you figured it out, where's the setting? It's driving me nuts. I should mention I'm running Houdini Apprentice, so perhaps there's a depth limit? I wouldn't think so, though, as you can export exr..

 

Thanks,

CW

Link to comment
Share on other sites

So I figured it out finally. Had I done just five more minutes of testing, I wouldn't have had to ask! 

Originally I was exporting the heightmap out of COPs which was suggested in a video. However, using the heightfield_output node, you can specify "type", which I set to 16b Fixed, and "Single channel", auto remapped. And it worked flawlessly. Hope that may help somebody!

 

CW

Link to comment
Share on other sites

  • 3 weeks later...

Hello!

Since I have not seen a hip file for the solution to this problem yet, I've felt the need to post it.
There were a couple of major things missing from localstarfights' file, namely correct addressing of the SOP to read the attributes from.
Thanks to the people of this thread for letting me know this was even possible!

attribexport.hip

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