Announcement

Collapse
No announcement yet.

How to convert an Alpha of Texture Sample from SRGB to FLOAT?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to convert an Alpha of Texture Sample from SRGB to FLOAT?

    Hi, I have a problem when plug an Alpha from the Texture Sample with the Base Color input. This is just an example but in the real project, I use the alpha with Subsurface Color and I don't know how to convert it? Please help, thanks.

    Let me explain the image below, the 3D Plane on the left has a weird color, everything becomes gray.
    Click image for larger version  Name:	Image.jpg Views:	1 Size:	122.8 KB ID:	1619771

  • replied
    I was wrong about everything, the problem has nothing to do with SRGB <--> FLOAT, but at least I discovered something, I must use Power(X, 1.75) if I want to have an exact result in Unreal Engine.
    People are wondering why I wrote these? That's because it will help me in the future, I will use this thread to document, and to remember everything.

    Edit: For the real project, I must use Power(X, 2) if I want an exact result, I don't understand.
    Click image for larger version  Name:	Pow.jpg Views:	1 Size:	90.1 KB ID:	1619923

    To convert a SRGB to FLOAT use Power(X, 2.186).
    To convert a FLOAT to SRGB, use Power(X, 0.4574).
    Last edited by mandaxyz; 05-20-2019, 08:40 AM.

    Leave a comment:


  • replied
    rosegoldslugs, thank you.
    Last edited by mandaxyz; 05-15-2019, 03:30 PM.

    Leave a comment:


  • replied
    The simplest solution is a power of 2.2, although it isn't the most accurate since it removes the tiny linear part of the sRGB curve.

    Leave a comment:


  • replied
    I understand if nobody can answer me for the moment because it takes a long time to open Unreal Engine and to create a project, so my solution is to use the math:

    I will reference on the first function below from https://github.com/apitrace/dxsdk/bl...matconvert.inl.
    Code:
    D3DX11INLINE FLOAT D3DX_SRGB_to_FLOAT_inexact(hlsl_precise FLOAT val)
    {
        if( val < 0.04045f )
            val /= 12.92f;
        else
            val = pow((val + 0.055f)/1.055f,2.4f);
        return val;
    }
    Click image for larger version  Name:	Material-Function.jpg Views:	1 Size:	75.7 KB ID:	1619842
    Please help me, is there a simpler method because I complicate the things?

    Here is the invert:
    Code:
    D3DX11INLINE FLOAT D3DX_FLOAT_to_SRGB(hlsl_precise FLOAT val)
    {
        if( val < 0.0031308f )
            val *= 12.92f;
        else
            val = 1.055f * pow(val,1.0f/2.4f) - 0.055f;
        return val;
    }
    Last edited by mandaxyz; 05-15-2019, 11:58 AM.

    Leave a comment:


  • replied
    Do you mean that I need to check the Scene Settings about Color? Let me explain my problem in Blender, I want a function like in the image below. I don't want to say "I want a curve", the real thing I want is a conversion from something between Linear and Non-Linear, I'm sorry I don't know how to call it, just something like that.

    Click image for larger version  Name:	Curve.jpg Views:	1 Size:	166.3 KB ID:	1619804
    Last edited by mandaxyz; 05-15-2019, 10:27 AM.

    Leave a comment:


  • replied
    you need to look at the Scene Color Buffer sionce it doesnt have the Tonemapper applied

    Leave a comment:

Working...
X