*/}}
Parcourir la source

P3 color space

YimingWu il y a 3 mois
Parent
commit
32464106e6
5 fichiers modifiés avec 33 ajouts et 8 suppressions
  1. 1 0
      la_interface.h
  2. 1 0
      la_tns.h
  3. 2 0
      resources/la_properties.c
  4. 23 7
      resources/la_tns_shaders.cpp
  5. 6 1
      resources/la_widgets.c

+ 1 - 0
la_interface.h

@@ -1218,6 +1218,7 @@ STRUCTURE(laWidget){
 #define LA_TEXT_ONE_LINE       (1<<23)
 #define LA_UI_FLAGS_NO_SCROLL_INACTIVE (1<<24)
 #define LA_UI_FLAGS_COLOR_SPACE_CLAY (1<<25)
+#define LA_UI_FLAGS_COLOR_SPACE_D65_P3 LA_UI_FLAGS_NO_SCROLL_INACTIVE
 #define LA_UI_FLAGS_EXIT_WHEN_TRIGGERED LA_UI_FLAGS_COLOR_SPACE_CLAY
 #define LA_TEXT_LCD_16         (1<<27)
 #define LA_TEXT_LCD_7          (1<<28)

+ 1 - 0
la_tns.h

@@ -55,6 +55,7 @@ extern const char* LA_SELECTION_FRAGMENT_SHADER;
 
 #define TNS_COLOR_SPACE_SRGB 0
 #define TNS_COLOR_SPACE_CLAY 1
+#define TNS_COLOR_SPACE_D65_P3 2
 
 //typedef real tnsMatrix33d[9];
 

+ 2 - 0
resources/la_properties.c

@@ -1850,6 +1850,7 @@ void la_RegisterInternalProps(){
             ep = laAddEnumProperty(p, "output_color_space", "Output Color Space", "Output color space of this window, set this to the monitor's color space to get accurate result", 0,0,0,0,0,offsetof(laWindow, OutputColorSpace), 0,laset_WindowColorSpace, 0,0,0,0,0,0,0,0);{
                 laAddEnumItemAs(ep, "SRGB", "sRGB", "Standard sRGB diplay", TNS_COLOR_SPACE_SRGB, 0);
                 laAddEnumItemAs(ep, "CLAY", "Clay", "Clay color space (AdobeRGB 1998 compatible)", TNS_COLOR_SPACE_CLAY, 0);
+                laAddEnumItemAs(ep, "D65_P3", "D65 P3", "D65 P3 color space", TNS_COLOR_SPACE_D65_P3, 0);
             }
             ep = laAddEnumProperty(p, "output_show_overflow", "Show Overflow", "Show stripes on overflowing colors", LA_WIDGET_ENUM_HIGHLIGHT, 0,0,0,0,offsetof(laWindow, OutputShowStripes), 0,laset_WindowShowStripes, 0,0,0,0,0,0,0,0);{
                 laAddEnumItemAs(ep, "NONE", "None", "Don't show overflow", 0,0);
@@ -1871,6 +1872,7 @@ void la_RegisterInternalProps(){
             ep = laAddEnumProperty(p, "color_space", "Output Color Space", "Hardware color space of this screen ", 0,0,0,0,0,offsetof(laScreen,ColorSpace), 0,laset_ScreenColorSpace, 0,0,0,0,0,0,0,0);{
                 laAddEnumItemAs(ep, "SRGB", "sRGB", "Standard sRGB diplay", TNS_COLOR_SPACE_SRGB, 0);
                 laAddEnumItemAs(ep, "CLAY", "Clay", "Clay color space (AdobeRGB 1998 compatible)", TNS_COLOR_SPACE_CLAY, 0);
+                laAddEnumItemAs(ep, "D65_P3", "D65 P3", "D65 P3 color space", TNS_COLOR_SPACE_D65_P3, 0);
             }
             laAddOperatorProperty(p,"remove","Remove","Remove this screen config","LA_remove_screen_config",0,0);
         }

+ 23 - 7
resources/la_tns_shaders.cpp

@@ -518,6 +518,12 @@ vec3 Clay2XYZ(vec3 color){
 				  vec3(0.0270343,0.0706872,0.9911085));
 	return color*mat;
 }
+vec3 D65P32XYZ(vec3 color){
+	mat3 mat=mat3(vec3(0.4865709,0.2656677,0.1982173),
+				  vec3(0.2289746,0.6917385,0.0792869),
+				  vec3(0.0000000,0.0451134,1.0439444));
+	return color*mat;
+}
 vec3 XYZ2sRGB(vec3 xyz){
 	mat3 mat=mat3(vec3(3.2404542,-1.5371385,-0.4985314),
 				  vec3(-0.9692660,1.8760108,0.0415560),
@@ -530,6 +536,12 @@ vec3 XYZ2Clay(vec3 xyz){
 				  vec3(0.0134474,-0.1183897,1.0154096));
 	return xyz*mat;
 }
+vec3 XYZ2D65P3(vec3 xyz){
+	mat3 mat=mat3(vec3(2.4934969,-0.9313836,-0.4027108),
+				  vec3(-0.8294890,1.7626641,0.0236247),
+				  vec3(0.0358458,-0.0761724,0.9568845));
+	return xyz*mat;
+}
 vec3 YUV2sRGB(vec3 yuv){
     yuv[0]=1.1643*(yuv[0]-0.0625);
     yuv[1]-=0.5; yuv[2]-=0.5;
@@ -707,20 +719,24 @@ vec4 ConvertColorSpace(vec4 _rgba){
 	vec3 color=_rgba.rgb;
     if(InputColorSpace!=OutputColorSpace){
         if(ColorMode==0){
-            if(InputColorSpace==0) color=to_linear_srgb(color);
+                 if(InputColorSpace==0) color=to_linear_srgb(color);
             else if(InputColorSpace==1) color=to_linear_clay(color);
+            else if(InputColorSpace==2) color=to_linear_srgb(color);
         } 
         vec3 xyz; if(ColorMode==1){ color.y=pow(color.y,max(HCYGamma,1.)); color=okhsl_to_linear_srgb(color); }
-        if(InputColorSpace==1){ xyz=Clay2XYZ(color); }
-        if(InputColorSpace==0){ xyz=sRGB2XYZ(color); }
-        if(OutputColorSpace==0){ color=to_log_srgb(XYZ2sRGB(xyz)); /*_rgba.a=srgb_transfer_function(_rgba.a);*/ }
-        if(OutputColorSpace==1){ color=to_log_clay(XYZ2Clay(xyz)); /*_rgba.a=pow(_rgba.a,1.0/2.19921875);*/ }
+             if(InputColorSpace==1){ xyz=Clay2XYZ(color); }
+        else if(InputColorSpace==0){ xyz=sRGB2XYZ(color); }
+        else if(InputColorSpace==2){ xyz=D65P32XYZ(color); }
+             if(OutputColorSpace==0){ color=to_log_srgb(XYZ2sRGB(xyz)); /*_rgba.a=srgb_transfer_function(_rgba.a);*/ }
+        else if(OutputColorSpace==1){ color=to_log_clay(XYZ2Clay(xyz)); /*_rgba.a=pow(_rgba.a,1.0/2.19921875);*/ }
+    	else if(OutputColorSpace==2){ color=to_log_srgb(XYZ2D65P3(xyz)); /*_rgba.a=pow(_rgba.a,1.0/2.19921875);*/ }
     }else{
         if(ColorMode==1){ color.y=pow(color.y,max(HCYGamma,1.)); color=okhsl_to_srgb(color); }
         else if(ColorMode==0){ color=color; }
         else{
-            if(OutputColorSpace==0){ color=to_log_srgb(color); /*_rgba.a=srgb_transfer_function(_rgba.a);*/ }
-            if(OutputColorSpace==1){ color=to_log_clay(color); /*_rgba.a=pow(_rgba.a,1.0/2.19921875);*/ }
+                 if(OutputColorSpace==0){ color=to_log_srgb(color); /*_rgba.a=srgb_transfer_function(_rgba.a);*/ }
+            else if(OutputColorSpace==1){ color=to_log_clay(color); /*_rgba.a=pow(_rgba.a,1.0/2.19921875);*/ }
+            else if(OutputColorSpace==2){ color=to_log_srgb(color); /*_rgba.a=pow(_rgba.a,1.0/2.19921875);*/ }
         }
     }
     if(ShowStripes!=0){

+ 6 - 1
resources/la_widgets.c

@@ -1255,15 +1255,19 @@ void la_ColorCircleDrawHCY(laUiItem *ui, int h){
     tnsFlush();
 
     int IsClay=ui->Flags&LA_UI_FLAGS_COLOR_SPACE_CLAY;
+    int IsP3=ui->Flags&LA_UI_FLAGS_COLOR_SPACE_D65_P3;
     int ShowInfo=0;
 
-    if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_SRGB && (!IsClay)){
+    if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_SRGB && (!IsClay) && (!IsP3)){
         tnsUniformShowColorOverflowStripes(T->immShader,1);
     }
 
     if(IsClay){
         tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_CLAY);
         if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_CLAY) ShowInfo=1;
+    }elif(IsP3){
+        tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_D65_P3);
+        if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_D65_P3) ShowInfo=1;
     }else{
         tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_SRGB);
     }
@@ -1338,6 +1342,7 @@ void la_ColorCircleDrawHCY(laUiItem *ui, int h){
     if(ui->Extra->HeightCoeff>=0) tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
 
     if(IsClay) tnsDrawStringAuto("Clay",laThemeColor(bt,LA_BT_BORDER),ui->L, c-r+LA_RH, ui->U+bt->TM, LA_TEXT_ALIGN_RIGHT|LA_TEXT_MONO);
+    if(IsP3) tnsDrawStringAuto("D65 P3",laThemeColor(bt,LA_BT_BORDER),ui->L, c-r+LA_RH, ui->U+bt->TM, LA_TEXT_ALIGN_RIGHT|LA_TEXT_MONO);
     if(ShowInfo) tnsDrawStringAuto("🛈",laThemeColor(bt,LA_BT_TEXT),c-r, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_LEFT);
 
     tnsFlush();