From 1e2ac40507366436ea460fc7d1b3fcc323372f93 Mon Sep 17 00:00:00 2001 From: hecomi Date: Thu, 27 Oct 2016 19:18:44 +0900 Subject: [PATCH] support linear color. --- Assets/uDesktopDuplication/Shaders/uDD_Common.cginc | 12 ++++++++++++ .../uDesktopDuplication/Shaders/uDD_Standard.shader | 3 +-- Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader | 3 +-- .../Shaders/uDD_Unlit_BlackMask.shader | 3 +-- .../Shaders/uDD_Unlit_Transparent.shader | 3 +-- README.md | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Common.cginc b/Assets/uDesktopDuplication/Shaders/uDD_Common.cginc index f97d8e7..8cfda5c 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Common.cginc +++ b/Assets/uDesktopDuplication/Shaders/uDD_Common.cginc @@ -1,6 +1,8 @@ #ifndef UDD_COMMON_CGINC #define UDD_COMMON_CGINC +#include "UnityCG.cginc" + inline void uddInvertUV(inout float2 uv) { #ifdef INVERT_X @@ -11,4 +13,14 @@ inline void uddInvertUV(inout float2 uv) #endif } +inline fixed4 uddGetTexture(sampler2D tex, float2 uv) +{ + uddInvertUV(uv); + fixed4 c = tex2D(tex, uv); + if (!IsGammaSpace()) { + c.rgb = GammaToLinearSpace(c.rgb); + } + return c; +} + #endif \ No newline at end of file diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Standard.shader b/Assets/uDesktopDuplication/Shaders/uDD_Standard.shader index 64d971e..9c80e7f 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Standard.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Standard.shader @@ -35,8 +35,7 @@ SubShader void surf(Input IN, inout SurfaceOutputStandard o) { - uddInvertUV(IN.uv_MainTex); - fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; + fixed4 c = uddGetTexture(_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Metallic = _Metallic; o.Smoothness = _Glossiness; diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader b/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader index c62f7c0..40516af 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Unlit.shader @@ -43,8 +43,7 @@ v2f vert(appdata v) fixed4 frag(v2f i) : SV_Target { - uddInvertUV(i.uv); - return tex2D(_MainTex, i.uv) * _Color; + return uddGetTexture(_MainTex, i.uv) * _Color; } ENDCG diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader index 1f60f44..fbbbf96 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_BlackMask.shader @@ -48,8 +48,7 @@ v2f vert(appdata v) fixed4 frag(v2f i) : SV_Target { - uddInvertUV(i.uv); - fixed4 tex = tex2D(_MainTex, i.uv); + fixed4 tex = uddGetTexture(_MainTex, i.uv); fixed alpha = pow((tex.r + tex.g + tex.b) / 3.0, _Mask); return fixed4(tex.rgb * _Color.rgb, alpha); } diff --git a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader index a6d042e..56cc858 100644 --- a/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader +++ b/Assets/uDesktopDuplication/Shaders/uDD_Unlit_Transparent.shader @@ -46,8 +46,7 @@ v2f vert(appdata v) fixed4 frag(v2f i) : SV_Target { - uddInvertUV(i.uv); - return fixed4(tex2D(_MainTex, i.uv).rgb, 1.0) * _Color; + return fixed4(uddGetTexture(_MainTex, i.uv).rgb, 1.0) * _Color; } ENDCG diff --git a/README.md b/README.md index a550f3f..8ed3a86 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ TODOs ----- - [x] Mouse cursor - [ ] Monitor selector -- [ ] Support linear color +- [x] Support linear color Please request new features you want to issues.