Welcome, Guest.
Username: Password: Remember me

TOPIC: sRGB to Linear RGB (approximation)

sRGB to Linear RGB (approximation) 1 week 3 hours ago #1

A very simple shader that removes the inherent gamma correction in sRGB and approximates the linear RGB (where gamma=1) that a camera captures:
#include "ReShade.fxh"

float4 LinearisePass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target

float4 c0=tex2D(ReShade::BackBuffer, texcoord);
	c0.rgb=( c0.rgb > 0.00313066844250063 )?1.055 * pow(abs(c0.rgb),1/2.4) - 0.055:12.92 *c0.rgb;
return c0;

technique sRGB_to_Linear
		VertexShader = PostProcessVS;
		PixelShader = LinearisePass;

Then re-grade as you see fit, I suggest applying gamma (choosing your own value or algorithm could lead to better results) first.

Thing is, when I apply the formula that should theoretically be the right one it's like it applies the gamma correction again so I have to use the one that should go the other way.

Video shader here
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, jas01