View topic - YafaRay Texture Interpolation and Color Spaces, maybe wrong?

YafaRay Texture Interpolation and Color Spaces, maybe wrong?

Post here questions about using YafaRay materials, texturing and procedural models.

YafaRay Texture Interpolation and Color Spaces, maybe wrong?

Post Fri Jan 27, 2017 5:17 pm

Hello,

I've found what I believe is a fundamental problem in how YafaRay (and some other renderers) interpolate, and color space decode, textures used for rendering.

See: http://www.yafaray.org/node/787

Please let me know what do you think about this.
User avatar
David Bluecame
 
Posts: 460
Joined: Mon Jan 21, 2013 12:42 pm
Location: Spain

Re: YafaRay Texture Interpolation and Color Spaces, maybe wrong?

Post Mon Jan 30, 2017 11:32 am

Hi David

Linear spaces for render engines are about making better and more precise maths. If you need that space for interpolating textures, use it. But the result is a color for gamma corrected color spaces, so you need to transform it again like other sRGB inputs. You need to check whether is worth the precission loss or the complexity doing one or other way.
User avatar
Samo
 
Posts: 3091
Joined: Tue Dec 20, 2005 10:39 am
Location: Spain

Re: YafaRay Texture Interpolation and Color Spaces, maybe wrong?

Post Wed Jul 25, 2018 3:50 pm

Hello,
I am tasked with creating a YafaRay4tS Help file.
YafaRay4tS is an open source scripting project created by members of the trueSpace community to add functionality to trueSpace7.61 for exporting YafaRay formatted XML files for reading by the YafaRay render engine.

In the YafaRay4tS panel there is several aspects (Tabs) for settings that are used to capture user's choices that are exported to your awesome YafaRay v3.30 render engine.

In the Default aspect there is the 'Render Settings' for YafaRay.
There is options for Input Color Space.
Input Color Space is a Combo Control with 3 choices.

Input Color Space - ?

LinearRGB - ?
sRGB - ?
XYZ - ?


In the Background aspect there is options for Color Space
Color Space is a Combo Control with 4 choices.

Color Space - ?

CIE (D50) - ?
CIE (E) - ?
sRGB (D50) - ?
sRGB (D65) - ?

Exposure - ?

Was hoping that you could help me define these options with a simple definition.

The developer that is developing YafaRay4tS uses YafaRay for Blender as a source for information and or YafaRay's User Guide. I have read http://www.yafaray.org/node/787 and looked at several other areas for info on this and can not seem to find a clear understanding of these options.

Thanks in advance!

Sincerely,

Dave
trueBlue
 
Posts: 1
Joined: Wed Jul 25, 2018 3:01 pm

Re: YafaRay Texture Interpolation and Color Spaces, maybe wrong?

Post Thu Jul 26, 2018 10:42 am

Hello,

Thank you very much for your interest in YafaRay! :-)

Keep in mind I'm actively working on a significantly modified upcoming yafaray v4 that will have a more clearly defined API to be more compatible with 3rd party software, using either XML files, Python3 or directly interfacing with YafaRay interface C++ API.

The reason of those differences in the Color Space are historical. The Background was developed by other developers and the Color Space settings they included in the Background were only used for it but not for the rest of the software.

Around 2-3 years ago I introduced Color Spaces in the rest of the software but, to be honest, did not dare to mess around the Background color spaces code so I kept it "separate" with its own Color Space code and parameters.

I agree it would be ideal to have a single Color Space model for the entire renderer, including Backgrounds. I will have to study how the background code works and I will try to unify this in the upcoming v4 if I can...

Thanks and Best regards! :-)
User avatar
David Bluecame
 
Posts: 460
Joined: Mon Jan 21, 2013 12:42 pm
Location: Spain

Re: YafaRay Texture Interpolation and Color Spaces, maybe wrong?

Post Thu Jul 26, 2018 10:55 am

About the color spaces in the general renderer, there are actually 4 options:

* Linear RGB: in this mode, the colors are taken "as is" without any processing. For example color R=0.5, G=0.5, B=0.5 would be written in a "low dynamic range" such as PNG the following way: R=127, G=127, B=127 and vice-versa

* RAW / Manual Gamma: in this mode a Gamma value can be specified and the color values are transformed using the specified gamma value.

* sRGB: this mode is somewhat similar (but not the same) as a RAW Manual Gamma with gamma 2.2. However the sRGB standard is not exactly a gamma curve and has two segments (one linear and one exponencial). The difference is subtle but for color accuracy this is normally necessary when using PNG, JPG, etc.

* XYZ: this is experimental (and possibly not correctly implemented?)

The relevant code is in color.h:

Code: Select all
inline void color_t::ColorSpace_from_linearRGB(colorSpaces_t colorSpace, float gamma)
{
   //NOTE: Alpha value is not converted from linear to color space and vice versa. Should it be converted?
   if(colorSpace == SRGB)
   {
      R = sRGB_from_linearRGB(R);
      G = sRGB_from_linearRGB(G);
      B = sRGB_from_linearRGB(B);
   }
   else if(colorSpace == XYZ_D65)
   {
      float oldR = R, oldG = G, oldB = B;
      R = XYZ_D65_from_linearRGB[0][0] * oldR + XYZ_D65_from_linearRGB[0][1] * oldG + XYZ_D65_from_linearRGB[0][2] * oldB;
      G = XYZ_D65_from_linearRGB[1][0] * oldR + XYZ_D65_from_linearRGB[1][1] * oldG + XYZ_D65_from_linearRGB[1][2] * oldB;
      B = XYZ_D65_from_linearRGB[2][0] * oldR + XYZ_D65_from_linearRGB[2][1] * oldG + XYZ_D65_from_linearRGB[2][2] * oldB;
   }
   else if(colorSpace == RAW_MANUAL_GAMMA && gamma != 1.f)
   {
      if(gamma <= 0.f) gamma = 1.0e-2f; //Arbitrary lower boundary limit for the output gamma, to avoid division by 0
      float invGamma = 1.f / gamma;
      gammaAdjust(invGamma);
   }
}

The relevant code for the Background color space options is in a different place, in the file ColorConv.h I really need to unify all this... :-/
User avatar
David Bluecame
 
Posts: 460
Joined: Mon Jan 21, 2013 12:42 pm
Location: Spain


Return to Materials and Texturing



Who is online

Users browsing this forum: No registered users and 1 guest

cron