Skip to main content
Various gramatical erros and code formatting
Source Link
Gustavo Maciel
  • 5.2k
  • 3
  • 25
  • 42

Opimized lineral Optimized linear to sRGB glsl codeGLSL

Currently I useI'm currently using a simple and ugly implementation of lineral -> linear to sRGB transfromtransform:

float sRGB(float x) {
    if ( x <= 0.00031308)
        return 12.92*x;92 * x;
    else
        return 1.055*pow(x,(1.0 / 2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
    return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}

PossiblePossibly, that the correction ( x <= 0.00031308 ) withfor small valesvalues (x <= 0.00031308) will not important for practicalmatter in practice.

I considerconsidered to just leave powlet ´pow(x,1 1.0 /2 2.4) but I'm not sure how much impact it will have.

Anyone can suggest ways forIs there any way to optimize it?

Can Can be vectorization help?

Can be Can some polynomal fitting be practical better  ?

Opimized lineral to sRGB glsl code

Currently I use simple and ugly implementation of lineral -> sRGB transfrom

float sRGB(float x) {
if ( x <= 0.00031308)
    return 12.92*x;
else
    return 1.055*pow(x,(1/2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
    return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}

Possible, that correction ( x <= 0.00031308 ) with small vales will not important for practical.

I consider just leave pow(x,1/2.4) but not sure how much impact it will have.

Anyone can suggest ways for optimize it?

Can be vectorization help?

Can be some polynomal fitting be practical better  ?

Optimized linear to sRGB GLSL

I'm currently using a simple implementation of linear to sRGB transform:

float sRGB(float x) {
    if (x <= 0.00031308)
        return 12.92 * x;
    else
        return 1.055*pow(x,(1.0 / 2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
    return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}

Possibly, that the correction for small values (x <= 0.00031308) will not matter in practice.

I considered to just let ´pow(x, 1.0 / 2.4) but I'm not sure how much impact it will have.

Is there any way to optimize it? Can be vectorization help? Can some polynomal fitting be better?

added 202 characters in body
Source Link

Currently I use simple and ugly implementation of lineral -> sRGB transfrom

float sRGB(float x) {
if ( x <= 0.00031308)
    return 12.92*x;
else
    return 1.055*pow(x,(1/2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
    return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}

Possible, that correction ( x <= 0.00031308 ) with small vales will not important for practical.

I consider just leave pow(x,1/2.4) but not sure how much impact it will have.

Anyone can suggest ways for optimize it?

Can be vectorization help? can

Can be some polynomal fitting have resultbe practical better ?

Currently I use simple and ugly implementation of lineral -> sRGB transfrom

float sRGB(float x) {
if ( x <= 0.00031308)
    return 12.92*x;
else
    return 1.055*pow(x,(1/2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
    return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}

Anyone can suggest ways for optimize it?

vectorization help? can be some polynomal fitting have result ?

Currently I use simple and ugly implementation of lineral -> sRGB transfrom

float sRGB(float x) {
if ( x <= 0.00031308)
    return 12.92*x;
else
    return 1.055*pow(x,(1/2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
    return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}

Possible, that correction ( x <= 0.00031308 ) with small vales will not important for practical.

I consider just leave pow(x,1/2.4) but not sure how much impact it will have.

Anyone can suggest ways for optimize it?

Can be vectorization help?

Can be some polynomal fitting be practical better ?

Source Link

Opimized lineral to sRGB glsl code

Currently I use simple and ugly implementation of lineral -> sRGB transfrom

float sRGB(float x) {
if ( x <= 0.00031308)
    return 12.92*x;
else
    return 1.055*pow(x,(1/2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
    return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}

Anyone can suggest ways for optimize it?

vectorization help? can be some polynomal fitting have result ?