4747 uniform samplerExternalOES texture0;
4848 out vec4 fragColor;
4949 uniform int engaged;
50+ uniform int enhance_driver;
5051
5152 void main() {
5253 vec4 color = texture(texture0, fragTexCoord);
5758 color.rgb = pow(color.rgb, vec3(1.0/1.28));
5859 fragColor = vec4(color.rgb, color.a);
5960 } else {
60- fragColor = vec4( color.rgb * 0.85, color.a) ; // 85% opacity
61+ color.rgb *= 0.85; // 85% opacity
6162 }
63+ if (enhance_driver == 1) {
64+ float brightness = 1.1;
65+ color.rgb = color.rgb + 0.15;
66+ color.rgb = clamp((color.rgb - 0.5) * (brightness * 0.8) + 0.5, 0.0, 1.0);
67+ color.rgb = color.rgb * color.rgb * (3.0 - 2.0 * color.rgb);
68+ color.rgb = pow(color.rgb, vec3(0.8));
69+ }
70+ fragColor = vec4(color.rgb, color.a);
6271 }
6372 """
6473else :
6877 uniform sampler2D texture1;
6978 out vec4 fragColor;
7079 uniform int engaged;
80+ uniform int enhance_driver;
7181
7282 void main() {
7383 float y = texture(texture0, fragTexCoord).r;
7787 float gray = dot(rgb, vec3(0.299, 0.587, 0.114));
7888 rgb = mix(vec3(gray), rgb, 0.2); // 20% saturation
7989 rgb = clamp((rgb - 0.5) * 1.2 + 0.5, 0.0, 1.0); // +20% contrast
80- fragColor = vec4(rgb, 1.0);
8190 } else {
82- fragColor = vec4(rgb * 0.85, 1.0); // 85% opacity
91+ rgb *= 0.85; // 85% opacity
92+ }
93+ // TODO: the images out of camerad need some more correction and
94+ // the ui should apply a gamma curve for the device display
95+ if (enhance_driver == 1) {
96+ float brightness = 1.1;
97+ rgb = rgb + 0.15;
98+ rgb = clamp((rgb - 0.5) * (brightness * 0.8) + 0.5, 0.0, 1.0);
99+ rgb = rgb * rgb * (3.0 - 2.0 * rgb);
100+ rgb = pow(rgb, vec3(0.8));
83101 }
102+ fragColor = vec4(rgb, 1.0);
84103 }
85104 """
86105
@@ -106,6 +125,8 @@ def __init__(self, name: str, stream_type: VisionStreamType):
106125 self ._texture1_loc : int = rl .get_shader_location (self .shader , "texture1" ) if not TICI else - 1
107126 self ._engaged_loc = rl .get_shader_location (self .shader , "engaged" )
108127 self ._engaged_val = rl .ffi .new ("int[1]" , [1 ])
128+ self ._enhance_driver_loc = rl .get_shader_location (self .shader , "enhance_driver" )
129+ self ._enhance_driver_val = rl .ffi .new ("int[1]" , [1 if stream_type == VisionStreamType .VISION_STREAM_DRIVER else 0 ])
109130
110131 self .frame : VisionBuf | None = None
111132 self .texture_y : rl .Texture | None = None
@@ -300,6 +321,7 @@ def _render_textures(self, src_rect: rl.Rectangle, dst_rect: rl.Rectangle) -> No
300321 def _update_texture_color_filtering (self ):
301322 self ._engaged_val [0 ] = 1 if ui_state .status != UIStatus .DISENGAGED else 0
302323 rl .set_shader_value (self .shader , self ._engaged_loc , self ._engaged_val , rl .ShaderUniformDataType .SHADER_UNIFORM_INT )
324+ rl .set_shader_value (self .shader , self ._enhance_driver_loc , self ._enhance_driver_val , rl .ShaderUniformDataType .SHADER_UNIFORM_INT )
303325
304326 def _ensure_connection (self ) -> bool :
305327 if not self .client .is_connected ():
0 commit comments