daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uniform extern texture ScreenTexture;  
  2.  
  3. float diamondMatrix[5][5] = {
  4.                             { 0.2, 0.4, 0.5, 0.4, 0.2},
  5.                             { 0.4, 0.6, 0.8, 0.6, 0.4},
  6.                             { 0.5, 0.8, 0.9, 0.8, 0.5},
  7.                             { 0.4, 0.6, 0.8, 0.6, 0.4},
  8.                             { 0.2, 0.4, 0.5, 0.4, 0.2}
  9.                             };
  10.  
  11. float xPixelWidth = (float)1 / (float)1280;
  12. float yPixelWidth = (float)1 / (float)720;
  13. //bool isBlack = false;
  14.  
  15. sampler ScreenS = sampler_state
  16. {
  17.     Texture = <ScreenTexture>; 
  18. };
  19.  
  20. int edgeWidth; // Set to 2, 1, or 0. 3 crashes Shader Model 2.
  21.  
  22. //XNA3.0 float4 PixelShader(float2 texCoord: TEXCOORD0) : COLOR
  23. float4 GreyScale(float2 texCoord: TEXCOORD0) : COLOR
  24. {
  25.     float4 color = tex2D(ScreenS, texCoord);
  26.     float grey = (color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722);
  27.     color.r = grey;
  28.     color.g = grey;
  29.     color.b = grey;
  30.  
  31.     return color;
  32. }
  33.  
  34. float4 PixelShaderFunction(float2 texCoord: TEXCOORD0) : COLOR
  35. {
  36.     /*
  37.     float4 color = tex2D(ScreenS, texCoord);
  38.    
  39.     if (texCoord[0] > 0.5f)
  40.     {
  41.         color[0] = 1 - color[0];
  42.         color[1] = 1 - color[1];
  43.         color[2] = 1 - color[2];
  44.     }
  45.     */
  46.    
  47.     int xPixelPos = (texCoord.x / xPixelWidth) % 5;
  48.     int yPixelPos = (texCoord.y / yPixelWidth) % 5;
  49.    
  50.  
  51.     float4 color = tex2D(ScreenS, texCoord);   
  52.    
  53.     float intensity = color[0];
  54.     //float intensity = 0.5;
  55.     /*
  56.     //Draw a 1px border around anything totally transparent
  57.     float4 edgeColor;
  58.     float2 coord;
  59.  
  60.     for(int i = -1; i <= 1; i++)
  61.     {
  62.         for(int j = -1; j <= 1; j++)
  63.         {
  64.             coord = texCoord;
  65.             coord[0] += i * xPixelWidth;
  66.             coord[1] += j * yPixelWidth;
  67.  
  68.             edgeColor = tex2D(ScreenS, coord);
  69.            
  70.             if(edgeColor[1] == 1)
  71.             {
  72.                 color[0] = 0;
  73.                 color[1] = 0;
  74.                 color[2] = 0;
  75.             }
  76.         }
  77.     }*/
  78.  
  79.     if(intensity < diamondMatrix[xPixelPos][yPixelPos])
  80.     {
  81.         return float4(0, 0, 0, color[3]);
  82.     }
  83.     else
  84.     {
  85.         return float4(1, 1, 1, color[3]);
  86.     }
  87. }
  88. technique
  89. {
  90.     pass P0
  91.     {
  92.         //XNA3.0 PixelShader = compile ps_2_0 PixelShader();
  93.         PixelShader = compile ps_2_0 GreyScale();
  94.     }
  95.     pass P1
  96.     {
  97.         PixelShader = compile ps_2_0 PixelShaderFunction();
  98.     }
  99. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top