Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform extern texture ScreenTexture;
- float diamondMatrix[5][5] = {
- { 0.2, 0.4, 0.5, 0.4, 0.2},
- { 0.4, 0.6, 0.8, 0.6, 0.4},
- { 0.5, 0.8, 0.9, 0.8, 0.5},
- { 0.4, 0.6, 0.8, 0.6, 0.4},
- { 0.2, 0.4, 0.5, 0.4, 0.2}
- };
- float xPixelWidth = (float)1 / (float)1280;
- float yPixelWidth = (float)1 / (float)720;
- //bool isBlack = false;
- sampler ScreenS = sampler_state
- {
- Texture = <ScreenTexture>;
- };
- int edgeWidth; // Set to 2, 1, or 0. 3 crashes Shader Model 2.
- //XNA3.0 float4 PixelShader(float2 texCoord: TEXCOORD0) : COLOR
- float4 GreyScale(float2 texCoord: TEXCOORD0) : COLOR
- {
- float4 color = tex2D(ScreenS, texCoord);
- float grey = (color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722);
- color.r = grey;
- color.g = grey;
- color.b = grey;
- return color;
- }
- float4 PixelShaderFunction(float2 texCoord: TEXCOORD0) : COLOR
- {
- /*
- float4 color = tex2D(ScreenS, texCoord);
- if (texCoord[0] > 0.5f)
- {
- color[0] = 1 - color[0];
- color[1] = 1 - color[1];
- color[2] = 1 - color[2];
- }
- */
- int xPixelPos = (texCoord.x / xPixelWidth) % 5;
- int yPixelPos = (texCoord.y / yPixelWidth) % 5;
- float4 color = tex2D(ScreenS, texCoord);
- float intensity = color[0];
- //float intensity = 0.5;
- /*
- //Draw a 1px border around anything totally transparent
- float4 edgeColor;
- float2 coord;
- for(int i = -1; i <= 1; i++)
- {
- for(int j = -1; j <= 1; j++)
- {
- coord = texCoord;
- coord[0] += i * xPixelWidth;
- coord[1] += j * yPixelWidth;
- edgeColor = tex2D(ScreenS, coord);
- if(edgeColor[1] == 1)
- {
- color[0] = 0;
- color[1] = 0;
- color[2] = 0;
- }
- }
- }*/
- if(intensity < diamondMatrix[xPixelPos][yPixelPos])
- {
- return float4(0, 0, 0, color[3]);
- }
- else
- {
- return float4(1, 1, 1, color[3]);
- }
- }
- technique
- {
- pass P0
- {
- //XNA3.0 PixelShader = compile ps_2_0 PixelShader();
- PixelShader = compile ps_2_0 GreyScale();
- }
- pass P1
- {
- PixelShader = compile ps_2_0 PixelShaderFunction();
- }
- }
Add Comment
Please, Sign In to add comment