浏览代码

Merge pull request #431 from UnityTech/kgdev

fix linear color space
/main
GitHub 4 年前
当前提交
dad60af6
共有 1 个文件被更改,包括 15 次插入3 次删除
  1. 18
      Runtime/Resources/shaders/UIWidgets_canvas.cginc

18
Runtime/Resources/shaders/UIWidgets_canvas.cginc


float2 fpos : TEXCOORD1;
};
inline half3 gamma_to_linear_space(half3 sRGB) {
return sRGB * (sRGB * (sRGB * 0.305306011h + 0.682171111h) + 0.012522878h);
}
inline half4 adjust_color(half4 color) {
#ifdef UNITY_COLORSPACE_GAMMA
return color;
#else
color.rgb = gamma_to_linear_space(color.rgb);
return color;
#endif
}
half shader_gradient_layout(half2 pos) {
half4 p4 = half4(pos, 0.0, 1.0);

half4 shader_gradient_colorize(half pt) {
if (_tileMode == 0) { // clamp
if (pt <= 0.0) {
return _leftColor;
return adjust_color(_leftColor);
return _rightColor;
return adjust_color(_rightColor);
}
half2 coord = half2(pt, 0.5);

half4 c;
#if defined(UIWIDGETS_COLOR)
c = _color;
c = adjust_color(_color);
#elif defined(UIWIDGETS_IMAGE)
half2 pt = shader_image_layout(i.fpos);
c = shader_image_colorize(pt);

正在加载...
取消
保存