# Some questions about Textured material and ColorizedTexture material

**URL:** <https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143>\
**Category:** SketchUp SDK\
**Created:** [July 21, 2016, 8:25am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143 "2016-07-21T08:25:08Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinwhp](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@justinwhp](https://forums.sketchup.com/u/justinwhp)\
**Post date:** [July 21, 2016, 8:25am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/1 "2016-07-21T08:25:08Z")

</div>

Hi Experts,

I am trying to export SketchUp material. In the file …\SketchUpAPI\model\material.h, there is enum SUMaterialType with three material types.

```auto
/**
@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?  
 ![](https://global.discourse-cdn.com/sketchup/original/3X/6/9/698b9e6ec3b364ba78f7f0c168466f3ff3503d5c.jpg)

---

<div class="post-metadata">

**Author:** ![xqtyler](https://avatars.discourse-cdn.com/v4/letter/x/8e8cbc/32.png) [@xqtyler](https://forums.sketchup.com/u/xqtyler)\
**Post date:** [June 19, 2018, 7:21am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/2 "2018-06-19T07:21:01Z")

</div>

I have the same questions. Who can answer the question?

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [June 19, 2018, 3:50pm UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/3 "2018-06-19T15:50:14Z")

</div>

A search of the developer categories on this subject:

- [_search:_ `"colorize texture category:12"`](https://forums.sketchup.com/search?q=colorize%20text%20category%3A12)

_… finds …_

> [@About colorized textures](https://forums.sketchup.com/t/about-colorized-textures/2381/2):
>
> SketchUp’s Ruby API bakes non-affine (quadrilateral) texture transformations and color modifications into the exported images. This is because many file formats and external applications might not support these features the same way as SketchUp does. There is unfortunately not much control over this. SketchUp supports two ways to adjust a material’s appearance, so-called colorize types: Colorization will turn all pixels monochrome in one single color tone with only variations in brightness. …

> [@How does colorised texture work?](https://forums.sketchup.com/t/how-does-colorised-texture-work/51168/5):
>
> We should probably document this in a page in the documentation. Let start here in making the first attempt - let me know if you need more details. (EDIT: We now have documented it: [GitHub - SketchUp/sketchup-colorize-algorithm: Explanation of SketchUp's colorization algorithm](https://github.com/SketchUp/sketchup-colorize-algorithm)) SketchUp perform two types of color adjustments: If you set a material color for a textured material via the Ruby API’s Sketchup::Material.color= it sets the type to Sketchup::Material::COLORIZE\_TINT. You can toggle…

---

<div class="post-metadata">

**Author:** ![xqtyler](https://avatars.discourse-cdn.com/v4/letter/x/8e8cbc/32.png) [@xqtyler](https://forums.sketchup.com/u/xqtyler)\
**Post date:** [June 20, 2018, 1:34am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/4 "2018-06-20T01:34:26Z")

</div>

Hi Dan,

For Colorized texture, I have no questions.

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”?

---

<div class="post-metadata">

**Author:** ![xqtyler](https://avatars.discourse-cdn.com/v4/letter/x/8e8cbc/32.png) [@xqtyler](https://forums.sketchup.com/u/xqtyler)\
**Post date:** [June 20, 2018, 2:27am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/5 "2018-06-20T02:27:52Z")

</div>

According to Ruby API document, the answer is yes. Please see the link:

> **[Class: Sketchup::Material](https://ruby.sketchup.com/Sketchup/Material.html#color-instance_method)**
>
> The Material class represents a texture or color that can be applied to Drawingelements.

I assume the C API should be the same.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [June 20, 2018, 4:30pm UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/6 "2018-06-20T16:30:12Z")

</div>

> [@xqtyler](#):
>
> 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”?

And the Ruby API doc says …

> If it uses a Texture, this will return the **average** color.

So yes, there is some calculation going on.

> [@xqtyler](#):
>
> I assume the C API should be the same.

I can say that API “parity” is a public stated goal of the Extensibility Team of the SketchUp Development group.

In the thread I referenced (you should read it in it’s entirety,) Thomas gives pseudo code and refers to the Ruby API method …

- [`Sketchup::Texture#average_color()`](http://ruby.sketchup.com/Sketchup/Texture.html#average_color-instance_method)

He also talks about the C API lacking some functions in this regard back in September of 2017, just before the 2018 version came out.

**But** then in the `"version.txt"`of the C API SDK is listed a new function for ver **6** ( **2018** ,) released in November of 2017, we have listed …

- `SUTextureGetAverageColor()`

So it appears that it did make it into the 2018 C SDK release (C API ver 6.)

---

<div class="post-metadata">

**Author:** ![xqtyler](https://avatars.discourse-cdn.com/v4/letter/x/8e8cbc/32.png) [@xqtyler](https://forums.sketchup.com/u/xqtyler)\
**Post date:** [June 21, 2018, 1:56am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/7 "2018-06-21T01:56:06Z")

</div>

Hi Dan,

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?

Thanks

---

<div class="post-metadata">

**Author:** ![bugra](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/bugra/32/33481_2.png) [@bugra](https://forums.sketchup.com/u/bugra)\
**Post date:** [June 21, 2018, 12:48pm UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/8 "2018-06-21T12:48:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bugra](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/bugra/32/33481_2.png) [@bugra](https://forums.sketchup.com/u/bugra)\
**Post date:** [June 21, 2018, 12:54pm UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/9 "2018-06-21T12:54:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [June 21, 2018, 3:05pm UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/10 "2018-06-21T15:05:26Z")

</div>

> [@bugra](#):
>
> 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.

Yup, you’ll also see the colour change in the UI.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [June 21, 2018, 3:16pm UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/11 "2018-06-21T15:16:57Z")

</div>

So the question that follows is, is this expected behavior or is it a bug ?

---

<div class="post-metadata">

**Author:** ![xqtyler](https://avatars.discourse-cdn.com/v4/letter/x/8e8cbc/32.png) [@xqtyler](https://forums.sketchup.com/u/xqtyler)\
**Post date:** [June 25, 2018, 8:33am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/12 "2018-06-25T08:33:07Z")

</div>

@bugra @DanRathbun and @tt_su Have any conclusion for the question “Is this expected behavior or is it a bug”?

---

<div class="post-metadata">

**Author:** ![bugra](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/bugra/32/33481_2.png) [@bugra](https://forums.sketchup.com/u/bugra)\
**Post date:** [June 25, 2018, 1:08pm UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/13 "2018-06-25T13:08:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xqtyler](https://avatars.discourse-cdn.com/v4/letter/x/8e8cbc/32.png) [@xqtyler](https://forums.sketchup.com/u/xqtyler)\
**Post date:** [June 27, 2018, 5:53am UTC](https://forums.sketchup.com/t/some-questions-about-textured-material-and-colorizedtexture-material/28143/14 "2018-06-27T05:53:19Z")

</div>

Hi @bugra,

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.
