Fix bloom computation
This commit is contained in:
parent
538694c1d1
commit
58e1b73752
@ -1,16 +1,18 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float low;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getCIEYxy(vec3 rgbColor);
|
||||
vec3 getRGBFromCIEXxy(vec3 YxyColor);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 uv = gl_FragCoord.xy / 512;
|
||||
vec3 col = texture(tex, uv).xyz;
|
||||
float luma = getCIEYxy(col).x;
|
||||
vec3 Yxy = getCIEYxy(col);
|
||||
vec3 WhiteYxy = getCIEYxy(vec3(1.));
|
||||
|
||||
col *= smoothstep(1., 10., luma);
|
||||
FragColor = vec4(col, 1.0);
|
||||
Yxy.x = smoothstep(WhiteYxy.x, WhiteYxy.x * 4, Yxy.x);
|
||||
|
||||
FragColor = vec4(getRGBFromCIEXxy(Yxy), 1.0);
|
||||
}
|
||||
|
@ -3,10 +3,12 @@
|
||||
|
||||
vec3 getCIEYxy(vec3 rgbColor)
|
||||
{
|
||||
mat3 sRGB2XYZ = transpose(mat3(
|
||||
mat3 RGB2XYZ = transpose(mat3(
|
||||
vec3(.4125, .2126, .0193),
|
||||
vec3(.3576, .7152, .1192),
|
||||
vec3(.1805, .0722, .9505)));
|
||||
|
||||
return sRGB2XYZ * rgbColor;
|
||||
vec3 xYz = RGB2XYZ * rgbColor;
|
||||
float tmp = xYz.x + xYz.y + xYz.z;
|
||||
return vec3(xYz.y, xYz.xy / tmp);
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ vec3 getRGBFromCIEXxy(vec3 YxyColor)
|
||||
float Yovery = YxyColor.x / YxyColor.z;
|
||||
vec3 XYZ = vec3(YxyColor.y * Yovery, YxyColor.x, (1. - YxyColor.y - YxyColor.z) * Yovery);
|
||||
|
||||
mat3 XYZ2sRGB = transpose(mat3(
|
||||
mat3 XYZ2RGB = transpose(mat3(
|
||||
vec3(3.2405, -.9693, .0556),
|
||||
vec3(-1.5371, 1.8760, -.2040),
|
||||
vec3(-.4985, .0416, 1.0572)));
|
||||
|
||||
vec3 sRGBColor = XYZ2sRGB * XYZ;
|
||||
return max(sRGBColor, vec3(0.));//vec3(pow(sRGBColor.x, 2.2), pow(sRGBColor.y, 2.2), pow(sRGBColor.z, 2.2));
|
||||
vec3 RGBColor = XYZ2RGB * XYZ;
|
||||
return max(RGBColor, vec3(0.));
|
||||
}
|
||||
|
||||
|
@ -1435,6 +1435,7 @@ namespace FullScreenShader
|
||||
Program = LoadProgram(OBJECT,
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getCIEXYZ.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getRGBfromCIEXxy.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bloom.frag").c_str());
|
||||
AssignUniforms();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user