BaseMaterial::GetAverageColor() whoes
-
On 27/02/2013 at 09:45, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;---------
Hi there!We have a custom exporter and recently tried to add a function that adds an average color of the color texture to our files for every material, so we can have a simplified representation that automatically somewhat resembles the fully detailed version. The materials we have are just the CINEMA 4D standard material and the color channel really only contains a simple Bitmap Shader.
For that, we thought the BaseMaterial::GetAverageColor() function would come in handy, but we ran into a bunch of problems with it:
(1) Calling BaseMaterial::GetAverageColor(CHANNEL_COLOR) just returns grey (0.5, 0.5, 0.5). Not sure where that is coming from, it's neither in the texture, nor is the plan color set to that value.
(2) Using BaseMaterial::GetAverageColor() returns a color that seems to make sense, but in the tests I made it was in sRGB. Converting back to linear worked fine for the cases I tried, but I don't feel well relying on that.Any ideas? Did anybody else try something similar?
Best
Timm -
On 28/02/2013 at 01:37, xxxxxxxx wrote:
Ha, I just realized, that this is perfectly in line with what the documentation says about color profiles, so I guess 2 is fine. I am still wondering about 1, though...
-
On 01/03/2013 at 02:59, xxxxxxxx wrote:
OK, does anybody actually know what the function is doing exactly? Now I also have cases where the same material seems to produce different values in different scenes. I guess it's some kind of side effect from something else in the scene, but I have no clue what it could be. It's definitely not color space, I checked that. Anybody?
-
On 02/03/2013 at 08:10, xxxxxxxx wrote:
Hi,
In my tests GetAverageColor() just does not work in most cases.
Most times you just get [0.5,0.5,0.5] gray back.
So apparently the only way is to create own function that will do this.Returns an average color for the material, based on the material preview.
This is also strange too, if this is correct then this function is using material preview to calculate average color.
But this is not the same as to use bitmap from GetPreview().Remo
-
On 06/04/2013 at 06:05, xxxxxxxx wrote:
Her is the function that seems to work better.
Of course it can be improved a lot.https://github.com/PluginCafe/Cinema-4D-Code-Collection/blob/master/C%2B%2B/Remo/SamplerRemo.h
Sampler::AverageColor()