How to output BaseBitmap with ShaderData plugin
-
Hello PluginCafe!
I hope the title is self-explanatory.
Unfortunately, there is almost 0 info about ShaderData plugins on the forum.It is worth mentioning that I already figured out how to load textures into Xbitmap from the disk, but this is not exactly what I need.
Currently, I'm trying to somehow load Pre-Defined Bitmap image Xbitmap (or maybe I have to load it into Xbase) but with no luck.def InitRender(self, sh, irs) : bmp = (c4d.bitmaps.InitResourceBitmap(c4d.RESOURCEIMAGE_OK)) self.texture = c4d.BaseShader(c4d.Xbitmap) # Not sure but if I'm doing this correctly but probably here I need to somehow load my bmp. self.texture.InitRender(irs) return c4d.INITRENDERRESULT_OK def FreeRender(self, sh) : self.texture.FreeRender() self.texture = None def Output(self, sh, cd) : res = self.texture.Sample(cd) return res
-
Hi Merkvilson, thanks for reaching out us.
If the final intent is to simply get
BaseBitmap
information to be returned by your shader, rather than sampling aXbitmap
shader I suggest instead to simply query the color information by using BaseBitmap::GetPixel and eventually apply color space transformation.def Output(self, sh, cd) : x = int(cd.p.x * self.bitmap.GetBw()) y = int(cd.p.y * self.bitmap.GetBh()) col = self.bitmap.GetPixel(x, y) return c4d.Vector(float(col[0]/256.0), float(col[1]/256.0), float(col[2]/256.0))
Best, Riccardo