[1049] | 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 sampler2D Texture: register(s0)
|
---|
| 45 | ,uniform sampler2D LastTexture: register(s1)
|
---|
| 46 | ):COLOR
|
---|
| 47 | {
|
---|
| 48 |
|
---|
| 49 | /*float intens = length(tex2D(Texture,IN.texCoord ).rgb) / sqrt(3.0);
|
---|
| 50 | return float4(intens,intens,intens,1);*/
|
---|
| 51 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
| 52 | float4 sample = tex2D(Texture,IN.texCoord );
|
---|
| 53 | float luminance = dot(sample.rgb, float3(1.0, 4.5907, 0.0601));
|
---|
| 54 | if (luminance < 5.0) sample = float4(0,0,0,0);
|
---|
| 55 | //if (sample.r + sample.g + sample.b < 1.7f) sample = float4(0,0,0,0);
|
---|
| 56 |
|
---|
| 57 | float alpha = 0.06;
|
---|
| 58 | sample = sample * alpha + tex2D(LastTexture, IN.texCoord) * (1.0 - alpha);
|
---|
| 59 |
|
---|
| 60 | return sample;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | half4 LuminancePS(VS_OUT IN,
|
---|
| 64 | uniform half width,
|
---|
| 65 | uniform half height,
|
---|
| 66 | uniform sampler2D Texture: register(s0)
|
---|
| 67 | ):COLOR
|
---|
| 68 | {
|
---|
| 69 |
|
---|
| 70 | IN.texCoord += half2(0.5/width, 0.5/height);
|
---|
| 71 | half4 sample = tex2D(Texture,IN.texCoord );
|
---|
| 72 |
|
---|
| 73 | // D65 white conversion and weighting
|
---|
| 74 | half avg = sample.r * 0.21f + sample.g * 0.39f + sample.b * 0.4f;
|
---|
| 75 | return half4(avg, 0, 0, 1);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | float4 GlowAddPS(VS_OUT IN,
|
---|
| 79 | uniform float width,
|
---|
| 80 | uniform float height,
|
---|
| 81 | uniform sampler2D Texture: register(s0),
|
---|
| 82 | uniform sampler2D GlowTexture: register(s1)
|
---|
| 83 | ):COLOR
|
---|
| 84 | {
|
---|
| 85 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
| 86 | /*float intens = length(tex2D(Texture,IN.texCoord ).rgb) / sqrt(3.0);
|
---|
| 87 | return float4(intens,intens,intens,1);*/
|
---|
| 88 | //return 1;
|
---|
| 89 | return tex2D(Texture,IN.texCoord ) + tex2D(GlowTexture,IN.texCoord ) ;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | float4 ToneMapPS(VS_OUT IN,
|
---|
| 93 | uniform half width,
|
---|
| 94 | uniform half height,
|
---|
| 95 | uniform half Gain,
|
---|
| 96 | uniform sampler2D Scene: register(s0),
|
---|
| 97 | uniform sampler2D AvrLuminanceTexture: register(s1),
|
---|
| 98 | uniform sampler2D LuminanceTexture: register(s2)
|
---|
| 99 | ):COLOR
|
---|
| 100 | {
|
---|
| 101 | IN.texCoord += half2(0.5/width, 0.5/height);
|
---|
| 102 |
|
---|
| 103 | // Automatic key calculation
|
---|
| 104 | //half Key = 1.03f - 2.0f / (2.0f + log10(tex2D(AvrLuminanceTexture, IN.texCoord).r + 1.0f));
|
---|
| 105 | half Key = 1 / (tex2D(AvrLuminanceTexture, IN.texCoord).r / 1 + tex2D(AvrLuminanceTexture, IN.texCoord).r);
|
---|
| 106 | //return 1 / Key;
|
---|
| 107 | // Relative luminance
|
---|
| 108 | half RelLum = Key* tex2D(LuminanceTexture, IN.texCoord).r /
|
---|
| 109 | tex2D(AvrLuminanceTexture, IN.texCoord).r;
|
---|
| 110 | half Lum = RelLum / (1 + RelLum);
|
---|
| 111 | // Color weghting
|
---|
| 112 | half4 Color = tex2D(Scene, IN.texCoord) * Lum;
|
---|
| 113 | // Gamma correction
|
---|
| 114 |
|
---|
| 115 | //Color = pow(Color * half4(1.05f, 0.97f, 1.27f, 1.0f), Gain);
|
---|
| 116 | return Color;
|
---|
| 117 |
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | float4 GlowBlurHPS(VS_OUT IN,
|
---|
| 121 | uniform float Stretch,
|
---|
| 122 | uniform float width,
|
---|
| 123 | uniform float height,
|
---|
| 124 | uniform sampler2D Texture: register(s0)) : COLOR {
|
---|
| 125 | float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height);
|
---|
| 126 | float4 texLookUp_h;
|
---|
| 127 |
|
---|
| 128 | /*texLookUp_h = tex2D(Texture, float2(tex0.x-(3.86979f*Stretch/width), tex0.y)) +
|
---|
| 129 | tex2D(Texture, float2(tex0.x-(1.72291f*Stretch/width ), tex0.y)) +
|
---|
| 130 | tex2D(Texture, tex0) +
|
---|
| 131 | tex2D(Texture, float2(tex0.x+(1.72291f*Stretch/width), tex0.y)) +
|
---|
| 132 | tex2D(Texture, float2(tex0.x+(3.86979f*Stretch/width), tex0.y));*/
|
---|
| 133 |
|
---|
| 134 | texLookUp_h = tex2D(Texture, float2(tex0.x-(2.0*Stretch/width), tex0.y)) +
|
---|
| 135 | tex2D(Texture, float2(tex0.x-(1.0*Stretch/width ), tex0.y)) +
|
---|
| 136 | tex2D(Texture, tex0) +
|
---|
| 137 | tex2D(Texture, float2(tex0.x+(1.0*Stretch/width), tex0.y)) +
|
---|
| 138 | tex2D(Texture, float2(tex0.x+(2.0*Stretch/width), tex0.y));
|
---|
| 139 |
|
---|
| 140 | return texLookUp_h / 5.0 ;
|
---|
| 141 | //return texLookUp_h /5;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | float4 GlowBlurVPS(VS_OUT IN,
|
---|
| 145 | uniform float Stretch,
|
---|
| 146 | uniform float width,
|
---|
| 147 | uniform float height,
|
---|
| 148 | uniform sampler2D Texture: register(s0)) : COLOR {
|
---|
| 149 | float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height);
|
---|
| 150 | float4 texLookUp_v;
|
---|
| 151 |
|
---|
| 152 | /*texLookUp_v = tex2D(Texture, float2(tex0.x, tex0.y-(3.86979f*Stretch/height)))+
|
---|
| 153 | tex2D(Texture, float2(tex0.x, tex0.y-(1.72291f*Stretch/height)))+
|
---|
| 154 | tex2D(Texture, tex0)+
|
---|
| 155 | tex2D(Texture, float2(tex0.x, tex0.y+(1.72291f*Stretch/height)))+
|
---|
| 156 | tex2D(Texture, float2(tex0.x, tex0.y+(3.86979f*Stretch/height)));*/
|
---|
| 157 |
|
---|
| 158 | texLookUp_v = tex2D(Texture, float2(tex0.x, tex0.y-(2*Stretch/height)))+
|
---|
| 159 | tex2D(Texture, float2(tex0.x, tex0.y-(1*Stretch/height)))+
|
---|
| 160 | tex2D(Texture, tex0) +
|
---|
| 161 | tex2D(Texture, float2(tex0.x, tex0.y+(1*Stretch/height)))+
|
---|
| 162 | tex2D(Texture, float2(tex0.x, tex0.y+(2*Stretch/height)));
|
---|
| 163 |
|
---|
| 164 | return texLookUp_v / 5.0;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | float4 CopyPS(VS_OUT IN,
|
---|
| 168 | uniform float width,
|
---|
| 169 | uniform float height,
|
---|
| 170 | uniform sampler2D Texture: register(s0)) : COLOR
|
---|
| 171 | {
|
---|
| 172 | IN.texCoord += float2(0.5/width, 0.5/height);
|
---|
| 173 | return tex2D(Texture,IN.texCoord );
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 |
|
---|