How to sample material/texture

   1266   1   0
User Avatar
Member
2 posts
Joined: Feb. 2022
Offline
Hi

In the last days I'm looking in the c++ sdk to find how to semple a material and a texture.
The idea is quite simple giving in input uv get color sample from material or a texture.
  1. A SOP node I think is not the right way because its aiming to modify or generate geometry
  2. A VOP node as well I don't think because I'm looking for the shader result not to the shader it self
  3. A VEX script? Create a vex node, place it in the graph only to store the material reference, really?
I'm a little confused and the examples doesn't help me.
Thanks
User Avatar
Member
2 posts
Joined: Feb. 2022
Offline
About how to fetch a texture the best way I found is to retrieve an ImageHandle from ImageCache

virtual ImageHandle* ImageCache::get_image_handle(ustring filename,Perthread * thread_info = NULL )

and then use the handle to get the pixels

virtual bool get_pixels (ImageHandle *file, Perthread *thread_info, int subimage, int miplevel, int xbegin, int xend, int ybegin, int yend, int zbegin, int zend, int chbegin, int chend, TypeDesc format, void *result, stride_t xstride=AutoStride, stride_t ystride=AutoStride, stride_t zstride=AutoStride, int cache_chbegin=0, int cache_chend=-1)=0

is this the fastest way?

Thanks
Edited by sukoy - Feb. 4, 2022 04:47:14
  • Quick Links