support linear color.

This commit is contained in:
hecomi
2016-10-27 19:18:44 +09:00
parent de0c157fb5
commit 1e2ac40507
6 changed files with 17 additions and 9 deletions
@@ -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
@@ -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;
@@ -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
@@ -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);
}
@@ -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
+1 -1
View File
@@ -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.