Hey guys,
I'm trying to understand why the normal map baked (in object space) by the Bake Material tag is different from the one that is baked by the the SDK (using the InitBakeTexture()
and BakeTexture()
functions) when they are seemingly both given the same parameters.
In both cases (the Bake Material tag and the SDK functions), these are my settings:
- Width: 1024
- Height: 1024
- Channel: Normal (active)
- Source (inside of the Normals sub-section): Object whose normals are being baked
- Method: Object (default)
The Base Material tag gives me this:
While the InitBakeTexture()
and BakeTexture()
functions give me this:
Unless I am wrong, the result yielded by the Bake Material tag seems to be the most accurate and favorable one (in terms of color spectrum). Am I wrong?
Here is an excerpt of my C++ code:
BaseContainer settings;
settings.SetInt32(BAKE_TEX_WIDTH, 1024);
settings.SetInt32(BAKE_TEX_HEIGHT, 1024);
settings.SetInt32(BAKE_TEX_PIXELBORDER, 0);
settings.SetBool(BAKE_TEX_CONTINUE_UV, true);
settings.SetBool(BAKE_TEX_USE_PHONG_TAG, true);
settings.SetVector(BAKE_TEX_FILL_COLOR, Vector(0.0));
settings.SetBool(BAKE_TEX_NORMAL, true);
settings.SetBool(BAKE_TEX_NORMAL_METHOD_OBJECT, true);
BAKE_TEX_ERR err;
BaseDocument* bakeDoc = InitBakeTexture(doc, (TextureTag*)textureTag, (UVWTag*)uvwTag, nullptr, settings, &err, nullptr);
// Check if initialization was successful
if (err != BAKE_TEX_ERR::NONE)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION, "Failed to initialize baking of the normal map."_s);
// Prepare bitmap for baking
MultipassBitmap* normalMap = MultipassBitmap::Alloc(1024, 1024, COLORMODE::RGBw);
if (!normalMap)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION, "Could not allocate normal map."_s);
// Perform the bake for the normal map
BakeTexture(bakeDoc, settings, normalMap, nullptr, nullptr, nullptr);
// File path of the normal map
maxon::Url urlNormalMapResult{ "file:///C:/filepath/normal_map.png"_s };
normalMap->Save(MaxonConvert(urlNormalMapResult), FILTER_PNG, nullptr, SAVEBIT::NONE);
Note: I am currently assigning the color mode RGBw
to normalMap
. I have experimented a lot in that area and I have not been able to find any other COLORMODE
or any other setting/enum for that matter that would get me closer to the normal map baked by the Base Material tag.
Any insight/guidance would be massively appreciated as always.
Thank you so much!