This repository was archived by the owner on Apr 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Runtime/Resources/shaders Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ struct v2f {
3030 float2 fpos : TEXCOORD1 ;
3131};
3232
33+ inline half3 gamma_to_linear_space (half3 sRGB) {
34+ return sRGB * (sRGB * (sRGB * 0. 305306011h + 0. 682171111h) + 0. 012522878h);
35+ }
36+
37+ inline half4 adjust_color (half4 color) {
38+ #ifdef UNITY_COLORSPACE_GAMMA
39+ return color;
40+ #else
41+ color.rgb = gamma_to_linear_space (color.rgb);
42+ return color;
43+ #endif
44+ }
3345
3446half shader_gradient_layout (half2 pos) {
3547 half4 p4 = half4 (pos, 0.0 , 1.0 );
@@ -50,9 +62,9 @@ half shader_gradient_layout(half2 pos) {
5062half4 shader_gradient_colorize (half pt) {
5163 if (_tileMode == 0 ) { // clamp
5264 if (pt <= 0.0 ) {
53- return _leftColor;
65+ return adjust_color ( _leftColor) ;
5466 } else if (pt >= 1.0 ) {
55- return _rightColor;
67+ return adjust_color ( _rightColor) ;
5668 }
5769
5870 half2 coord = half2 (pt, 0.5 );
@@ -107,7 +119,7 @@ half4 shader_color (v2f i) {
107119 half4 c;
108120
109121#if defined (UIWIDGETS_COLOR)
110- c = _color;
122+ c = adjust_color ( _color) ;
111123#elif defined (UIWIDGETS_IMAGE)
112124 half2 pt = shader_image_layout (i.fpos);
113125 c = shader_image_colorize (pt);
You can’t perform that action at this time.
0 commit comments