@@ -194,13 +194,6 @@ fn linear_to_srgb(linear: vec3<f32>) -> vec3<f32> {
194194 return select (higher , lower , cutoff );
195195}
196196
197- fn linear_to_srgb_component (linear : f32 ) -> f32 {
198- let cutoff = linear < 0 .0031308 ;
199- let higher = 1 .055 * pow (linear , 1 .0 / 2 .4 ) - 0 .055 ;
200- let lower = linear * 12 .92 ;
201- return select (higher , lower , cutoff );
202- }
203-
204197/// Convert a linear color to sRGBA space.
205198fn linear_to_srgba (color : vec4 <f32 >) -> vec4 <f32 > {
206199 return vec4 <f32 >(linear_to_srgb (color . rgb ), color . a );
@@ -243,12 +236,7 @@ fn hsla_to_rgba(hsla: Hsla) -> vec4<f32> {
243236 color . b += x ;
244237 }
245238
246- // Input colors are assumed to be in sRGB space,
247- // but blending and rendering needs to happen in linear space.
248- // The output will be converted to sRGB by either the target
249- // texture format or the swapchain color space.
250- let linear = srgb_to_linear (color );
251- return vec4 <f32 >(linear , a );
239+ return vec4 <f32 >(color , a );
252240}
253241
254242/// Convert a linear sRGB to Oklab space.
@@ -1169,18 +1157,15 @@ fn vs_mono_sprite(@builtin(vertex_index) vertex_id: u32, @builtin(instance_index
11691157@fragment
11701158fn fs_mono_sprite (input : MonoSpriteVarying ) -> @location (0 ) vec4 <f32 > {
11711159 let sample = textureSample (t_sprite , s_sprite , input . tile_position ). r ;
1172- // converting to linear space to do color operations as cosmic_text outputs texture data in srgb format
1173- // cannot make the gpu automatically do the conversion as there's no R8UnormSrgb format
1174- let sample_linear = srgb_to_linear_component (sample );
1175- let alpha_corrected = apply_contrast_and_gamma_correction (sample_linear , input . color . rgb , grayscale_enhanced_contrast , gamma_ratios );
1160+ let alpha_corrected = apply_contrast_and_gamma_correction (sample , input . color . rgb , grayscale_enhanced_contrast , gamma_ratios );
11761161
11771162 // Alpha clip after using the derivatives.
11781163 if (any (input . clip_distances < vec4 <f32 >(0 .0 ))) {
11791164 return vec4 <f32 >(0 .0 );
11801165 }
11811166
11821167 // convert to srgb space as the rest of the code (output swapchain) expects that
1183- return blend_color (input . color , linear_to_srgb_component ( alpha_corrected ) );
1168+ return blend_color (input . color , alpha_corrected );
11841169}
11851170
11861171// --- polychrome sprites --- //
@@ -1233,7 +1218,7 @@ fn fs_poly_sprite(input: PolySpriteVarying) -> @location(0) vec4<f32> {
12331218 let grayscale = dot (color . rgb , GRAYSCALE_FACTORS );
12341219 color = vec4 <f32 >(vec3 <f32 >(grayscale ), sample . a );
12351220 }
1236- return blend_color (color , linear_to_srgb_component ( sprite . opacity * saturate (0 .5 - distance ) ));
1221+ return blend_color (color , sprite . opacity * saturate (0 .5 - distance ));
12371222}
12381223
12391224// --- surfaces --- //
0 commit comments