Compare commits

...

2 Commits

Author SHA1 Message Date
hecomi
ba5ebe8094 update readme. 2016-10-27 19:19:45 +09:00
hecomi
1e2ac40507 support linear color. 2016-10-27 19:18:44 +09:00
6 changed files with 18 additions and 9 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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

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.
@@ -38,5 +38,6 @@ Version
-------
| Data | Version | Description |
| ---------- | ------- | --------------------------------- |
| 2016/10/27 | 0.0.3 | Support lienar color. |
| 2016/10/27 | 0.0.2 | Add mouse cursor / shader family. |
| 2016/10/27 | 0.0.1 | Initial commit. |