I am trying to export SketchUp material. In the file …\SketchUpAPI\model\material.h, there is enum SUMaterialType with three material types.
/**
@enum SUMaterialType
@brief Indicates material type.
*/
enum SUMaterialType {
SUMaterialType_Colored = 0, ///< Colored material
SUMaterialType_Textured, ///< Textured material
SUMaterialType_ColorizedTexture ///< Colored and textured material
};
For the material type “SUMaterialType_Textured”, we only assign a texture onto a face. However, we still get color information from the function “SUMaterialGetColor()”. My question is what the color is? Is it calculated from the pixel of texture image file?
For the material type “SUMaterialType_ColorizedTexture”, we can assign a color and a texture onto a face. When calling the function “SUTextureWriteToFile()” to save the texture file, the color is also applied onto the image file. My question is: material has carried color information, why the color is applied to the image file during writing texture into disk file?
For the material type “SUMaterialType_Textured”, we only assign a texture onto a face. However, we still get color information from the function “SUMaterialGetColor()”. The question is what the color is? Is it calculated from the pixel of texture image file?
Do you know what the color is for the material type “SUMaterialType_Textured”?
Thanks for your detailed explanation. I am using the 2018 C SDK release (C API ver 6). I have no question about the function SUTextureGetAverageColor().
My question is:
For the material type “SUMaterialType_Textured”, we only assign a texture onto a face. However, we still get color information from the function “SUMaterialGetColor(), not from SUTextureGetAverageColor()”. My question is what the color got from SUMaterialGetColor() is? Is it calculated from the pixel of texture image file?
Hi,
I can’t see a reason for SUMaterialGetColor to return the average color for a textured-only material. Can you post a minimal code example that duplicates the issue?
I think I see what’s happening. When you set the texture on a material using SUMaterialSetTexture, the average texture color is applied to the material. So when you call SUMaterialGetColor, you get this average texture color back.
I don’t believe this is a bug. You can see this behavior in SketchUp’s UI as well. If you apply a textured material to a surface and edit that in-model material, you’ll see that it assumes the average texture color. So even if you remove the texture (i.e. check off ‘Use texture image’), the material color will remain somewhat close to the texture color. At least that’s what I believe was the rationale.
Thanks for your information. I agree with your point.
Maybe we can add some comments on the API SUMaterialGetColor() to tell SKP clients that what the color is when texture type is pure textured.
Thanks a lot again for your (@bugra@DanRathbun@tt_su) help. I have no questions about texture and materials.