[Closed] Baking out a texmap with EvalColor
I’m working on a renderer for Max and as a part of this I have created some functionality to bake out a bitmap from a Texmap, using the values returned from evalColor.
It largely works as expected but a few of the texmap types seem to bake out incorrectly, sometimes being a solid color or a very light gradient instead of matching how it is displayed in the preview.
I have a feeling there is a problem in the ShadeContext subclass I made to support this, but I’m not sure where to look for it. As far as I can tell, I’m returning a reasonable value from each of the functions that are part of ShadeContext, but I’m not getting the values I expect from evalColor.
Has anyone here made something like this before? Any ideas on where I might be going wrong?
Ok, I seem to have solved this to some degree by using the Texmap’s RenderBitmap function rather than EvalColor.
The problem I’m running into with this approach is that it seems to lack HDR float support.
For reference, here is exactly what I’m doing to create the bitmap.
BitmapInfo bi;
bi.SetType(BMM_FLOAT_RGBA_32);
bi.SetWidth(width);
bi.SetHeight(height);
bi.SetFlags(MAP_HAS_ALPHA);
bi.SetCustomFlag(0);
Bitmap* bitmap = TheManager->Create(&bi);
if (bitmap == nullptr) {
return;
}
texmap->RenderBitmap(t, bitmap);
Even when using an HDR bitmap as the source, the output of RenderBitmap doesn’t have any RGB values over 1.0. Is there a flag I’m missing somewhere that I need to set?
I ended up sorting this out on my own and wanted to post my terrible solution here in case anyone is interested.
To work around this I call Texmap::RenderBitmap as described in my previous post, but with a very low resolution. After a bitmap of any size has been created through Texmap::RenderBitmap, Texmap::EvalColor begins to work as expected again.
I’m not entirely sure why, but this is a good enough solution for now.