Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. Texture2D DiffuseTexture;
  2. Texture2D DepthTexture;
  3.  
  4. float2 Center = { 0.5, 0.5 };
  5. float BlurWidth;
  6. float BlurStart = 1.0f;
  7. float NumberOfSamples = 32;
  8.  
  9. struct VS_INPUT
  10. {
  11.     float4 Pos : POSITION;
  12.     float2 Tex : TEXCOORD;
  13. };
  14.  
  15. struct PS_INPUT
  16. {
  17.     float4 Pos : SV_POSITION;
  18.     float2 Tex : TEXCOORD;
  19. };
  20.  
  21. shared SamplerState Sampler
  22. {
  23.     Filter = MIN_MAG_MIP_LINEAR;
  24.     AddressU = Border;
  25.     AddressV = Border;
  26. };
  27.  
  28. BlendState NoBlend
  29. {
  30.     AlphaToCoverageEnable = FALSE;
  31.     BlendEnable[0] = FALSE;
  32. };
  33.  
  34. DepthStencilState EnableDepthWrites
  35. {
  36.     DepthEnable = TRUE;
  37.     DepthWriteMask = ALL;
  38. };
  39.  
  40. PS_INPUT VS(VS_INPUT input)
  41. {
  42.     PS_INPUT output = (PS_INPUT)0;
  43.     output.Pos = input.Pos;
  44.     output.Tex = input.Tex;
  45.  
  46.     return output;
  47. }
  48.  
  49. float4 PS(PS_INPUT input) : SV_Target
  50. {
  51.     float2 UV = input.Tex - Center;
  52.     float4 color = 0;
  53.     for (int i = 0; i < NumberOfSamples; i++)
  54.     {
  55.         float scale = BlurStart - BlurWidth*(i / (float)(NumberOfSamples - 1));
  56.         color += DiffuseTexture.Sample(Sampler, UV * scale + Center);
  57.     }
  58.     color /= NumberOfSamples;
  59.     return color;
  60. }
  61.  
  62. technique10 Render
  63. {
  64.     pass P0
  65.     {
  66.         SetVertexShader(CompileShader(vs_5_0, VS()));
  67.         SetGeometryShader(NULL);
  68.         SetPixelShader(CompileShader(ps_5_0, PS()));
  69.         SetDepthStencilState(EnableDepthWrites, 0);
  70.         SetBlendState(NoBlend, float4(0, 0, 0, 0), 0xFFFFFFF);
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement