• News

• Industries

• Learning & Support

• Community

• Marketplace

# 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.

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

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.

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.

``````
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;
}

``````

Here is the invert:

``````
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;
}

``````

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.

@rosegoldslugs, thank you.

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.

To convert a SRGB to FLOAT use Power(X, 2.186).
To convert a FLOAT to SRGB, use Power(X, 0.4574).