Page 1 of 1
color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Tue Nov 10, 2020 11:54 am
by bartek_zgo
Hi, Guys
I want to convert standard RGB color (0-255 range) to LuxCore 0-1. I was trying to simply divide by 255. But the color I get in the render is completely different. Than I have made some simple test using Blender. A set some random color make print screen, copy to Paint, make a color pick and I got completely different values. So the color is the same, but Red is 0.216*255 = 55 but Paint is giving me 128.
So my simple question is. I have a color (128, 10, 55). Ho to convert the values to LuxCore system?
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Tue Nov 10, 2020 12:44 pm
by bartek_zgo
Or maybe I have a wrong approach. It looks like blender is applying gamma correction about 2.2 to color conversion ( (x / 255)^2.2) gives quite similar results.
Maybe I simply should divide color by 255, and set gamma in image pipeline to 1.0. The only thing I want to do is to get the same color on render that I set is scene setup.
BTW. It wold be nice to know how blender converts the colors
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Tue Nov 10, 2020 1:36 pm
by bartek_zgo
OK. I have simplified the problem. If I create a plain texture (all covered by one color), add to matte material and render, I get correct color. When I use the same color that I used in texture, divide it by 255, render, I get different color in render image. What formula I have to apply to the color to get the same result?
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Tue Nov 10, 2020 1:41 pm
by Dade
bartek_zgo wrote: Tue Nov 10, 2020 1:36 pm
OK. I have simplified the problem. If I create a plain texture (all covered by one color), add to matte material and render, I get correct color. When I use the same color that I used in texture, divide it by 255, render, I get different color in render image. What formula I have to apply to the color to get the same result?
Image maps are reversed gamma corrected by LuxCore if the gamma of the image is set 2.2 (i.e. it has the correct and expected behavior). If you set the image maps gamma to 1.0, there will be no reverse gamma correction.
LuxCore works in "sRGB" space: the input and the output are the same. If you use a gamma correction plugin in the image pipeline (i.e. very likely): the inputs will be "sRGB" and the outputs will be sRGB+Gamma Correction.
You have to set your mind straight on the color space where are you are working or you will end with a mess.
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Wed Nov 11, 2020 9:48 am
by bartek_zgo
Thanks for reply. Now I understand. Images are automatically converted from gamma 2.2 to 1.0 color space. The color that I want to pass has to be in linear color space. If somebody will need it here is the formula how convert sRGB color to linear color space:
https://www.nayuki.io/page/srgb-transform-library
and here is ready to use code:
http://entropymine.com/imageworsener/srgbformula/
It works perfect

Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Thu Nov 19, 2020 11:35 am
by bartek_zgo
Another question. Let say I have a gray texture (color 127, 127, 127). So it has a luminance of 50%. Than I want to apply this texture to Metalic parameter of Disney material. So I should get the same result as setting Metailic parameter to 0.5. But the render result is different.
If I understood correctly, when I add a texture to LuxCore, a revers gamma correction is applied automatically. So the texture does not have luminance of 50% anymore.
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Thu Nov 19, 2020 11:38 am
by B.Y.O.B.
You will need to set the gamma to 1 for such "non-color" data textures. Same for bump maps, roughness maps etc.
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Thu Nov 19, 2020 11:43 am
by bartek_zgo
I think I have found. I have to set gamma parameter to 1.0
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Thu Nov 19, 2020 11:55 am
by bartek_zgo
thanks B.Y.O.B.
More complex question. I have a texture that I want to put in Diffuse Color of Matte material. I have to import it with gamma 2.2. I add brightness/contrast correction node. I want to increase brightness of 20%. So I set control to 0.2. But the result is different than I have in other programs. That is quite logical, because I apply brightness correction to the image that has inverse gamma correction already applied.
So my question is. What to do to have the same effect, as modifying brightens by 20% in photoshop and than importing to luxcore.
Should I import texture with gamma 1.0, than apply brightness correction 0.2 and than in some way (I don't know how) apply revers gamma correction?
Re: color conversion from standard rgb 0-255 to luxcore 0-1
Posted: Tue Nov 24, 2020 11:32 am
by bartek_zgo
I have found a solution form my problem. Maybe it will be helpful for someone else:
So simply, first I import image with gamma 1.0. Than I make brightness/contrast correction on ORIGINAL image. Than I apply gamma correction. As I didn't found power function for color, I split the color first and than assembly it again.