1 | struct VS_OUT
|
---|
2 | {
|
---|
3 | float4 hPosition : POSITION;
|
---|
4 | float2 texCoord : TEXCOORD0;
|
---|
5 | };
|
---|
6 |
|
---|
7 | VS_OUT Default_VS(float4 position : POSITION,
|
---|
8 | float4 texCoord : TEXCOORD0)
|
---|
9 | {
|
---|
10 | VS_OUT OUT;
|
---|
11 | OUT.hPosition = float4(sign(position.xy),0,1);
|
---|
12 | OUT.texCoord = (float2(OUT.hPosition.x, -OUT.hPosition.y) + 1.0) / 2.0;
|
---|
13 | return OUT;
|
---|
14 | }
|
---|
15 |
|
---|
16 | float4 Black_PS(VS_OUT IN):COLOR
|
---|
17 | {
|
---|
18 | return float4(0,0,0,1);
|
---|
19 | }
|
---|
20 |
|
---|
21 | float4 Copy_PS(VS_OUT IN,
|
---|
22 | uniform float width,
|
---|
23 | uniform float height,
|
---|
24 | uniform sampler2D Texture: register(s0)) : COLOR
|
---|
25 | {
|
---|
26 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
27 | // return 1;
|
---|
28 | return tex2D(Texture, IN.texCoord);
|
---|
29 | }
|
---|
30 |
|
---|
31 | float4 AlphaBlend_PS(VS_OUT IN,
|
---|
32 | uniform float width,
|
---|
33 | uniform float height,
|
---|
34 | uniform float alpha,
|
---|
35 | uniform sampler2D Texture: register(s0)) : COLOR
|
---|
36 | {
|
---|
37 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
38 | return float4(tex2D(Texture, IN.texCoord).rgb, alpha);
|
---|
39 | }
|
---|
40 |
|
---|
41 | float4 Add_PS(VS_OUT IN,
|
---|
42 | uniform float width,
|
---|
43 | uniform float height,
|
---|
44 | uniform sampler2D Texture1: register(s0),
|
---|
45 | uniform sampler2D Texture2: register(s1)
|
---|
46 | ):COLOR
|
---|
47 | {
|
---|
48 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
49 | return tex2D(Texture1,IN.texCoord ) + tex2D(Texture2,IN.texCoord );
|
---|
50 | }
|
---|
51 |
|
---|
52 | float4 Combine_PS(VS_OUT IN,
|
---|
53 | uniform float width,
|
---|
54 | uniform float height,
|
---|
55 | uniform float weight1,
|
---|
56 | uniform float weight2,
|
---|
57 | uniform sampler2D Texture1: register(s0),
|
---|
58 | uniform sampler2D Texture2: register(s1)
|
---|
59 | ):COLOR
|
---|
60 | {
|
---|
61 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
62 | return tex2D(Texture1,IN.texCoord ) * weight1 + tex2D(Texture2,IN.texCoord ) * weight2;
|
---|
63 | }
|
---|
64 |
|
---|
65 | half4 Luminance_PS(VS_OUT IN,
|
---|
66 | uniform half width,
|
---|
67 | uniform half height,
|
---|
68 | uniform sampler2D Texture: register(s0)
|
---|
69 | ):COLOR
|
---|
70 | {
|
---|
71 | IN.texCoord += half2(0.5/width, 0.5/height);
|
---|
72 | half4 sample = tex2D(Texture,IN.texCoord );
|
---|
73 |
|
---|
74 | // D65 white conversion and weighting
|
---|
75 | half avg = sample.r * 0.21f + sample.g * 0.39f + sample.b * 0.4f;
|
---|
76 | return half4(avg, 0, 0, 1);
|
---|
77 | }
|
---|
78 |
|
---|
79 | float4 GlowCut_PS(VS_OUT IN,
|
---|
80 | uniform float width,
|
---|
81 | uniform float height,
|
---|
82 | uniform float cutValue,
|
---|
83 | uniform float timeBlur,
|
---|
84 | uniform sampler2D Texture: register(s0)
|
---|
85 | ,uniform sampler2D LastTexture: register(s1)
|
---|
86 | ):COLOR
|
---|
87 | {
|
---|
88 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
89 | float4 sample = 2.0 * tex2D(Texture,IN.texCoord );
|
---|
90 | float luminance = dot(sample.rgb, float3(1.0, 4.5907, 0.0601));
|
---|
91 | if (luminance < cutValue) sample = float4(0,0,0,0);
|
---|
92 | float alpha = timeBlur;
|
---|
93 | sample = sample * alpha + tex2D(LastTexture, IN.texCoord) * (1.0 - alpha);
|
---|
94 |
|
---|
95 | return sample;
|
---|
96 | }
|
---|
97 |
|
---|
98 | float4 GlowBlurH_PS(VS_OUT IN,
|
---|
99 | uniform float Stretch,
|
---|
100 | uniform float width,
|
---|
101 | uniform float height,
|
---|
102 | uniform float timeBlur,
|
---|
103 | uniform sampler2D Texture: register(s0)) : COLOR
|
---|
104 | {
|
---|
105 | float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height);
|
---|
106 | float4 texLookUp_h;
|
---|
107 |
|
---|
108 | /*texLookUp_h = tex2D(Texture, float2(tex0.x-(3.86979f*Stretch/width), tex0.y)) +
|
---|
109 | tex2D(Texture, float2(tex0.x-(1.72291f*Stretch/width ), tex0.y)) +
|
---|
110 | tex2D(Texture, tex0) +
|
---|
111 | tex2D(Texture, float2(tex0.x+(1.72291f*Stretch/width), tex0.y)) +
|
---|
112 | tex2D(Texture, float2(tex0.x+(3.86979f*Stretch/width), tex0.y));*/
|
---|
113 |
|
---|
114 | texLookUp_h = tex2D(Texture, float2(tex0.x-(2.0*Stretch/width), tex0.y)) +
|
---|
115 | tex2D(Texture, float2(tex0.x-(1.0*Stretch/width ), tex0.y)) +
|
---|
116 | tex2D(Texture, tex0) +
|
---|
117 | tex2D(Texture, float2(tex0.x+(1.0*Stretch/width), tex0.y)) +
|
---|
118 | tex2D(Texture, float2(tex0.x+(2.0*Stretch/width), tex0.y));
|
---|
119 |
|
---|
120 | return float4(texLookUp_h.rgb / 5.0, timeBlur) ;
|
---|
121 | }
|
---|
122 |
|
---|
123 | float4 GlowBlurV_PS(VS_OUT IN,
|
---|
124 | uniform float Stretch,
|
---|
125 | uniform float width,
|
---|
126 | uniform float height,
|
---|
127 | uniform float timeBlur,
|
---|
128 | uniform sampler2D Texture: register(s0)) : COLOR
|
---|
129 | {
|
---|
130 | float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height);
|
---|
131 | float4 texLookUp_v;
|
---|
132 |
|
---|
133 | /*texLookUp_v = tex2D(Texture, float2(tex0.x, tex0.y-(3.86979f*Stretch/height)))+
|
---|
134 | tex2D(Texture, float2(tex0.x, tex0.y-(1.72291f*Stretch/height)))+
|
---|
135 | tex2D(Texture, tex0)+
|
---|
136 | tex2D(Texture, float2(tex0.x, tex0.y+(1.72291f*Stretch/height)))+
|
---|
137 | tex2D(Texture, float2(tex0.x, tex0.y+(3.86979f*Stretch/height)));*/
|
---|
138 |
|
---|
139 | texLookUp_v = tex2D(Texture, float2(tex0.x, tex0.y-(2*Stretch/height))) +
|
---|
140 | tex2D(Texture, float2(tex0.x, tex0.y-(1*Stretch/height))) +
|
---|
141 | tex2D(Texture, tex0) +
|
---|
142 | tex2D(Texture, float2(tex0.x, tex0.y+(1*Stretch/height))) +
|
---|
143 | tex2D(Texture, float2(tex0.x, tex0.y+(2*Stretch/height)));
|
---|
144 |
|
---|
145 | return float4(texLookUp_v.rgb / 5.0, timeBlur);
|
---|
146 | }
|
---|
147 |
|
---|
148 | float4 ToneMap_PS(VS_OUT IN,
|
---|
149 | uniform half width,
|
---|
150 | uniform half height,
|
---|
151 | uniform half Gain,
|
---|
152 | uniform sampler2D Scene: register(s0),
|
---|
153 | uniform sampler2D AvrLuminanceTexture: register(s1),
|
---|
154 | uniform sampler2D LuminanceTexture: register(s2),
|
---|
155 | uniform sampler2D GlobalLuminanceTexture: register(s3)
|
---|
156 | ):COLOR
|
---|
157 | {
|
---|
158 | IN.texCoord += half2(0.5/width, 0.5/height);
|
---|
159 |
|
---|
160 | float gLum = tex2D(GlobalLuminanceTexture, float2(0.5,0.5)).r;
|
---|
161 | gLum = max(gLum, 0.31415);
|
---|
162 |
|
---|
163 | // Automatic key calculation
|
---|
164 | //half Key = 1.03f - 2.0f / (2.0f + log10(tex2D(AvrLuminanceTexture, IN.texCoord).r + 1.0f));
|
---|
165 | //half Key = 1 / (tex2D(AvrLuminanceTexture, IN.texCoord).r / 1 + tex2D(AvrLuminanceTexture, IN.texCoord).r);
|
---|
166 | //return 1 / Key;
|
---|
167 | // Relative luminance
|
---|
168 | //half RelLum = Key* tex2D(LuminanceTexture, IN.texCoord).r /
|
---|
169 | // tex2D(AvrLuminanceTexture, IN.texCoord).r;
|
---|
170 | half Key = 1.03f - 2.0f / (2.0f + log10(gLum + 1.0f));
|
---|
171 | half RelLum = Key* tex2D(LuminanceTexture, IN.texCoord).r / gLum;
|
---|
172 | half Lum = RelLum / (1 + RelLum);
|
---|
173 | // Color weghting
|
---|
174 | half4 Color = tex2D(Scene, IN.texCoord) / gLum * 0.4f;
|
---|
175 | // Gamma correction
|
---|
176 |
|
---|
177 | //Color = pow(Color * half4(1.05f, 0.97f, 1.27f, 1.0f), Gain);
|
---|
178 | return Color + 0.0000000000001 * Gain;
|
---|
179 | //return gLum;
|
---|
180 | return float4(tex2D(GlobalLuminanceTexture, IN.texCoord).r,
|
---|
181 | tex2D(GlobalLuminanceTexture, IN.texCoord).r,
|
---|
182 | tex2D(GlobalLuminanceTexture, IN.texCoord).r,
|
---|
183 | 1);
|
---|
184 | } |
---|