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