-
Notifications
You must be signed in to change notification settings - Fork 965
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually Do sRGB Conversion During Web Present
- Loading branch information
Showing
3 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#version 300 es | ||
precision mediump float; | ||
in vec2 uv; | ||
uniform sampler2D present_texture; | ||
out vec4 frag; | ||
vec4 linear_to_srgb(vec4 linear) { | ||
vec3 color_linear = linear.rgb; | ||
vec3 selector = ceil(color_linear - 0.0031308); // 0 if under value, 1 if over | ||
vec3 under = 12.92 * color_linear; | ||
vec3 over = 1.055 * pow(color_linear, vec3(0.41666)) - 0.055; | ||
vec3 result = mix(under, over, selector); | ||
return vec4(result, linear.a); | ||
} | ||
void main() { | ||
frag = linear_to_srgb(texture(present_texture, uv)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#version 300 es | ||
precision mediump float; | ||
// A triangle that fills the whole screen | ||
const vec2[3] TRIANGLE_POS = vec2[]( | ||
vec2( 0.0, -3.0), | ||
vec2(-3.0, 1.0), | ||
vec2( 3.0, 1.0) | ||
); | ||
const vec2[3] TRIANGLE_UV = vec2[]( | ||
vec2( 0.5, 1.), | ||
vec2( -1.0, -1.0), | ||
vec2( 2.0, -1.0) | ||
); | ||
out vec2 uv; | ||
void main() { | ||
uv = TRIANGLE_UV[gl_VertexID]; | ||
gl_Position = vec4(TRIANGLE_POS[gl_VertexID], 0.0, 1.0); | ||
} |