-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorProcess.shader
More file actions
95 lines (80 loc) · 1.77 KB
/
ColorProcess.shader
File metadata and controls
95 lines (80 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Shader "Hidden/ColorProcess"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
}
CGINCLUDE
#include "UnityCG.cginc"
#include "Utils.cginc"
Texture2D _MainTex;
SamplerState sampler_MainTex;
float4 _MainTex_TexelSize;
int _direction;
int _isLinearColorSpace;
float _screenWidth;
float _screenHeight;
float _texSize;
float _LOD;
struct Input
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
Varyings vertex(in Input input)
{
Varyings output;
output.vertex = UnityObjectToClipPos(input.vertex.xyz);
float sx = _texSize / _screenWidth;
float sy = _texSize / _screenHeight;
if (_direction == 1) {
output.uv = float2(input.uv.x * sx, input.uv.y * sy);
}
else if (_direction == -1) {
output.uv = float2(input.uv.x / sx, input.uv.y / sy);
}
else
output.uv = input.uv;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
output.uv.y = 1. - input.uv.y;
#endif
return output;
}
float4 fragment(in Varyings input) : SV_Target
{
float4 color = _MainTex.SampleLevel(sampler_MainTex, input.uv, _LOD);
if (_direction == -1)
{
if(_isLinearColorSpace ==1)
return float4(srgb2Linear(YCrCb2rgb(color.xyz)), color.a);
else
return float4(YCrCb2rgb(color.xyz), color.a);
}
if (_direction == 1 || _direction == 2)
{
if (_isLinearColorSpace == 1)
return float4(rgb2YCrCb(linear2Srgb(color.xyz)),color.a);
else
return float4(rgb2YCrCb(color.xyz), color.a);
}
return color;
}
ENDCG
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vertex
#pragma fragment fragment
ENDCG
}
}
}